breakpoint
before change animation type
This commit is contained in:
@@ -15,40 +15,64 @@ namespace BITKit.Entities
|
||||
[SerializeField] private Collider[] ragdollColliders;
|
||||
[SerializeField] private Joint[] joints;
|
||||
[SerializeField] private new Rigidbody rigidbody;
|
||||
[Inject]
|
||||
|
||||
[Inject(true)]
|
||||
private IHealth _health;
|
||||
|
||||
[Inject(true)] private IEntityOverride _override;
|
||||
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointXMotions=new();
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointYMotions=new();
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointZMotions=new();
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointAngularXMotions=new();
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointAngularYMotions=new();
|
||||
private readonly Dictionary<Joint,ConfigurableJointMotion> _jointAngularZMotions=new();
|
||||
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
_health.OnSetAlive += OnSetAlive;
|
||||
_health.OnSetHealthPoint += OnSetHP;
|
||||
foreach (var x in joints)
|
||||
{
|
||||
switch (x)
|
||||
{
|
||||
case ConfigurableJoint configurableJoint:
|
||||
_jointXMotions.Add(configurableJoint,configurableJoint.xMotion);
|
||||
_jointYMotions.Add(configurableJoint,configurableJoint.yMotion);
|
||||
_jointZMotions.Add(configurableJoint,configurableJoint.zMotion);
|
||||
_jointAngularXMotions.Add(configurableJoint,configurableJoint.angularXMotion);
|
||||
_jointAngularYMotions.Add(configurableJoint,configurableJoint.angularYMotion);
|
||||
_jointAngularZMotions.Add(configurableJoint,configurableJoint.angularZMotion);
|
||||
case ConfigurableJoint configurableJoint:
|
||||
_jointXMotions.Add(configurableJoint, configurableJoint.xMotion);
|
||||
_jointYMotions.Add(configurableJoint, configurableJoint.yMotion);
|
||||
_jointZMotions.Add(configurableJoint, configurableJoint.zMotion);
|
||||
_jointAngularXMotions.Add(configurableJoint, configurableJoint.angularXMotion);
|
||||
_jointAngularYMotions.Add(configurableJoint, configurableJoint.angularYMotion);
|
||||
_jointAngularZMotions.Add(configurableJoint, configurableJoint.angularZMotion);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (_override is not null)
|
||||
_override.OnOverride += OnOverride;
|
||||
}
|
||||
|
||||
private async void OnSetAlive(bool alive)
|
||||
private void OnOverride(bool obj)
|
||||
{
|
||||
IsPhysics = !alive;
|
||||
EnsureConf();
|
||||
}
|
||||
|
||||
private void OnSetAlive(bool alive)
|
||||
{
|
||||
EnsureConf();
|
||||
}
|
||||
|
||||
private async void EnsureConf()
|
||||
{
|
||||
var allow = (_health, _override) switch
|
||||
{
|
||||
(not null,not null)=>_health.IsAlive || _override.IsOvering,
|
||||
(not null,null)=>_health.IsAlive,
|
||||
(null,not null)=>_override.IsOvering,
|
||||
_=>false,
|
||||
};
|
||||
if (animator)
|
||||
animator.enabled = alive;
|
||||
{
|
||||
animator.enabled = allow;
|
||||
}
|
||||
try
|
||||
{
|
||||
await Task.Delay(10, destroyCancellationToken);
|
||||
@@ -56,13 +80,13 @@ namespace BITKit.Entities
|
||||
foreach (var x in rigidbodies)
|
||||
{
|
||||
//x.isKinematic = alive;
|
||||
x.gameObject.SetActive(!alive);
|
||||
x.gameObject.SetActive(!allow);
|
||||
}
|
||||
foreach (var x in ragdollColliders)
|
||||
{
|
||||
x.enabled = !alive;
|
||||
x.enabled = !allow;
|
||||
}
|
||||
OnSetPhysics?.Invoke(!alive);
|
||||
OnSetPhysics?.Invoke(!allow);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@@ -74,25 +98,20 @@ namespace BITKit.Entities
|
||||
switch (joint)
|
||||
{
|
||||
case ConfigurableJoint configurableJoint:
|
||||
configurableJoint.xMotion = alive ? _jointXMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.yMotion = alive ? _jointYMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.zMotion = alive ? _jointZMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.xMotion = allow ? _jointXMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.yMotion = allow ? _jointYMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.zMotion = allow ? _jointZMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.angularXMotion =
|
||||
alive ? _jointAngularXMotions[joint] : ConfigurableJointMotion.Free;
|
||||
allow ? _jointAngularXMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.angularYMotion =
|
||||
alive ? _jointAngularYMotions[joint] : ConfigurableJointMotion.Free;
|
||||
allow ? _jointAngularYMotions[joint] : ConfigurableJointMotion.Free;
|
||||
configurableJoint.angularZMotion =
|
||||
alive ? _jointAngularZMotions[joint] : ConfigurableJointMotion.Free;
|
||||
allow ? _jointAngularZMotions[joint] : ConfigurableJointMotion.Free;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnSetHP(int hp)
|
||||
{
|
||||
}
|
||||
|
||||
public Vector3 Center => rigidbody.worldCenterOfMass;
|
||||
public bool IsPhysics { get; private set; }
|
||||
public Vector3 Velocity
|
||||
|
Reference in New Issue
Block a user