1
Fork 0
mirror of https://github.com/thegeneralist01/Scene-Manager-DevRepo synced 2026-01-11 15:40:29 +01:00

Updated path reference based on CollectedVehicle refactoring.

This commit is contained in:
Rich Dunne 2020-09-07 20:26:35 -06:00
parent 394538eb26
commit 27d4b5c39a
4 changed files with 23 additions and 21 deletions

View file

@ -180,11 +180,11 @@ namespace SceneManager
if (collectorWaypoint.Checked)
{
currentPath.Waypoints.Add(new Waypoint(currentPath.Number, currentWaypoint.Number + 1, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, changeCollectorRadius.Value, changeSpeedZoneRadius.Value));
currentPath.Waypoints.Add(new Waypoint(currentPath, currentWaypoint.Number + 1, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip, true, changeCollectorRadius.Value, changeSpeedZoneRadius.Value));
}
else
{
currentPath.Waypoints.Add(new Waypoint(currentPath.Number, currentPath.Waypoints.Last().Number + 1, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip));
currentPath.Waypoints.Add(new Waypoint(currentPath, currentPath.Waypoints.Last().Number + 1, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlag, blip));
}
editWaypointMenu.RemoveItemAt(0);

View file

@ -95,11 +95,11 @@ namespace SceneManager
if (collectorWaypoint.Checked)
{
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(pathNumber, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index]), true, collectorRadius.Value, speedZoneRadius.Value));
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index]), true, collectorRadius.Value, speedZoneRadius.Value));
}
else
{
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(pathNumber, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index])));
PathMainMenu.GetPaths()[pathIndex].Waypoints.Add(new Waypoint(firstNonNullPath, waypointNumber, Game.LocalPlayer.Character.Position, SetDriveSpeedForWaypoint(), drivingFlags[waypointType.Index], CreateWaypointBlip(pathIndex, drivingFlags[waypointType.Index])));
}
Game.LogTrivial($"[Path {pathNumber}] Waypoint {waypointNumber} ({drivingFlags[waypointType.Index].ToString()}) added");

View file

@ -6,7 +6,8 @@ namespace SceneManager
{
public class Waypoint
{
private int _path { get; set; }
private Path _path { get; set; }
//private int _path { get; set; }
private int _number { get; set; }
private Vector3 _position { get; set; }
private float _speed { get; set; }
@ -19,7 +20,8 @@ namespace SceneManager
private uint _speedZone { get; set; }
private bool _enableWaypointMarker { get; set; }
public int Path { get {return _path; } }
public Path Path { get { return _path; } set { _path = value; } }
//public int Path { get {return _path; } }
public int Number { get { return _number; } set { _number = value; } }
public Vector3 Position { get { return _position; } }
public float Speed { get { return _speed; } }
@ -32,7 +34,7 @@ namespace SceneManager
public uint SpeedZone { get { return _speedZone; } set { _speedZone = value; } }
public bool EnableWaypointMarker { get { return _enableWaypointMarker; } set { _enableWaypointMarker = value; } }
public Waypoint(int path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector = false, float collectorRadius = 0, float speedZoneRadius = 0)
public Waypoint(Path path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector = false, float collectorRadius = 0, float speedZoneRadius = 0)
{
_path = path;
_number = waypointNum;
@ -76,7 +78,7 @@ namespace SceneManager
foreach(CollectedVehicle cv in VehicleCollector.collectedVehicles.Where(cv => cv.Path == _path && cv.CurrentWaypoint == _number && cv.StoppedAtWaypoint))
{
Game.LogTrivial($"Setting StoppedAtWaypoint to false for {cv.Vehicle.Model.Name}");
cv.SetStoppedAtWaypoint(false);
cv.StoppedAtWaypoint = false;
}
}
_drivingFlag = newDrivingFlag;
@ -240,7 +242,7 @@ namespace SceneManager
public void EnableBlip()
{
if(!PathMainMenu.GetPaths().Where(p => p.Number == _path).First().IsEnabled)
if(!PathMainMenu.GetPaths().Where(p => p == _path).First().IsEnabled)
{
_blip.Alpha = 0.5f;
_collectorRadiusBlip.Alpha = 0.25f;
@ -261,7 +263,7 @@ namespace SceneManager
public void RemoveWaypoint()
{
_path = 0;
_path = null;
_number = 0;
_position = new Vector3(0,0,0);
_speed = 0;

View file

@ -41,7 +41,7 @@ namespace SceneManager
{
SetVehicleAndDriverPersistence(vehicle);
CollectedVehicle newCollectedVehicle = AddVehicleToCollection(path, waypoint, vehicle);
Game.LogTrivial($"[WaypointVehicleCollector] Added {vehicle.Model.Name} to collection.");
newCollectedVehicle.TasksAssigned = true;
GameFiber AssignTasksFiber = new GameFiber(() => AITasking.AssignWaypointTasks(newCollectedVehicle, path.Waypoints, waypoint));
AssignTasksFiber.Start();
@ -50,7 +50,7 @@ namespace SceneManager
else if (!collectedVehicle.TasksAssigned)
{
Game.LogTrivial($"[WaypointVehicleCollector] {vehicle.Model.Name} already in collection, but with no tasks. Assigning tasks.");
collectedVehicle.SetTasksAssigned(true);
collectedVehicle.TasksAssigned = true;
GameFiber AssignTasksFiber = new GameFiber(() => AITasking.AssignWaypointTasks(collectedVehicle, path.Waypoints, waypoint));
AssignTasksFiber.Start();
@ -65,20 +65,12 @@ namespace SceneManager
private static CollectedVehicle AddVehicleToCollection(Path path, Waypoint waypoint, Vehicle v)
{
var collectedVehicle = new CollectedVehicle(v, v.LicensePlate, path.Number, path.Waypoints.Count, waypoint.Number, true, false);
var collectedVehicle = new CollectedVehicle(v, path, path.Waypoints.Count, waypoint.Number, false);
collectedVehicles.Add(collectedVehicle);
Game.LogTrivial($"[WaypointVehicleCollector] Added {v.Model.Name} to collection from path {path.Number}, waypoint {waypoint.Number}.");
return collectedVehicle;
}
public static void SetVehicleAndDriverPersistence(Vehicle v)
{
v.IsPersistent = true;
v.Driver.IsPersistent = true;
v.Driver.BlockPermanentEvents = true;
v.Driver.Tasks.Clear();
}
private static bool IsValidForCollection(this Vehicle v)
{
if(v && v.Speed > 1 && v.IsOnAllWheels && v != Game.LocalPlayer.Character.CurrentVehicle && v != Game.LocalPlayer.Character.LastVehicle && (v.IsCar || v.IsBike || v.IsBicycle || v.IsQuadBike || (v.HasSiren && !v.IsSirenOn)) && !collectedVehicles.Any(cv => cv.Vehicle == v))
@ -104,5 +96,13 @@ namespace SceneManager
return false;
}
}
public static void SetVehicleAndDriverPersistence(Vehicle v)
{
v.IsPersistent = true;
v.Driver.IsPersistent = true;
v.Driver.BlockPermanentEvents = true;
v.Driver.Tasks.Clear();
}
}
}