public bool Meet(IEventArgs args) { FreeData fd = (FreeData)args.GetUnit(player); if (fd != null) { if (fd.Player.stateInterface.State.GetNextActionKeepState() == ActionKeepInConfig.Sight) { return(false); } var states = fd.Player.StateInteractController().GetCurrStates(); var manager = SingletonManager.Get <StateTransitionConfigManager>(); foreach (var state in states) { StateTransitionConfigItem condition = manager.GetConditionByState(state); if (condition == null) { continue; } if (!condition.GetTransition(Transition.IsUseAction) /*IsUseAction*/) { return(false); } } return(fd.Player.hasRaycastTarget && fd.Player.raycastTarget.Key == key); } return(false); }
public bool IsInterrupted(ISkillArgs args) { FreeData fd = (FreeData)args.GetUnit("current"); if (fd != null) { if (PlayerStateUtil.HasPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay)) { return(true); } var manager = SingletonManager.Get <StateTransitionConfigManager>(); foreach (EPlayerState state in fd.Player.StateInteractController().GetCurrStates()) { StateTransitionConfigItem condition = manager.GetConditionByState(state); if (condition == null) { continue; } if (!condition.GetTransition(Transition.IsUseItem) /*IsUseItem*/) { return(true); } } return(false); } return(false); }
protected bool IsUseActionEnabled() { var player = _playerContext.flagSelfEntity; var states = player.StateInteractController().GetCurrStates(); var manager = SingletonManager.Get <StateTransitionConfigManager>(); foreach (var state in states) { StateTransitionConfigItem condition = manager.GetConditionByState(state); if (condition == null) { continue; } if (!condition.GetTransition(Transition.IsUseAction) /*IsUseAction*/) { if (Logger.IsDebugEnabled) { Logger.DebugFormat("use action is limited by {0}", condition.State); } return(false); } else { if (Logger.IsDebugEnabled) { Logger.DebugFormat("use action is allowed by {0}", condition.State); } } } return(true); }
public static void UseItem(string key, FreeData fd, ISkillArgs args) { var manager = SingletonManager.Get <StateTransitionConfigManager>(); foreach (EPlayerState state in fd.Player.StateInteractController().GetCurrStates()) { StateTransitionConfigItem condition = manager.GetConditionByState(state); if (condition == null) { continue; } if (!condition.GetTransition(Transition.IsUseItem) /*IsUseItem*/) { return; } } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager()); if (ip != null && ip.key.IsConsume() && FreeItemConfig.GetSing(ip.key) > 0) { args.TempUse("current", fd); args.TempUse("item", ip); if (ip.key.CanUse(args)) { FreeItemConfig.UseAnimation(args.GameContext, fd, ip.key.GetKey()); fd.freeInventory.StartUseItem(args, fd, ip, FreeItemConfig.GetSing(ip.key), FreeItemConfig.GetSound(ip.key.GetKey())); } args.Resume("current"); args.Resume("item"); } else { UseItem(ip, fd, fr); } }