add "dead body sync rate" setting

This commit is contained in:
in0finite 2021-01-05 21:32:20 +01:00
parent 8d400bfceb
commit 20100a34aa
3 changed files with 26 additions and 0 deletions

View file

@ -38,6 +38,8 @@ namespace SanAndreasUnity.Behaviours.Peds
{ {
this.PushableByDamage = this.GetComponentOrThrow<PushableByDamage>(); this.PushableByDamage = this.GetComponentOrThrow<PushableByDamage>();
this.PushableByDamage.forceMultiplier = PedManager.Instance.ragdollDamageForceWhenDetached; this.PushableByDamage.forceMultiplier = PedManager.Instance.ragdollDamageForceWhenDetached;
this.RefreshSyncRate();
} }
private void OnEnable() private void OnEnable()
@ -166,5 +168,10 @@ namespace SanAndreasUnity.Behaviours.Peds
} }
} }
public void RefreshSyncRate()
{
this.syncInterval = 1.0f / PedManager.Instance.ragdollSyncRate;
}
} }
} }

View file

@ -65,6 +65,7 @@ namespace SanAndreasUnity.Behaviours
public float ragdollDamageForce = 4f; public float ragdollDamageForce = 4f;
public float ragdollDamageForceWhenDetached = 4f; public float ragdollDamageForceWhenDetached = 4f;
public CollisionDetectionMode ragdollCollisionDetectionMode = CollisionDetectionMode.Discrete; public CollisionDetectionMode ragdollCollisionDetectionMode = CollisionDetectionMode.Discrete;
[Range(1, 60)] public float ragdollSyncRate = 20f;
void Awake () void Awake ()

View file

@ -1,4 +1,5 @@
using SanAndreasUnity.Behaviours; using SanAndreasUnity.Behaviours;
using SanAndreasUnity.Behaviours.Peds;
using SanAndreasUnity.Behaviours.Vehicles; using SanAndreasUnity.Behaviours.Vehicles;
using SanAndreasUnity.UI; using SanAndreasUnity.UI;
using SanAndreasUnity.Utilities; using SanAndreasUnity.Utilities;
@ -14,6 +15,15 @@ namespace SanAndreasUnity.Settings
setValue = (value) => { ApplyPedSyncRate(value); }, setValue = (value) => { ApplyPedSyncRate(value); },
persistType = OptionsWindow.InputPersistType.OnStart persistType = OptionsWindow.InputPersistType.OnStart
}; };
OptionsWindow.FloatInput m_deadBodySyncRate = new OptionsWindow.FloatInput
{
description = "Dead body sync rate",
minValue = 1,
maxValue = 60,
getValue = () => PedManager.Instance.ragdollSyncRate,
setValue = ApplyDeadBodySyncRate,
persistType = OptionsWindow.InputPersistType.OnStart,
};
OptionsWindow.FloatInput m_vehicleSyncRate = new OptionsWindow.FloatInput ("Vehicle sync rate", 1, 60) { OptionsWindow.FloatInput m_vehicleSyncRate = new OptionsWindow.FloatInput ("Vehicle sync rate", 1, 60) {
isAvailable = () => VehicleManager.Instance != null, isAvailable = () => VehicleManager.Instance != null,
@ -69,6 +79,7 @@ namespace SanAndreasUnity.Settings
{ {
OptionsWindow.RegisterInputs ("NET", OptionsWindow.RegisterInputs ("NET",
m_pedSyncRate, m_pedSyncRate,
m_deadBodySyncRate,
m_vehicleSyncRate, m_vehicleSyncRate,
m_syncVehicleTransformUsingSyncVars, m_syncVehicleTransformUsingSyncVars,
m_syncVehiclesLinearVelocity, m_syncVehiclesLinearVelocity,
@ -86,6 +97,13 @@ namespace SanAndreasUnity.Settings
ped.ApplySyncRate(syncRate); ped.ApplySyncRate(syncRate);
} }
static void ApplyDeadBodySyncRate(float syncRate)
{
PedManager.Instance.ragdollSyncRate = syncRate;
foreach (var deadBody in DeadBody.DeadBodies)
deadBody.RefreshSyncRate();
}
static void ApplyVehicleSyncRate(float syncRate) static void ApplyVehicleSyncRate(float syncRate)
{ {
VehicleManager.Instance.vehicleSyncRate = syncRate; VehicleManager.Instance.vehicleSyncRate = syncRate;