1
This commit is contained in:
@@ -80,6 +80,10 @@ namespace BITKit.Entities
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void Entered()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void Exit()
|
||||
{
|
||||
if (entityAnimator)
|
||||
@@ -93,15 +97,22 @@ namespace BITKit.Entities
|
||||
public virtual UniTask ExitAsync()
|
||||
{
|
||||
AllowRendering.RemoveElement(this);
|
||||
if (cameraTransform is not null)
|
||||
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual async void Exited()
|
||||
{
|
||||
if (cameraTransform)
|
||||
{
|
||||
await UniTask.NextFrame(destroyCancellationToken);
|
||||
cameraTransform.localPosition = default;
|
||||
cameraTransform.localRotation = _initialCameraRotation;
|
||||
}
|
||||
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public virtual void OnAwake()
|
||||
@@ -110,7 +121,7 @@ namespace BITKit.Entities
|
||||
if (animator)
|
||||
animator.enabled = false;
|
||||
AllowRendering.Invoke();
|
||||
if (cameraTransform is not null)
|
||||
if (cameraTransform)
|
||||
_initialCameraRotation = cameraTransform.localRotation;
|
||||
Initialize();
|
||||
inputActionGroup.allowInput.Invoke();
|
||||
@@ -137,6 +148,7 @@ namespace BITKit.Entities
|
||||
case "Attack":
|
||||
meleeService.Melee(new MeleeCommand
|
||||
{
|
||||
|
||||
PlayerId = Entity.Id,
|
||||
Position = Transform.position,
|
||||
Force = meleeForce * equip.MeleeForce,
|
||||
@@ -185,6 +197,7 @@ namespace BITKit.Entities
|
||||
private IBasicItem _currentItem;
|
||||
|
||||
[Inject(true)] private IHealth _health;
|
||||
public IValidHandle AllowEquip { get; } =new ValidHandle();
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
@@ -192,13 +205,19 @@ namespace BITKit.Entities
|
||||
|
||||
equips.OnEntry += OnEntry;
|
||||
equips.OnExit += OnExit;
|
||||
|
||||
|
||||
AllowEquip.AddListener(OnAllowEquip);
|
||||
|
||||
if (_health is not null)
|
||||
{
|
||||
_health.OnSetAlive += x =>
|
||||
{
|
||||
AllowEquip.SetElements(this,x);
|
||||
if (x is false)
|
||||
{
|
||||
_currentItem = null;
|
||||
EntryEquip(-1);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -209,7 +228,17 @@ namespace BITKit.Entities
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnAllowEquip(bool allow)
|
||||
{
|
||||
if (allow)
|
||||
{
|
||||
EntryEquip(_currentItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
EntryEquip(-1);
|
||||
}
|
||||
}
|
||||
public override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
@@ -217,8 +246,11 @@ namespace BITKit.Entities
|
||||
{
|
||||
x.OnStart();
|
||||
}
|
||||
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
|
||||
{
|
||||
EntryEquip(overrideIndex.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnExit(IEquipBase obj)
|
||||
{
|
||||
OnUnEquipAddressable?.Invoke(obj.AddressablePath);
|
||||
@@ -264,10 +296,7 @@ namespace BITKit.Entities
|
||||
optionalScope.Value.SetActive(AllowScope);
|
||||
}
|
||||
|
||||
if (overrideIndex.Allow && (_health?.IsAlive ?? true))
|
||||
{
|
||||
EntryEquip(overrideIndex.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsSupportItem(IBasicItem item)=> equips.list.Any(x => x.IsSupportItem(item));
|
||||
|
Reference in New Issue
Block a user