mirror of
https://github.com/thegeneralist01/Scene-Manager-DevRepo
synced 2026-01-11 23:50:29 +01:00
Refactored with more encapsulation, better protection for class fields
This commit is contained in:
parent
7c6a3fdfcf
commit
0dc3b19bc2
1 changed files with 101 additions and 31 deletions
|
|
@ -1,52 +1,122 @@
|
||||||
using Rage;
|
using Rage;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace SceneManager
|
namespace SceneManager
|
||||||
{
|
{
|
||||||
public class Waypoint
|
public class Waypoint
|
||||||
{
|
{
|
||||||
public int Path;
|
public int Path { get; private set; }
|
||||||
public int WaypointNum;
|
public int Number { get; private set; }
|
||||||
public Vector3 WaypointPos;
|
public Vector3 Position { get; private set; }
|
||||||
public float Speed;
|
public float Speed { get; private set; }
|
||||||
public VehicleDrivingFlags DrivingFlag;
|
public VehicleDrivingFlags DrivingFlag { get; private set; }
|
||||||
public Blip WaypointBlip;
|
public Blip Blip { get; private set; }
|
||||||
public uint YieldZone;
|
public uint YieldZone { get; private set; }
|
||||||
public bool Collector;
|
public bool Collector { get; private set; }
|
||||||
public float CollectorRadius;
|
public float CollectorRadius { get; private set; }
|
||||||
public Blip CollectorRadiusBlip;
|
public Blip CollectorRadiusBlip { get; private set; }
|
||||||
|
|
||||||
// Can this constructor be deleted?
|
public Waypoint(int path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip)
|
||||||
//public Waypoint(int path, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, uint yieldZone)
|
{
|
||||||
//{
|
Path = path;
|
||||||
// Path = path;
|
Number = waypointNum;
|
||||||
// WaypointPos = waypointPos;
|
Position = waypointPos;
|
||||||
// Speed = speed;
|
Speed = speed;
|
||||||
// DrivingFlag = drivingFlag;
|
DrivingFlag = drivingFlag;
|
||||||
// WaypointBlip = waypointBlip;
|
Blip = waypointBlip;
|
||||||
// YieldZone = yieldZone;
|
|
||||||
//}
|
}
|
||||||
|
|
||||||
public Waypoint(int path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector, float collectorRadius, uint yieldZone)
|
public Waypoint(int path, int waypointNum, Vector3 waypointPos, float speed, VehicleDrivingFlags drivingFlag, Blip waypointBlip, bool collector, float collectorRadius, uint yieldZone)
|
||||||
{
|
{
|
||||||
Path = path;
|
Path = path;
|
||||||
WaypointNum = waypointNum;
|
Number = waypointNum;
|
||||||
WaypointPos = waypointPos;
|
Position = waypointPos;
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
DrivingFlag = drivingFlag;
|
DrivingFlag = drivingFlag;
|
||||||
WaypointBlip = waypointBlip;
|
Blip = waypointBlip;
|
||||||
Collector = collector;
|
Collector = collector;
|
||||||
CollectorRadius = collectorRadius;
|
CollectorRadius = collectorRadius;
|
||||||
if (collector)
|
|
||||||
{
|
|
||||||
YieldZone = yieldZone;
|
YieldZone = yieldZone;
|
||||||
CollectorRadiusBlip = new Blip(waypointBlip.Position, collectorRadius)
|
CollectorRadiusBlip = new Blip(waypointBlip.Position, collectorRadius)
|
||||||
{
|
{
|
||||||
Color = waypointBlip.Color,
|
Color = waypointBlip.Color,
|
||||||
Alpha = 0.5f
|
Alpha = 0.5f
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateWaypoint(Waypoint currentWaypoint, VehicleDrivingFlags drivingFlag, float drivingSpeed, bool collectorWaypointChecked, float collectorRadius, bool updateWaypointPositionChecked)
|
||||||
|
{
|
||||||
|
UpdateDrivingFlag(drivingFlag);
|
||||||
|
UpdateWaypointSpeed(drivingSpeed);
|
||||||
|
UpdateCollectorOptions(currentWaypoint, drivingSpeed, collectorWaypointChecked, collectorRadius);
|
||||||
|
if (updateWaypointPositionChecked)
|
||||||
|
{
|
||||||
|
UpdateWaypointPosition(Game.LocalPlayer.Character.Position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateCollectorOptions(Waypoint currentWaypoint, float drivingSpeed, bool collectorWaypointChecked, float collectorRadius)
|
||||||
|
{
|
||||||
|
if (collectorWaypointChecked)
|
||||||
|
{
|
||||||
|
Collector = true;
|
||||||
|
YieldZone = World.AddSpeedZone(Game.LocalPlayer.Character.Position, 50f, drivingSpeed);
|
||||||
|
if (CollectorRadiusBlip)
|
||||||
|
{
|
||||||
|
currentWaypoint.CollectorRadiusBlip.Alpha = 0.5f;
|
||||||
|
currentWaypoint.CollectorRadiusBlip.Scale = collectorRadius;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CollectorRadiusBlip = new Blip(Blip.Position, collectorRadius)
|
||||||
|
{
|
||||||
|
Color = Blip.Color,
|
||||||
|
Alpha = 0.5f
|
||||||
|
};
|
||||||
|
}
|
||||||
|
CollectorRadius = collectorRadius;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Collector = false;
|
||||||
|
World.RemoveSpeedZone(YieldZone);
|
||||||
|
if (CollectorRadiusBlip)
|
||||||
|
{
|
||||||
|
CollectorRadiusBlip.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateWaypointPosition(Vector3 newWaypointPosition)
|
||||||
|
{
|
||||||
|
Position = newWaypointPosition;
|
||||||
|
UpdateWaypointBlipPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateWaypointSpeed(float newWaypointSpeed)
|
||||||
|
{
|
||||||
|
Speed = newWaypointSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDrivingFlag(VehicleDrivingFlags newDrivingFlag)
|
||||||
|
{
|
||||||
|
DrivingFlag = newDrivingFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateWaypointBlipPosition()
|
||||||
|
{
|
||||||
|
Blip.Position = Game.LocalPlayer.Character.Position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdatePathNumber(int newPathNumber)
|
||||||
|
{
|
||||||
|
Path = newPathNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateWaypointNumber(int newWaypointNumber)
|
||||||
|
{
|
||||||
|
Number = newWaypointNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue