mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Removed unncessary code, updated references.
This commit is contained in:
parent
530686a8b2
commit
480ef8975f
2 changed files with 34 additions and 53 deletions
|
|
@ -224,7 +224,7 @@ namespace SceneManager
|
||||||
if (collectedVehicle == null && (directOptions.SelectedItem == "First waypoint" || directOptions.SelectedItem == "Nearest waypoint" && nearestWaypoint != null))
|
if (collectedVehicle == null && (directOptions.SelectedItem == "First waypoint" || directOptions.SelectedItem == "Nearest waypoint" && nearestWaypoint != null))
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not found in collection, adding now.");
|
Game.LogTrivial($"[Direct Driver] {nearbyVehicle.Model.Name} not found in collection, adding now.");
|
||||||
VehicleCollector.collectedVehicles.Add(new CollectedVehicle(nearbyVehicle, path, false));
|
VehicleCollector.collectedVehicles.Add(new CollectedVehicle(nearbyVehicle, path));
|
||||||
collectedVehicle = VehicleCollector.collectedVehicles.Where(cv => cv.Vehicle == nearbyVehicle).FirstOrDefault();
|
collectedVehicle = VehicleCollector.collectedVehicles.Where(cv => cv.Vehicle == nearbyVehicle).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,91 +5,72 @@ namespace SceneManager
|
||||||
{
|
{
|
||||||
public class CollectedVehicle
|
public class CollectedVehicle
|
||||||
{
|
{
|
||||||
private Ped _driver { get; set; }
|
public Ped Driver { get; set; }
|
||||||
private Vehicle _vehicle { get; set; }
|
public Vehicle Vehicle { get; set; }
|
||||||
private Path _path { get; set; }
|
public Path Path { get; set; }
|
||||||
private Waypoint _currentWaypoint {get; set;}
|
public Waypoint CurrentWaypoint { get; set; }
|
||||||
private bool _tasksAssigned { get; set; }
|
public Waypoint NextWaypoint { get; private set; }
|
||||||
private bool _stoppedAtWaypoint { get; set; }
|
public bool StoppedAtWaypoint { get; set; }
|
||||||
private bool _dismissed { get; set; } = false;
|
public bool Dismissed { get; set; }
|
||||||
private bool _skipWaypoint { get; set; } = false;
|
public bool SkipWaypoint { get; set; }
|
||||||
|
|
||||||
public Ped Driver { get { return _driver; } set { _driver = value; } }
|
public CollectedVehicle(Vehicle vehicle, Path path, Waypoint currentWaypoint)
|
||||||
public Vehicle Vehicle { get { return _vehicle; } set { _vehicle = value; } }
|
|
||||||
public Path Path { get { return _path; } set { _path = value; } }
|
|
||||||
public Waypoint CurrentWaypoint { get { return _currentWaypoint; } set { _currentWaypoint = value; } }
|
|
||||||
public bool TasksAssigned { get { return _tasksAssigned; } set { _tasksAssigned = value; } }
|
|
||||||
public bool StoppedAtWaypoint { get { return _stoppedAtWaypoint; } set { _stoppedAtWaypoint = value; } }
|
|
||||||
public bool Dismissed { get { return _dismissed; } set { _dismissed = value; } }
|
|
||||||
public bool SkipWaypoint { get { return _skipWaypoint; } set { _skipWaypoint = value; } }
|
|
||||||
|
|
||||||
public CollectedVehicle(Vehicle vehicle, Path path, Waypoint currentWaypoint, bool tasksAssigned)
|
|
||||||
{
|
{
|
||||||
_vehicle = vehicle;
|
Vehicle = vehicle;
|
||||||
_driver = vehicle.Driver;
|
Driver = vehicle.Driver;
|
||||||
_path = path;
|
Path = path;
|
||||||
_currentWaypoint = currentWaypoint;
|
CurrentWaypoint = currentWaypoint;
|
||||||
_tasksAssigned = tasksAssigned;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CollectedVehicle(Vehicle vehicle, Path path, bool tasksAssigned)
|
public CollectedVehicle(Vehicle vehicle, Path path)
|
||||||
{
|
{
|
||||||
_vehicle = vehicle;
|
Vehicle = vehicle;
|
||||||
_driver = vehicle.Driver;
|
Driver = vehicle.Driver;
|
||||||
_path = path;
|
Path = path;
|
||||||
_tasksAssigned = tasksAssigned;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AssignPropertiesFromDirectedTask(Path path, Waypoint currentWaypoint, bool tasksAssigned, bool stoppedAtWaypoint)
|
|
||||||
{
|
|
||||||
_path = path;
|
|
||||||
_currentWaypoint = currentWaypoint;
|
|
||||||
_tasksAssigned = tasksAssigned;
|
|
||||||
_stoppedAtWaypoint = stoppedAtWaypoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dismiss()
|
public void Dismiss()
|
||||||
{
|
{
|
||||||
GameFiber.StartNew(() =>
|
GameFiber.StartNew(() =>
|
||||||
{
|
{
|
||||||
if (!_vehicle || !_driver)
|
if (!Vehicle || !Driver)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_dismissed = true;
|
Dismissed = true;
|
||||||
_stoppedAtWaypoint = false;
|
StoppedAtWaypoint = false;
|
||||||
|
|
||||||
_driver.Tasks.Clear();
|
Driver.Tasks.Clear();
|
||||||
_driver.Tasks.PerformDrivingManeuver(_vehicle, VehicleManeuver.GoForwardWithCustomSteeringAngle, 3);
|
Driver.Tasks.PerformDrivingManeuver(Vehicle, VehicleManeuver.GoForwardWithCustomSteeringAngle, 3);
|
||||||
|
|
||||||
if (_driver.GetAttachedBlip())
|
if (Driver.GetAttachedBlip())
|
||||||
{
|
{
|
||||||
_driver.GetAttachedBlip().Delete();
|
Driver.GetAttachedBlip().Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the vehicle is near any of the path's collector waypoints
|
// check if the vehicle is near any of the path's collector waypoints
|
||||||
var nearestCollectorWaypoint = _path.Waypoints.Where(wp => wp.IsCollector && _vehicle.DistanceTo2D(wp.Position) <= wp.CollectorRadius * 2).FirstOrDefault();
|
var nearestCollectorWaypoint = Path.Waypoints.Where(wp => wp.IsCollector && Vehicle.DistanceTo2D(wp.Position) <= wp.CollectorRadius * 2).FirstOrDefault();
|
||||||
if (nearestCollectorWaypoint != null)
|
if (nearestCollectorWaypoint != null)
|
||||||
{
|
{
|
||||||
while (nearestCollectorWaypoint != null && _vehicle && _driver && _vehicle.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2)
|
while (nearestCollectorWaypoint != null && Vehicle && Driver && Vehicle.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2)
|
||||||
{
|
{
|
||||||
//Game.LogTrivial($"{_vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
//Game.LogTrivial($"{_vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||||
GameFiber.Yield();
|
GameFiber.Yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_vehicle || !_driver)
|
if (!Vehicle || !Driver)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VehicleCollector.collectedVehicles.Remove(this);
|
VehicleCollector.collectedVehicles.Remove(this);
|
||||||
Game.LogTrivial($"{_vehicle.Model.Name} dismissed successfully.");
|
Game.LogTrivial($"{Vehicle.Model.Name} dismissed successfully.");
|
||||||
_driver.BlockPermanentEvents = false;
|
Driver.BlockPermanentEvents = false;
|
||||||
_driver.Dismiss();
|
Driver.Dismiss();
|
||||||
_vehicle.IsSirenOn = false;
|
Vehicle.IsSirenOn = false;
|
||||||
_vehicle.IsSirenSilent = true;
|
Vehicle.IsSirenSilent = true;
|
||||||
_vehicle.Dismiss();
|
Vehicle.Dismiss();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue