37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using Code.OfficeGame.BattleMode.Actions;
|
|
using KinematicCharacterController;
|
|
using UnityEngine;
|
|
|
|
namespace Code.Game.Entities
|
|
{
|
|
public static class EntityExtensions
|
|
{
|
|
// WC
|
|
public static void SyncRootMotionToMotor(this EntityProperties entity, bool syncRotation = true)
|
|
{
|
|
Transform animTransform = entity.animator.transform;
|
|
KinematicCharacterMotor motor = entity.KinematicCharacterMotor;
|
|
|
|
Vector3 targetWorldPos = animTransform.position;
|
|
Quaternion targetWorldRot = syncRotation
|
|
? animTransform.rotation
|
|
: motor.TransientRotation;
|
|
|
|
animTransform.localPosition = Vector3.zero;
|
|
animTransform.localRotation = Quaternion.identity;
|
|
|
|
motor.SetPositionAndRotation(targetWorldPos, targetWorldRot);
|
|
motor.BaseVelocity = Vector3.zero;
|
|
}
|
|
|
|
public static EntitySnapshot GetSnapshot(this EntityProperties entityProperties)
|
|
{
|
|
return EntitySnapshot.GetSnapshot(entityProperties);
|
|
}
|
|
|
|
public static void RestoreSnapshot(this EntityProperties entityProperties, EntitySnapshot snapshot)
|
|
{
|
|
EntitySnapshot.RestoreSnapshot(entityProperties, snapshot);
|
|
}
|
|
}
|
|
} |