using System; using System.Collections; using System.Collections.Generic; using BITKit; using BITKit.StateMachine; using BITKit.UX; using UnityEngine; namespace BITFALL.Entities.Equipment.Universal.States { [Serializable] public sealed class Draw:UseState { protected override void OnPlayEnd() { base.OnPlayEnd(); useController.TransitionState(); } } [Serializable] public sealed class Use:UseState { public override void OnStateEntry(IState old) { base.OnStateEntry(old); useController._equipmentContainer.OnEquip+=OnEquip; } public override void OnStateExit(IState old, IState newState) { base.OnStateExit(old, newState); useController._equipmentContainer.OnEquip-=OnEquip; } protected override void OnPlayEnd() { base.OnPlayEnd(); //useController.TransitionState(); if (useController.Release) useController._playerEquipSelector.Cancel(); else { try { if (useController.Item is not null && useController.Inventory.AllowUseItem(useController.Item) ) { currentState.Events.OnEnd = null; currentState.Stop(); PlayAnimation(); //animancerComponent.States.Current.Time = 0; } else { useController._playerEquipSelector.Cancel(); } } catch (InGameException e) { useController.UXPopup.Popup(e.Message); useController._playerEquipSelector.Cancel(); } } } private void OnEquip(IEquipmentSlot arg1, IBasicItem arg2) { if (useController.ScriptableItem.AddressablePath != arg2?.AddressablePath) return; useController.Item = arg2; } } [Serializable] public sealed class Exit:UseState { public override void OnStateEntry(IState old) { if (clips.Length is 0) { animancerComponent.Stop(); } else { base.OnStateEntry(old); } } protected override void OnPlayEnd() { base.OnPlayEnd(); animancerComponent.Stop(); } } }