HoloCop still in progress

This commit is contained in:
ThomasCharester committed 2026-10-28 16:52:34 +03:00
1 parent 430b250075
commit d3b2e4c8d8
54 files changed
+173233 -112995

No files matched your search

@@ -113,7 +113,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
public void CompleteOrInterruptAction()
{
animator.Play(EntryStateHash, 0, 0f); // Создать None State и кинуть эту штуку туда
animator.Update(0f);
_entityHitBoxes.DisableAllHitboxes();
// TODO С нормальными анимациями не нужен будет рут моушен
animator.transform.localPosition = Vector3.zero;
animator.transform.localRotation = Quaternion.identity;
Finished = true;
}
@@ -128,7 +134,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
_currentFrame++;
return _currentFrame >= _attackData.TotalFrames;
if(_currentFrame >= _attackData.TotalFrames)
{
_currentFrame = 0;
return true;
}
return false;
}
}
}
@@ -11,39 +11,59 @@ namespace Code.OfficeGame.BattleMode.Actions.HoloCopy
{
public class HoloCop : MonoBehaviour
{
private static readonly int VelocityForward = Animator.StringToHash("VelocityForward");
private Func<HoloCop, float, bool> _action;
[SerializeField] private MovementController movementController;
[SerializeField] private KinematicCharacterMotor motor;
[SerializeField] private KinematicCharacterMotor originMotor;
[SerializeField] private Animator animator;
[SerializeField] private Animator originAnimator;
public MovementController Controller => movementController;
public Animator Animator => animator;
private Vector3 _initialPosition;
private Quaternion _initialRotation;
private Vector3 _initialMotorPosition;
private Quaternion _initialMotorRotation;
private int _initialAnimationState;
private void Awake()
{
animator = GetComponentInChildren<Animator>();
movementController = GetComponent<MovementController>();
motor = GetComponent<KinematicCharacterMotor>();
}
private float _initialNormalizedTime;
private void Snapshot()
{
_initialPosition = motor.transform.position;
_initialRotation = motor.transform.rotation;
_initialMotorPosition = originMotor.TransientPosition;
_initialMotorRotation = originMotor.TransientRotation;
_initialAnimationState = animator.GetCurrentAnimatorStateInfo(0).shortNameHash;
AnimatorStateInfo stateInfo = originAnimator.GetCurrentAnimatorStateInfo(0);
_initialAnimationState = stateInfo.shortNameHash;
_initialNormalizedTime = stateInfo.normalizedTime;
animator.applyRootMotion = false;
animator.SetFloat(VelocityForward, originAnimator.GetFloat(VelocityForward));
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
animator.Update(0f);
animator.applyRootMotion = true;
}
private void ReturnToSnapshot()
{
motor.SetPositionAndRotation(_initialPosition, _initialRotation);
bool prevRootMotion = animator.applyRootMotion;
animator.applyRootMotion = false;
animator.Play(_initialAnimationState, 0);
animator.Play(_initialAnimationState, 0, _initialNormalizedTime);
animator.Update(0f);
animator.transform.localPosition = Vector3.zero;
animator.transform.localRotation = Quaternion.identity;
originMotor.SetPositionAndRotation(_initialMotorPosition, _initialMotorRotation);
animator.applyRootMotion = prevRootMotion;
Physics.SyncTransforms();
}
public async UniTask Simulate(Func<HoloCop, float, bool> action, CancellationToken ctx)
@@ -70,7 +90,7 @@ namespace Code.OfficeGame.BattleMode.Actions.HoloCopy
if (_action == null) return;
bool result = _action(this, BattleTimeline.TickDelta);
animator.Update(BattleTimeline.TickDelta);
Physics.Simulate(BattleTimeline.TickDelta);
@@ -10,12 +10,15 @@ namespace Code.OfficeGame.Player
private KinematicCharacterMotor _motor;
[SerializeField] private Animator animator;
public Animator Animator { get; private set; }
private void Awake()
{
_motor = GetComponent<KinematicCharacterMotor>();
Animator = GetComponentInChildren<Animator>();
// :?:?:?:?:?:?:?:?:?:?:?:?:?:?
if (!animator) Animator = GetComponentInChildren<Animator>();
else Animator = animator;
}
private void Update()
+11
View File
@@ -1311,7 +1311,9 @@ MonoBehaviour:
m_EditorClassIdentifier: Assembly-CSharp::Code.OfficeGame.BattleMode.Actions.HoloCopy.HoloCop
movementController: {fileID: 4168235549514175667}
motor: {fileID: 315944951666586202}
originMotor: {fileID: 2650801570508942627}
animator: {fileID: 8851620147763273111}
originAnimator: {fileID: 2511146916935397012}
--- !u!136 &1067183535363547161
CapsuleCollider:
m_ObjectHideFlags: 8
@@ -2025,6 +2027,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 05290340b907438c8fcb9d5f0e75624f, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Code.OfficeGame.Player.PlayerAnimator
animator: {fileID: 2511146916935397012}
--- !u!114 &7637701434054888247
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -2213,6 +2216,10 @@ PrefabInstance:
propertyPath: m_Controller
value:
objectReference: {fileID: 9100000, guid: 0a88085cbabf38ae084dd83fcdd5e566, type: 2}
- target: {fileID: 5866666021909216657, guid: 22f5406d0dd3e496dab66400ad658fb8, type: 3}
propertyPath: m_ApplyRootMotion
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9148548460791437811, guid: 22f5406d0dd3e496dab66400ad658fb8, type: 3}
propertyPath: m_IsActive
value: 1
@@ -2328,6 +2335,10 @@ PrefabInstance:
propertyPath: m_Controller
value:
objectReference: {fileID: 9100000, guid: 0a88085cbabf38ae084dd83fcdd5e566, type: 2}
- target: {fileID: 5866666021909216657, guid: 22f5406d0dd3e496dab66400ad658fb8, type: 3}
propertyPath: m_ApplyRootMotion
value: 1
objectReference: {fileID: 0}
- target: {fileID: 9148548460791437811, guid: 22f5406d0dd3e496dab66400ad658fb8, type: 3}
propertyPath: m_IsActive
value: 1
@@ -63,7 +63,7 @@ AnimatorController:
m_AnimatorParameters:
- m_Name: VelocityForward
m_Type: 1
m_DefaultFloat: 0
m_DefaultFloat: 1
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 9100000}