mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 15:40:29 +01:00
Refactored AssignPropertiesFromDirectedTask method, added Dismiss method. Added a second constructor
This commit is contained in:
parent
08115a871b
commit
07dcc46abb
1 changed files with 70 additions and 14 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using Rage;
|
using Rage;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace SceneManager
|
namespace SceneManager
|
||||||
{
|
{
|
||||||
|
|
@ -7,33 +8,88 @@ namespace SceneManager
|
||||||
private Ped _driver { get; set; }
|
private Ped _driver { get; set; }
|
||||||
private Vehicle _vehicle { get; set; }
|
private Vehicle _vehicle { get; set; }
|
||||||
private Path _path { get; set; }
|
private Path _path { get; set; }
|
||||||
//private int _path { get; set; } // Should change this to a Path object
|
private Waypoint _currentWaypoint {get; set;}
|
||||||
private int _currentWaypoint { get; set; }
|
|
||||||
private bool _tasksAssigned { get; set; }
|
private bool _tasksAssigned { get; set; }
|
||||||
private bool _stoppedAtWaypoint { get; set; }
|
private bool _stoppedAtWaypoint { get; set; }
|
||||||
|
private bool _dismissed { get; set; } = false;
|
||||||
|
private bool _skipWaypoint { get; set; } = false;
|
||||||
|
|
||||||
public Ped Driver { get { return _driver; } set { _driver = value; } }
|
public Ped Driver { get { return _driver; } set { _driver = value; } }
|
||||||
public Vehicle Vehicle { get { return _vehicle; } set { _vehicle = value; } }
|
public Vehicle Vehicle { get { return _vehicle; } set { _vehicle = value; } }
|
||||||
public Path Path { get { return _path; } set { _path = value; } }
|
public Path Path { get { return _path; } set { _path = value; } }
|
||||||
public int CurrentWaypoint { get { return _currentWaypoint; } set { _currentWaypoint = value; } }
|
public Waypoint CurrentWaypoint { get { return _currentWaypoint; } set { _currentWaypoint = value; } }
|
||||||
public bool TasksAssigned { get { return _tasksAssigned; } set { _tasksAssigned = value; } }
|
public bool TasksAssigned { get { return _tasksAssigned; } set { _tasksAssigned = value; } }
|
||||||
public bool StoppedAtWaypoint { get { return _stoppedAtWaypoint; } set { _stoppedAtWaypoint = 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, int totalWaypoints, int currentWaypoint, bool tasksAssigned)
|
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;
|
_tasksAssigned = tasksAssigned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssignPropertiesFromDirectedTask(Path path, int totalPathWaypoints, int currentWaypoint, bool tasksAssigned, bool stoppedAtWaypoint)
|
public CollectedVehicle(Vehicle vehicle, Path path, bool tasksAssigned)
|
||||||
{
|
{
|
||||||
Path = path;
|
_vehicle = vehicle;
|
||||||
CurrentWaypoint = currentWaypoint;
|
_driver = vehicle.Driver;
|
||||||
TasksAssigned = tasksAssigned;
|
_path = path;
|
||||||
StoppedAtWaypoint = stoppedAtWaypoint;
|
_tasksAssigned = tasksAssigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AssignPropertiesFromDirectedTask(Path path, Waypoint currentWaypoint, bool tasksAssigned, bool stoppedAtWaypoint)
|
||||||
|
{
|
||||||
|
_path = path;
|
||||||
|
_currentWaypoint = currentWaypoint;
|
||||||
|
_tasksAssigned = tasksAssigned;
|
||||||
|
_stoppedAtWaypoint = stoppedAtWaypoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dismiss()
|
||||||
|
{
|
||||||
|
GameFiber.StartNew(() =>
|
||||||
|
{
|
||||||
|
if (!_vehicle || !_driver)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_dismissed = true;
|
||||||
|
_stoppedAtWaypoint = false;
|
||||||
|
|
||||||
|
_driver.Tasks.Clear();
|
||||||
|
|
||||||
|
if (_driver.GetAttachedBlip())
|
||||||
|
{
|
||||||
|
_driver.GetAttachedBlip().Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
if (nearestCollectorWaypoint != null)
|
||||||
|
{
|
||||||
|
while (nearestCollectorWaypoint != null && _vehicle && _driver && _vehicle.DistanceTo2D(nearestCollectorWaypoint.Position) <= nearestCollectorWaypoint.CollectorRadius * 2.5)
|
||||||
|
{
|
||||||
|
//Game.LogTrivial($"{_vehicle.Model.Name} is too close to the collector to be fully dismissed.");
|
||||||
|
GameFiber.Yield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_vehicle || !_driver)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VehicleCollector.collectedVehicles.Remove(this);
|
||||||
|
Game.LogTrivial($"{_vehicle.Model.Name} dismissed successfully.");
|
||||||
|
_driver.BlockPermanentEvents = false;
|
||||||
|
_driver.Dismiss();
|
||||||
|
_vehicle.IsSirenOn = false;
|
||||||
|
_vehicle.IsSirenSilent = true;
|
||||||
|
_vehicle.Dismiss();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue