Health System
This commit is contained in:
1 parent
329cc98ade
commit
cb05da5e89
87 files changed
+568550
-155362
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using Code.Game.Gameplay.Player;
|
||||
using Code.OfficeGame.BattleMode.Health;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
@@ -11,6 +12,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
public AnimatorSnapshot AnimatorSnapshot;
|
||||
public MovementControllerSnapshot ControllerSnapshot;
|
||||
public EntityHealthSnapshot HealthSnapshot;
|
||||
|
||||
public static EntitySnapshot GetSnapshot(EntityProperties entityProperties)
|
||||
{
|
||||
@@ -20,12 +22,15 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
Position = entityProperties.KinematicCharacterMotor.TransientPosition,
|
||||
Rotation = entityProperties.KinematicCharacterMotor.TransientRotation,
|
||||
AnimatorSnapshot = AnimatorSnapshot.GetSnapshot(entityProperties.animator),
|
||||
ControllerSnapshot = MovementControllerSnapshot.GetSnapshot(entityProperties.MovementController)
|
||||
ControllerSnapshot = MovementControllerSnapshot.GetSnapshot(entityProperties.MovementController),
|
||||
HealthSnapshot = EntityHealthSnapshot.GetSnapshot(entityProperties.EntityHealth)
|
||||
};
|
||||
}
|
||||
|
||||
public static void RestoreSnapshot(EntityProperties entityProperties, EntitySnapshot snapshot)
|
||||
{
|
||||
snapshot.HealthSnapshot.RestoreSnapshot(entityProperties.EntityHealth);
|
||||
|
||||
// 1. Возвращаем капсулу KCC
|
||||
entityProperties.KinematicCharacterMotor.SetPositionAndRotation(snapshot.Position, snapshot.Rotation);
|
||||
entityProperties.KinematicCharacterMotor.BaseVelocity = snapshot.BaseVelocity;
|
||||
@@ -93,6 +98,8 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
NormalizedTime = stateInfo.normalizedTime,
|
||||
LayerWeight = animator.GetLayerWeight(i)
|
||||
};
|
||||
|
||||
Debug.Log($"Saved animator state {stateInfo.shortNameHash}");
|
||||
}
|
||||
|
||||
int paramCount = animator.parameterCount;
|
||||
@@ -199,4 +206,22 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
movementController.LookInputVector = LookInput;
|
||||
}
|
||||
}
|
||||
|
||||
public struct EntityHealthSnapshot
|
||||
{
|
||||
public HealthData HealthData;
|
||||
|
||||
public static EntityHealthSnapshot GetSnapshot(EntityHealth entityHealth)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
HealthData = entityHealth.HealthData.CurrentValue
|
||||
};
|
||||
}
|
||||
|
||||
public void RestoreSnapshot(EntityHealth entityHealth)
|
||||
{
|
||||
entityHealth.SetHealthData(HealthData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user