"Entities" cleaned up
This commit is contained in:
parent
d70c739208
commit
cb7f0290ec
@ -15,10 +15,7 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public bool IsLocal
|
||||
{
|
||||
get
|
||||
{
|
||||
return OwnerID==Main.LocalPlayerID;
|
||||
}
|
||||
get => OwnerID == Main.LocalPlayerID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -33,10 +30,7 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public int OwnerID
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ownerID;
|
||||
}
|
||||
get => _ownerID;
|
||||
internal set
|
||||
{
|
||||
if (value==_ownerID && Owner!=null) { return; }
|
||||
@ -51,19 +45,16 @@ namespace RageCoop.Client
|
||||
/// </summary>
|
||||
public bool IsOutOfSync
|
||||
{
|
||||
get
|
||||
{
|
||||
return Main.Ticked-LastSynced>200 && ID!=0;
|
||||
}
|
||||
get => Main.Ticked - LastSynced > 200 && ID != 0;
|
||||
}
|
||||
internal bool IsReady
|
||||
{
|
||||
get { return (LastSynced>0||LastFullSynced==0); }
|
||||
get => LastSynced > 0 || LastFullSynced == 0;
|
||||
}
|
||||
internal bool IsInvincible { get; set; } = false;
|
||||
internal bool NeedUpdate
|
||||
{
|
||||
get { return LastSynced>=LastUpdated; }
|
||||
get => LastSynced >= LastUpdated;
|
||||
}
|
||||
#region LAST STATE
|
||||
/// <summary>
|
||||
@ -100,6 +91,5 @@ namespace RageCoop.Client
|
||||
{
|
||||
LastUpdated=Main.Ticked+frames;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace RageCoop.Client
|
||||
/// <summary>
|
||||
/// Indicates whether this ped is a player
|
||||
/// </summary>
|
||||
public bool IsPlayer { get { return (OwnerID==ID)&&(ID!=0); } }
|
||||
public bool IsPlayer { get => OwnerID == ID && ID != 0; }
|
||||
/// <summary>
|
||||
/// real entity
|
||||
/// </summary>
|
||||
@ -80,7 +80,6 @@ namespace RageCoop.Client
|
||||
|
||||
private WeaponAsset WeaponAsset { get; set; }
|
||||
|
||||
|
||||
internal override void Update()
|
||||
{
|
||||
if (IsPlayer)
|
||||
@ -97,12 +96,7 @@ namespace RageCoop.Client
|
||||
if (!IsReady) { return; }
|
||||
|
||||
// Skip update if no new sync message has arrived.
|
||||
if (!NeedUpdate)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!NeedUpdate) { return; }
|
||||
|
||||
if (MainPed == null || !MainPed.Exists())
|
||||
{
|
||||
@ -112,11 +106,6 @@ namespace RageCoop.Client
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Need to update state
|
||||
if (LastFullSynced>=LastUpdated)
|
||||
{
|
||||
@ -126,7 +115,6 @@ namespace RageCoop.Client
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (((byte)BlipColor==255) && (PedBlip!=null))
|
||||
@ -165,8 +153,6 @@ namespace RageCoop.Client
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (MainPed.IsDead)
|
||||
{
|
||||
if (Health>0)
|
||||
@ -201,10 +187,9 @@ namespace RageCoop.Client
|
||||
{
|
||||
DisplayOnFoot();
|
||||
}
|
||||
LastUpdated=Main.Ticked;
|
||||
return;
|
||||
}
|
||||
|
||||
LastUpdated=Main.Ticked;
|
||||
}
|
||||
|
||||
private void RenderNameTag()
|
||||
{
|
||||
@ -225,7 +210,6 @@ namespace RageCoop.Client
|
||||
Color=Owner.HasDirectConnection? Color.FromArgb(179, 229, 252) : Color.White,
|
||||
}.Draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private bool CreateCharacter()
|
||||
@ -261,7 +245,6 @@ namespace RageCoop.Client
|
||||
|
||||
Model.MarkAsNoLongerNeeded();
|
||||
|
||||
|
||||
MainPed.BlockPermanentEvents = true;
|
||||
MainPed.CanWrithe=false;
|
||||
MainPed.CanBeDraggedOutOfVehicle = true;
|
||||
@ -278,7 +261,6 @@ namespace RageCoop.Client
|
||||
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
||||
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
||||
|
||||
|
||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater, false);
|
||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
||||
@ -288,10 +270,7 @@ namespace RageCoop.Client
|
||||
|
||||
SetClothes();
|
||||
|
||||
if (IsPlayer)
|
||||
{
|
||||
MainPed.IsInvincible=true;
|
||||
}
|
||||
if (IsPlayer) { MainPed.IsInvincible=true; }
|
||||
if (IsInvincible) { MainPed.IsInvincible=true; }
|
||||
|
||||
lock (EntityPool.PedsLock)
|
||||
@ -517,12 +496,9 @@ namespace RageCoop.Client
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lastRagdoll = false;
|
||||
}
|
||||
}
|
||||
|
||||
_lastRagdoll = false;
|
||||
}
|
||||
|
||||
if (IsReloading)
|
||||
{
|
||||
@ -546,8 +522,6 @@ namespace RageCoop.Client
|
||||
}
|
||||
else if (IsInCover)
|
||||
{
|
||||
|
||||
|
||||
if (!_lastInCover)
|
||||
{
|
||||
Function.Call(Hash.TASK_STAY_IN_COVER, MainPed.Handle);
|
||||
@ -563,7 +537,6 @@ namespace RageCoop.Client
|
||||
{
|
||||
SmoothTransition();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (_lastInCover)
|
||||
{
|
||||
@ -601,17 +574,13 @@ namespace RageCoop.Client
|
||||
{
|
||||
foreach (KeyValuePair<uint, bool> comp in WeaponComponents)
|
||||
{
|
||||
|
||||
if (comp.Value)
|
||||
{
|
||||
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, _lastWeaponObj, comp.Key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, _lastWeaponObj, MainPed.Handle);
|
||||
|
||||
}
|
||||
_lastWeaponComponents = WeaponComponents;
|
||||
}
|
||||
|
@ -52,8 +52,6 @@ namespace RageCoop.Client
|
||||
|
||||
|
||||
#region LAST STATE
|
||||
|
||||
|
||||
private byte[] _lastVehicleColors = new byte[] { 0, 0 };
|
||||
private Dictionary<int, int> _lastVehicleMods = new Dictionary<int, int>();
|
||||
#endregion
|
||||
@ -67,25 +65,22 @@ namespace RageCoop.Client
|
||||
internal float DeluxoWingRatio { get; set; } = -1;
|
||||
internal bool IsFlipped
|
||||
{
|
||||
get
|
||||
{
|
||||
return _isMotorcycle||((Quaternion*Vector3.RelativeTop).Z - (Quaternion*Vector3.RelativeBottom).Z)<0.5;
|
||||
}
|
||||
get => _isMotorcycle || ((Quaternion * Vector3.RelativeTop).Z - (Quaternion * Vector3.RelativeBottom).Z) < 0.5;
|
||||
}
|
||||
private bool _isMotorcycle;
|
||||
#endregion
|
||||
#region FLAGS
|
||||
internal bool EngineRunning { get { return Flags.HasVehFlag(VehicleDataFlags.IsEngineRunning); } }
|
||||
internal bool EngineRunning { get => Flags.HasVehFlag(VehicleDataFlags.IsEngineRunning); }
|
||||
private bool _lastTransformed = false;
|
||||
internal bool Transformed { get { return Flags.HasVehFlag(VehicleDataFlags.IsTransformed); } }
|
||||
internal bool Transformed { get => Flags.HasVehFlag(VehicleDataFlags.IsTransformed); }
|
||||
private bool _lastHornActive = false;
|
||||
internal bool HornActive { get { return Flags.HasVehFlag(VehicleDataFlags.IsHornActive); } }
|
||||
internal bool LightsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreLightsOn); } }
|
||||
internal bool BrakeLightsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreBrakeLightsOn); } }
|
||||
internal bool HighBeamsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreHighBeamsOn); } }
|
||||
internal bool SireneActive { get { return Flags.HasVehFlag(VehicleDataFlags.IsSirenActive); } }
|
||||
internal bool IsDead { get { return Flags.HasVehFlag(VehicleDataFlags.IsDead); } }
|
||||
internal bool IsDeluxoHovering { get { return Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering); } }
|
||||
internal bool HornActive { get => Flags.HasVehFlag(VehicleDataFlags.IsHornActive); }
|
||||
internal bool LightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreLightsOn); }
|
||||
internal bool BrakeLightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreBrakeLightsOn); }
|
||||
internal bool HighBeamsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreHighBeamsOn); }
|
||||
internal bool SireneActive { get => Flags.HasVehFlag(VehicleDataFlags.IsSirenActive); }
|
||||
internal bool IsDead { get => Flags.HasVehFlag(VehicleDataFlags.IsDead); }
|
||||
internal bool IsDeluxoHovering { get => Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering); }
|
||||
#endregion
|
||||
|
||||
#region -- VEHICLE STATE --
|
||||
@ -139,14 +134,7 @@ namespace RageCoop.Client
|
||||
MainVehicle.ThrottlePower=ThrottlePower;
|
||||
MainVehicle.BrakePower=BrakePower;
|
||||
var v = Main.P.CurrentVehicle;
|
||||
if (v!= null && MainVehicle.IsTouching(v))
|
||||
{
|
||||
DisplayVehicle(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayVehicle(false);
|
||||
}
|
||||
DisplayVehicle(v != null && MainVehicle.IsTouching(v));
|
||||
#region FLAGS
|
||||
if (IsDead)
|
||||
{
|
||||
@ -154,10 +142,8 @@ namespace RageCoop.Client
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainVehicle.Explode();
|
||||
}
|
||||
|
||||
MainVehicle.Explode();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -280,7 +266,6 @@ namespace RageCoop.Client
|
||||
// check passengers (and driver).
|
||||
if (_checkSeat)
|
||||
{
|
||||
|
||||
var currentPassengers = MainVehicle.GetPassengers();
|
||||
|
||||
lock (Passengers)
|
||||
@ -290,7 +275,6 @@ namespace RageCoop.Client
|
||||
VehicleSeat seat = (VehicleSeat)i;
|
||||
if (Passengers.ContainsKey(seat))
|
||||
{
|
||||
|
||||
SyncedPed c = Passengers[seat];
|
||||
if (c?.ID==Main.LocalPlayerID && (RadioStation!=Function.Call<int>(Hash.GET_PLAYER_RADIO_STATION_INDEX)))
|
||||
{
|
||||
@ -336,8 +320,6 @@ namespace RageCoop.Client
|
||||
_lastVehicleMods = Mods;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle)!=LicensePlate)
|
||||
{
|
||||
Function.Call(Hash.SET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle, LicensePlate);
|
||||
@ -366,34 +348,32 @@ namespace RageCoop.Client
|
||||
var dist = current.DistanceTo(Position);
|
||||
var cali = ((Velocity.Length()<0.1 && !touching)?dist*4:dist)*(_predictedPos - current);
|
||||
|
||||
if (dist<8)
|
||||
if (dist>=8)
|
||||
{
|
||||
MainVehicle.Position = _predictedPos;
|
||||
MainVehicle.Velocity = Velocity;
|
||||
MainVehicle.ApplyForce(cali);
|
||||
if (IsFlipped)
|
||||
{
|
||||
MainVehicle.Quaternion=Quaternion.Slerp(MainVehicle.ReadQuaternion(), Quaternion, 0.5f);
|
||||
MainVehicle.RotationVelocity=RotationVelocity;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 calirot = GetCalibrationRotation();
|
||||
if (calirot.Length()<50)
|
||||
{
|
||||
MainVehicle.RotationVelocity = RotationVelocity+calirot*0.2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainVehicle.Quaternion=Quaternion;
|
||||
MainVehicle.RotationVelocity=RotationVelocity;
|
||||
}
|
||||
}
|
||||
MainVehicle.Quaternion = Quaternion;
|
||||
return;
|
||||
}
|
||||
|
||||
MainVehicle.Velocity = Velocity;
|
||||
MainVehicle.ApplyForce(cali);
|
||||
if (IsFlipped)
|
||||
{
|
||||
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.ReadQuaternion(), Quaternion, 0.5f);
|
||||
MainVehicle.RotationVelocity = RotationVelocity;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 calirot = GetCalibrationRotation();
|
||||
if (calirot.Length() < 50)
|
||||
{
|
||||
MainVehicle.RotationVelocity = RotationVelocity + calirot * 0.2f;
|
||||
}
|
||||
else
|
||||
{
|
||||
MainVehicle.Position=_predictedPos;
|
||||
MainVehicle.Velocity=Velocity;
|
||||
MainVehicle.Quaternion=Quaternion;
|
||||
MainVehicle.Quaternion = Quaternion;
|
||||
MainVehicle.RotationVelocity = RotationVelocity;
|
||||
}
|
||||
}
|
||||
private Vector3 GetCalibrationRotation()
|
||||
@ -411,7 +391,6 @@ namespace RageCoop.Client
|
||||
if (r.Z>180) { r.Z=r.Z-360; }
|
||||
else if (r.Z<-180) { r.Z=360+r.Z; }
|
||||
return r;
|
||||
|
||||
}
|
||||
private bool CreateVehicle()
|
||||
{
|
||||
@ -489,5 +468,4 @@ namespace RageCoop.Client
|
||||
internal Vector3 LastVelocity { get; set; }
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user