mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Renamed Object Classes folder to Objects
This commit is contained in:
parent
a2b935659f
commit
8ae65246f8
5 changed files with 134 additions and 64 deletions
|
|
@ -1,21 +0,0 @@
|
||||||
using System;
|
|
||||||
using Rage;
|
|
||||||
|
|
||||||
namespace SceneManager
|
|
||||||
{
|
|
||||||
class Barrier
|
|
||||||
{
|
|
||||||
internal Rage.Object Object { get; }
|
|
||||||
internal Model @Model{ get; }
|
|
||||||
internal Vector3 Position { get; }
|
|
||||||
internal float Rotation { get; }
|
|
||||||
|
|
||||||
internal Barrier(Rage.Object barrier, Vector3 barrierPosition, float barrierRotation)
|
|
||||||
{
|
|
||||||
Object = barrier;
|
|
||||||
@Model = barrier.Model;
|
|
||||||
Position = barrierPosition;
|
|
||||||
Rotation = barrierRotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
72
SceneManager/Objects/Barrier.cs
Normal file
72
SceneManager/Objects/Barrier.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Rage;
|
||||||
|
using SceneManager.Utils;
|
||||||
|
|
||||||
|
namespace SceneManager.Objects
|
||||||
|
{
|
||||||
|
class Barrier
|
||||||
|
{
|
||||||
|
internal Rage.Object Object { get; }
|
||||||
|
internal Model @Model{ get; }
|
||||||
|
internal Vector3 Position { get; }
|
||||||
|
internal float Rotation { get; }
|
||||||
|
internal bool Invincible { get; }
|
||||||
|
|
||||||
|
internal bool Immobile { get; }
|
||||||
|
|
||||||
|
internal Barrier(Rage.Object barrier, Vector3 barrierPosition, float barrierRotation, bool invincible, bool immobile)
|
||||||
|
{
|
||||||
|
Object = barrier;
|
||||||
|
@Model = barrier.Model;
|
||||||
|
Position = barrierPosition;
|
||||||
|
Rotation = barrierRotation;
|
||||||
|
Invincible = invincible;
|
||||||
|
Immobile = immobile;
|
||||||
|
//AddBlocker();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddBlocker()
|
||||||
|
{
|
||||||
|
var blocker = new Rage.Object("prop_barier_conc_01a", Position, Rotation);
|
||||||
|
blocker.AttachTo(Object, 0, new Vector3(0, 0, 0), new Rotator());
|
||||||
|
GameFiber.StartNew(() =>
|
||||||
|
{
|
||||||
|
while (Object)
|
||||||
|
{
|
||||||
|
GameFiber.Yield();
|
||||||
|
}
|
||||||
|
blocker.Delete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void GoAround()
|
||||||
|
{
|
||||||
|
GameFiber.StartNew(() =>
|
||||||
|
{
|
||||||
|
var collected = new List<Vehicle>();
|
||||||
|
while (Object)
|
||||||
|
{
|
||||||
|
foreach (Vehicle v in World.GetAllVehicles())
|
||||||
|
{
|
||||||
|
if(v && v.IsEngineOn)
|
||||||
|
{
|
||||||
|
if(v.HasDriver && v.Driver && v.Driver.IsAlive)
|
||||||
|
{
|
||||||
|
if (!collected.Contains(v))
|
||||||
|
{
|
||||||
|
v.Driver.Tasks.Clear();
|
||||||
|
v.Driver.Tasks.CruiseWithVehicle(5f, (VehicleDrivingFlags)17039872);
|
||||||
|
v.Driver.KeepTasks = true;
|
||||||
|
collected.Add(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GameFiber.Sleep(1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
using Rage;
|
using Rage;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using SceneManager.Utils;
|
||||||
|
|
||||||
namespace SceneManager
|
namespace SceneManager.Objects
|
||||||
{
|
{
|
||||||
internal class CollectedVehicle
|
internal class CollectedVehicle
|
||||||
{
|
{
|
||||||
|
|
@ -64,7 +65,7 @@ namespace SceneManager
|
||||||
DriveToNextWaypoint();
|
DriveToNextWaypoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!VehicleAndDriverAreValid() || Directed)
|
if (!Dismissed && !VehicleAndDriverAreValid() || Directed)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -251,11 +252,6 @@ namespace SceneManager
|
||||||
|
|
||||||
void StopAtWaypoint()
|
void StopAtWaypoint()
|
||||||
{
|
{
|
||||||
if (!VehicleAndDriverAreValid())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var stoppingDistance = GetAcceptedStoppingDistance(currentWaypoint.Path.Waypoints, currentWaypoint.Path.Waypoints.IndexOf(currentWaypoint));
|
var stoppingDistance = GetAcceptedStoppingDistance(currentWaypoint.Path.Waypoints, currentWaypoint.Path.Waypoints.IndexOf(currentWaypoint));
|
||||||
Game.LogTrivial($"{Vehicle.Model.Name} stopping at path {currentWaypoint.Path.Number} waypoint.");
|
Game.LogTrivial($"{Vehicle.Model.Name} stopping at path {currentWaypoint.Path.Number} waypoint.");
|
||||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, stoppingDistance, -1, true);
|
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, stoppingDistance, -1, true);
|
||||||
|
|
@ -280,14 +276,15 @@ namespace SceneManager
|
||||||
Game.LogTrivial($"CollectedVehicle is null");
|
Game.LogTrivial($"CollectedVehicle is null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Vehicle && !Dismissed)
|
if (!Vehicle)// && !Dismissed)
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"Vehicle is null");
|
Game.LogTrivial($"Vehicle is null");
|
||||||
Dismiss();
|
Dismiss();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!Driver || !Driver.IsAlive)
|
if (!Driver || !Driver.CurrentVehicle || !Driver.IsAlive)
|
||||||
{
|
{
|
||||||
|
Game.LogTrivial($"Driver is null or dead or not in a vehicle");
|
||||||
Dismiss();
|
Dismiss();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -297,8 +294,14 @@ namespace SceneManager
|
||||||
|
|
||||||
internal void Dismiss(DismissOption dismissOption = DismissOption.FromPath, Path newPath = null)
|
internal void Dismiss(DismissOption dismissOption = DismissOption.FromPath, Path newPath = null)
|
||||||
{
|
{
|
||||||
if (!Vehicle || !Driver)
|
if (!Vehicle)
|
||||||
{
|
{
|
||||||
|
Game.LogTrivial($"Vehicle is null.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Driver)
|
||||||
|
{
|
||||||
|
Game.LogTrivial($"Driver is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -311,27 +314,27 @@ namespace SceneManager
|
||||||
if (dismissOption == DismissOption.FromPlayer)
|
if (dismissOption == DismissOption.FromPlayer)
|
||||||
{
|
{
|
||||||
Dismissed = true;
|
Dismissed = true;
|
||||||
if (Driver)
|
//if (Driver)
|
||||||
{
|
//{
|
||||||
Driver.Dismiss();
|
Driver.Dismiss();
|
||||||
}
|
//}
|
||||||
if (Vehicle)
|
//if (Vehicle)
|
||||||
{
|
//{
|
||||||
Vehicle.Dismiss();
|
Vehicle.Dismiss();
|
||||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Vehicle, 0f, 1, true);
|
||||||
}
|
//}
|
||||||
Path.CollectedVehicles.Remove(this);
|
Path.CollectedVehicles.Remove(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Vehicle && StoppedAtWaypoint)
|
if(Driver.CurrentVehicle && StoppedAtWaypoint)
|
||||||
{
|
{
|
||||||
StoppedAtWaypoint = false;
|
StoppedAtWaypoint = false;
|
||||||
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Driver.CurrentVehicle, 0f, 1, true);
|
Rage.Native.NativeFunction.Natives.x260BE8F09E326A20(Driver.LastVehicle, 0f, 1, true);
|
||||||
if (Driver?.CurrentVehicle)
|
//if (Driver)
|
||||||
{
|
//{
|
||||||
Driver.Tasks.CruiseWithVehicle(5f);
|
Driver.Tasks.CruiseWithVehicle(5f);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
Driver.Tasks.Clear();
|
Driver.Tasks.Clear();
|
||||||
|
|
||||||
|
|
@ -3,18 +3,27 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
using SceneManager.Utils;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace SceneManager
|
namespace SceneManager.Objects
|
||||||
{
|
{
|
||||||
public class Path
|
internal class Path // Change this to Public for import/export
|
||||||
{
|
{
|
||||||
internal int Number { get; set; }
|
internal int Number { get; set; }
|
||||||
internal bool IsEnabled { get; set; }
|
internal bool IsEnabled { get; set; }
|
||||||
internal State State { get; set; }
|
internal State State { get; set; }
|
||||||
internal List<Waypoint> Waypoints = new List<Waypoint>();
|
|
||||||
|
[XmlArray("Waypoints")]
|
||||||
|
[XmlArrayItem("Waypoint")]
|
||||||
|
public List<Waypoint> Waypoints { get; set; } = new List<Waypoint>();
|
||||||
|
|
||||||
internal List<CollectedVehicle> CollectedVehicles = new List<CollectedVehicle>();
|
internal List<CollectedVehicle> CollectedVehicles = new List<CollectedVehicle>();
|
||||||
private List<Vehicle> _blacklistedVehicles = new List<Vehicle>();
|
private List<Vehicle> _blacklistedVehicles = new List<Vehicle>();
|
||||||
|
|
||||||
|
private Path() { }
|
||||||
|
|
||||||
internal Path(int pathNum, State pathState)
|
internal Path(int pathNum, State pathState)
|
||||||
{
|
{
|
||||||
Number = pathNum;
|
Number = pathNum;
|
||||||
|
|
@ -22,6 +31,18 @@ namespace SceneManager
|
||||||
DrawLinesBetweenWaypoints();
|
DrawLinesBetweenWaypoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void Save(string filename)
|
||||||
|
{
|
||||||
|
var GAME_DIRECTORY = Directory.GetCurrentDirectory();
|
||||||
|
var SAVED_PATHS_DIRECTORY = GAME_DIRECTORY + "/plugins/SceneManager/Saved Paths/";
|
||||||
|
if (!Directory.Exists(SAVED_PATHS_DIRECTORY))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(SAVED_PATHS_DIRECTORY);
|
||||||
|
Game.LogTrivial($"New directory created at '/plugins/SceneManager/Saved Paths'");
|
||||||
|
}
|
||||||
|
PathXMLManager.SaveItemToXML(this, SAVED_PATHS_DIRECTORY + filename);
|
||||||
|
}
|
||||||
|
|
||||||
private void LowerWaypointBlipsOpacity()
|
private void LowerWaypointBlipsOpacity()
|
||||||
{
|
{
|
||||||
foreach (Waypoint wp in Waypoints)
|
foreach (Waypoint wp in Waypoints)
|
||||||
|
|
@ -199,22 +220,14 @@ namespace SceneManager
|
||||||
}
|
}
|
||||||
if (v.HasDriver && v.Driver)
|
if (v.HasDriver && v.Driver)
|
||||||
{
|
{
|
||||||
//Game.LogTrivial($"Driver task status: {v.Driver.Tasks.CurrentTaskStatus}");
|
|
||||||
if(!v.Driver.IsAlive)
|
if(!v.Driver.IsAlive)
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"Vehicle's driver is dead.");
|
Game.LogTrivial($"Vehicle's driver is dead.");
|
||||||
_blacklistedVehicles.Add(v);
|
_blacklistedVehicles.Add(v);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(v.Driver.IsPersistent) // Persistent drivers are likely spawned from another script and doing something important.
|
if (v.IsPoliceVehicle && !v.Driver.IsAmbient())
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"Vehicle's driver is already persistent and probably being handled by another plugin.");
|
|
||||||
_blacklistedVehicles.Add(v);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (v.Driver.Tasks.CurrentTaskStatus == TaskStatus.InProgress && !Rage.Native.NativeFunction.Natives.GET_IS_TASK_ACTIVE(v.Driver, 151)) // Drivers with a non-wander task are probably doing something important
|
|
||||||
{
|
|
||||||
Game.LogTrivial($"Vehicle's driver is already tasked and probably being handled by another plugin.");
|
|
||||||
_blacklistedVehicles.Add(v);
|
_blacklistedVehicles.Add(v);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +1,28 @@
|
||||||
using Rage;
|
using Rage;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using SceneManager.Utils;
|
||||||
|
|
||||||
namespace SceneManager
|
namespace SceneManager.Objects
|
||||||
{
|
{
|
||||||
public class Waypoint
|
internal class Waypoint // Change this to Public for import/export
|
||||||
{
|
{
|
||||||
internal Path Path { get; set; }
|
internal Path Path { get; set; }
|
||||||
internal int Number { get; set; }
|
public int Number { get; set; }
|
||||||
internal Vector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
internal float Speed { get; set; }
|
public float Speed { get; set; }
|
||||||
internal DrivingFlagType DrivingFlagType { get; private set; }
|
public DrivingFlagType DrivingFlagType { get; set; }
|
||||||
internal bool IsStopWaypoint { get; set; }
|
public bool IsStopWaypoint { get; set; }
|
||||||
internal Blip Blip { get; }
|
internal Blip Blip { get; }
|
||||||
internal bool IsCollector { get; set; }
|
public bool IsCollector { get; set; }
|
||||||
internal float CollectorRadius { get; set; }
|
public float CollectorRadius { get; set; }
|
||||||
internal Blip CollectorRadiusBlip { get; set; }
|
internal Blip CollectorRadiusBlip { get; set; }
|
||||||
internal float SpeedZoneRadius { get; set; }
|
public float SpeedZoneRadius { get; set; }
|
||||||
internal uint SpeedZone { get; set; }
|
internal uint SpeedZone { get; set; }
|
||||||
internal bool EnableWaypointMarker { get; set; } = true;
|
internal bool EnableWaypointMarker { get; set; } = true;
|
||||||
|
|
||||||
|
private Waypoint() { }
|
||||||
|
|
||||||
internal Waypoint(Path path, int waypointNum, Vector3 waypointPos, float speed, DrivingFlagType drivingFlag, bool stopWaypoint, Blip waypointBlip, bool collector = false, float collectorRadius = 1, float speedZoneRadius = 5)
|
internal Waypoint(Path path, int waypointNum, Vector3 waypointPos, float speed, DrivingFlagType drivingFlag, bool stopWaypoint, Blip waypointBlip, bool collector = false, float collectorRadius = 1, float speedZoneRadius = 5)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue