mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Removed unnecessary code and updated references.
This commit is contained in:
parent
02a603ad15
commit
7aedb19090
1 changed files with 60 additions and 90 deletions
|
|
@ -6,57 +6,43 @@ namespace SceneManager
|
||||||
{
|
{
|
||||||
public class Waypoint
|
public class Waypoint
|
||||||
{
|
{
|
||||||
private Path _path { get; set; }
|
public Path Path { get; set; }
|
||||||
private int _number { get; set; }
|
public int Number { get; set; }
|
||||||
private Vector3 _position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
private float _speed { get; set; }
|
public float Speed { get; set; }
|
||||||
private VehicleDrivingFlags _drivingFlag { get; set; }
|
public VehicleDrivingFlags DrivingFlag { get; set; }
|
||||||
private Blip _blip { get; set; }
|
public Blip Blip { get; }
|
||||||
private bool _isCollector { get; set; }
|
public bool IsCollector { get; set; }
|
||||||
private float _collectorRadius { get; set; }
|
public float CollectorRadius { get; set; }
|
||||||
private Blip _collectorRadiusBlip { get; set; }
|
public Blip CollectorRadiusBlip { get; set; }
|
||||||
private float _speedZoneRadius { get; set; }
|
public float SpeedZoneRadius { get; set; }
|
||||||
private uint _speedZone { get; set; }
|
public uint SpeedZone { get; set; }
|
||||||
private bool _enableWaypointMarker { get; set; } = true;
|
public bool EnableWaypointMarker { get; set; }
|
||||||
private bool _enableEditMarker { get; set; } = false;
|
public bool EnableEditMarker { get; set; }
|
||||||
|
|
||||||
public Path Path { get { return _path; } set { _path = value; } }
|
|
||||||
public int Number { get { return _number; } set { _number = value; } }
|
|
||||||
public Vector3 Position { get { return _position; } }
|
|
||||||
public float Speed { get { return _speed; } }
|
|
||||||
public VehicleDrivingFlags DrivingFlag { get { return _drivingFlag; } }
|
|
||||||
public Blip Blip { get { return _blip; } }
|
|
||||||
public bool IsCollector { get { return _isCollector; } }
|
|
||||||
public float CollectorRadius { get { return _collectorRadius; } }
|
|
||||||
public Blip CollectorRadiusBlip { get { return _collectorRadiusBlip; } }
|
|
||||||
public float SpeedZoneRadius { get { return _speedZoneRadius; } }
|
|
||||||
public uint SpeedZone { get { return _speedZone; } set { _speedZone = value; } }
|
|
||||||
public bool EnableWaypointMarker { get { return _enableWaypointMarker; } set { _enableWaypointMarker = value; } }
|
|
||||||
public bool EnableEditMarker { get { return _enableEditMarker; } set { _enableEditMarker = value; } }
|
|
||||||
|
|
||||||
public Waypoint(Path path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector = false, float collectorRadius = 1, float speedZoneRadius = 0)
|
public Waypoint(Path path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector = false, float collectorRadius = 1, float speedZoneRadius = 0)
|
||||||
{
|
{
|
||||||
_path = path;
|
Path = path;
|
||||||
_number = waypointNum;
|
Number = waypointNum;
|
||||||
_position = waypointPos;
|
Position = waypointPos;
|
||||||
_speed = speed;
|
Speed = speed;
|
||||||
_drivingFlag = drivingFlag;
|
DrivingFlag = drivingFlag;
|
||||||
_blip = waypointBlip;
|
Blip = waypointBlip;
|
||||||
_isCollector = collector;
|
IsCollector = collector;
|
||||||
_collectorRadius = collectorRadius;
|
CollectorRadius = collectorRadius;
|
||||||
_speedZoneRadius = speedZoneRadius;
|
SpeedZoneRadius = speedZoneRadius;
|
||||||
AddSpeedZone();
|
AddSpeedZone();
|
||||||
_collectorRadiusBlip = new Blip(waypointBlip.Position, collectorRadius)
|
CollectorRadiusBlip = new Blip(waypointBlip.Position, collectorRadius)
|
||||||
{
|
{
|
||||||
Color = waypointBlip.Color,
|
Color = waypointBlip.Color,
|
||||||
};
|
};
|
||||||
if (SettingsMenu.mapBlips.Checked)
|
if (SettingsMenu.mapBlips.Checked)
|
||||||
{
|
{
|
||||||
_collectorRadiusBlip.Alpha = 0.5f;
|
CollectorRadiusBlip.Alpha = 0.5f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_collectorRadiusBlip.Alpha = 0f;
|
CollectorRadiusBlip.Alpha = 0f;
|
||||||
}
|
}
|
||||||
DrawWaypointMarker();
|
DrawWaypointMarker();
|
||||||
}
|
}
|
||||||
|
|
@ -73,69 +59,69 @@ namespace SceneManager
|
||||||
|
|
||||||
void UpdateDrivingFlag(VehicleDrivingFlags newDrivingFlag)
|
void UpdateDrivingFlag(VehicleDrivingFlags newDrivingFlag)
|
||||||
{
|
{
|
||||||
if(_drivingFlag == VehicleDrivingFlags.StopAtDestination && newDrivingFlag != VehicleDrivingFlags.StopAtDestination)
|
if(DrivingFlag == VehicleDrivingFlags.StopAtDestination && newDrivingFlag != VehicleDrivingFlags.StopAtDestination)
|
||||||
{
|
{
|
||||||
foreach(CollectedVehicle cv in VehicleCollector.collectedVehicles.Where(cv => cv.Path == _path && cv.CurrentWaypoint == this && cv.StoppedAtWaypoint))
|
foreach(CollectedVehicle cv in VehicleCollector.collectedVehicles.Where(cv => cv.Path == Path && cv.CurrentWaypoint == this && cv.StoppedAtWaypoint))
|
||||||
{
|
{
|
||||||
Game.LogTrivial($"Setting StoppedAtWaypoint to false for {cv.Vehicle.Model.Name}");
|
Logger.Log($"Setting StoppedAtWaypoint to false for {cv.Vehicle.Model.Name}");
|
||||||
cv.StoppedAtWaypoint = false;
|
cv.StoppedAtWaypoint = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_drivingFlag = newDrivingFlag;
|
DrivingFlag = newDrivingFlag;
|
||||||
if (newDrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
if (newDrivingFlag == VehicleDrivingFlags.StopAtDestination)
|
||||||
{
|
{
|
||||||
_blip.Color = Color.Red;
|
Blip.Color = Color.Red;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_blip.Color = Color.Green;
|
Blip.Color = Color.Green;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWaypointSpeed(float newWaypointSpeed)
|
void UpdateWaypointSpeed(float newWaypointSpeed)
|
||||||
{
|
{
|
||||||
_speed = newWaypointSpeed;
|
Speed = newWaypointSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateCollectorOptions()
|
void UpdateCollectorOptions()
|
||||||
{
|
{
|
||||||
if (collectorWaypointChecked)
|
if (collectorWaypointChecked)
|
||||||
{
|
{
|
||||||
_isCollector = true;
|
IsCollector = true;
|
||||||
RemoveSpeedZone();
|
RemoveSpeedZone();
|
||||||
_speedZone = World.AddSpeedZone(Game.LocalPlayer.Character.Position, SpeedZoneRadius, speed);
|
SpeedZone = World.AddSpeedZone(Game.LocalPlayer.Character.Position, SpeedZoneRadius, speed);
|
||||||
_blip.Color = Color.Blue;
|
Blip.Color = Color.Blue;
|
||||||
if (_collectorRadiusBlip)
|
if (CollectorRadiusBlip)
|
||||||
{
|
{
|
||||||
_collectorRadiusBlip.Position = Game.LocalPlayer.Character.Position;
|
CollectorRadiusBlip.Position = Game.LocalPlayer.Character.Position;
|
||||||
_collectorRadiusBlip.Alpha = 0.5f;
|
CollectorRadiusBlip.Alpha = 0.5f;
|
||||||
_collectorRadiusBlip.Scale = collectorRadius * 0.5f;
|
CollectorRadiusBlip.Scale = collectorRadius * 0.5f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_collectorRadiusBlip = new Blip(Blip.Position)
|
CollectorRadiusBlip = new Blip(Blip.Position)
|
||||||
{
|
{
|
||||||
Color = Blip.Color,
|
Color = Blip.Color,
|
||||||
Alpha = 0.5f
|
Alpha = 0.5f
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
_collectorRadius = collectorRadius;
|
CollectorRadius = collectorRadius;
|
||||||
_speedZoneRadius = speedZoneRadius;
|
SpeedZoneRadius = speedZoneRadius;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_isCollector = false;
|
IsCollector = false;
|
||||||
RemoveSpeedZone();
|
RemoveSpeedZone();
|
||||||
if (_collectorRadiusBlip)
|
if (CollectorRadiusBlip)
|
||||||
{
|
{
|
||||||
_collectorRadiusBlip.Delete();
|
CollectorRadiusBlip.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateWaypointPosition(Vector3 newWaypointPosition)
|
void UpdateWaypointPosition(Vector3 newWaypointPosition)
|
||||||
{
|
{
|
||||||
_position = newWaypointPosition;
|
Position = newWaypointPosition;
|
||||||
RemoveSpeedZone();
|
RemoveSpeedZone();
|
||||||
AddSpeedZone();
|
AddSpeedZone();
|
||||||
UpdateWaypointBlipPosition();
|
UpdateWaypointBlipPosition();
|
||||||
|
|
@ -143,26 +129,26 @@ namespace SceneManager
|
||||||
|
|
||||||
void UpdateWaypointBlipPosition()
|
void UpdateWaypointBlipPosition()
|
||||||
{
|
{
|
||||||
_blip.Position = Game.LocalPlayer.Character.Position;
|
Blip.Position = Game.LocalPlayer.Character.Position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSpeedZone()
|
public void AddSpeedZone()
|
||||||
{
|
{
|
||||||
_speedZone = World.AddSpeedZone(_position, _speedZoneRadius, _speed);
|
SpeedZone = World.AddSpeedZone(Position, SpeedZoneRadius, Speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSpeedZone()
|
public void RemoveSpeedZone()
|
||||||
{
|
{
|
||||||
World.RemoveSpeedZone(_speedZone);
|
World.RemoveSpeedZone(SpeedZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawWaypointMarker()
|
public void DrawWaypointMarker()
|
||||||
{
|
{
|
||||||
// This is called once when the waypoint is created
|
// This is called once when the waypoint is created
|
||||||
GameFiber.StartNew(() =>
|
GameFiber.StartNew((System.Threading.ThreadStart)(() =>
|
||||||
{
|
{
|
||||||
while (SettingsMenu.threeDWaypoints.Checked && _enableWaypointMarker && _path.Waypoints.Contains(this))
|
while (SettingsMenu.threeDWaypoints.Checked && EnableWaypointMarker && Path.Waypoints.Contains(this))
|
||||||
{
|
{
|
||||||
if (EditWaypointMenu.editWaypointMenu.Visible && EditWaypointMenu.editWaypoint.Value == Number)
|
if (EditWaypointMenu.editWaypointMenu.Visible && EditWaypointMenu.editWaypoint.Value == Number)
|
||||||
{
|
{
|
||||||
|
|
@ -205,7 +191,7 @@ namespace SceneManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((_path.State == State.Finished && MenuManager.menuPool.IsAnyMenuOpen()) || (_path.State == State.Creating && PathCreationMenu.pathCreationMenu.Visible))
|
else if ((Path.State == State.Finished && MenuManager.menuPool.IsAnyMenuOpen()) || (Path.State == State.Creating && PathCreationMenu.pathCreationMenu.Visible))
|
||||||
{
|
{
|
||||||
if (IsCollector && CollectorRadius > 0)
|
if (IsCollector && CollectorRadius > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -227,44 +213,28 @@ namespace SceneManager
|
||||||
|
|
||||||
GameFiber.Yield();
|
GameFiber.Yield();
|
||||||
}
|
}
|
||||||
});
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnableBlip()
|
public void EnableBlip()
|
||||||
{
|
{
|
||||||
if(!PathMainMenu.GetPaths().Where(p => p == _path).First().IsEnabled)
|
if(!PathMainMenu.GetPaths().Where(p => p == Path).First().IsEnabled)
|
||||||
{
|
{
|
||||||
_blip.Alpha = 0.5f;
|
Blip.Alpha = 0.5f;
|
||||||
_collectorRadiusBlip.Alpha = 0.25f;
|
CollectorRadiusBlip.Alpha = 0.25f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_blip.Alpha = 1.0f;
|
Blip.Alpha = 1.0f;
|
||||||
_collectorRadiusBlip.Alpha = 0.5f;
|
CollectorRadiusBlip.Alpha = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisableBlip()
|
public void DisableBlip()
|
||||||
{
|
{
|
||||||
_blip.Alpha = 0;
|
Blip.Alpha = 0;
|
||||||
_collectorRadiusBlip.Alpha = 0;
|
CollectorRadiusBlip.Alpha = 0;
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveWaypoint()
|
|
||||||
{
|
|
||||||
_path = null;
|
|
||||||
_number = 0;
|
|
||||||
_position = new Vector3(0,0,0);
|
|
||||||
_speed = 0;
|
|
||||||
_drivingFlag = 0;
|
|
||||||
_blip.Delete();
|
|
||||||
_isCollector = false;
|
|
||||||
_collectorRadius = 0;
|
|
||||||
_speedZoneRadius = 0;
|
|
||||||
RemoveSpeedZone();
|
|
||||||
_collectorRadiusBlip.Delete();
|
|
||||||
_enableWaypointMarker = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue