public SpecialActionFlags GetSpecialActionFlags() { SpecialActionFlags specialActionFlags = new SpecialActionFlags(); // counts number of special action flags if (PsaFile.DataSection[DataSectionLocation + 6] >= 1480 && PsaFile.DataSection[DataSectionLocation + 6] < PsaFile.DataSectionSize) { specialActionFlags.Offset = PsaFile.DataSection[DataSectionLocation + 6]; specialActionFlags.ActionFlagsCount = 274 + NumberOfSpecialActions; for (int i = 0; i < NumberOfSpecialActions; i++) { if (PsaFile.DataSection[DataSectionLocation + 6] + i * 16 > 1479 && PsaFile.DataSection[DataSectionLocation + 6] + i * 16 < PsaFile.DataSectionSize) { int specialActionFlagActionLocation = PsaFile.DataSection[DataSectionLocation + 6] + i * 16; int specialActionFlagActionValuesLocation = specialActionFlagActionLocation / 4; int[] flagValues = new int[4]; // each flag has four values for (int j = 0; j < 4; j++) { flagValues[j] = PsaFile.DataSection[specialActionFlagActionValuesLocation + j]; } ActionFlag actionFlag = new ActionFlag(specialActionFlagActionLocation, flagValues); specialActionFlags.ActionFlags.Add(actionFlag); } } } Console.WriteLine(specialActionFlags); return(specialActionFlags); }
public CommonActionFlags GetCommonActionFlags() { CommonActionFlags commonActionFlags = new CommonActionFlags(); // counts number of common action flags if (PsaFile.DataSection[DataSectionLocation + 5] >= 1480 && PsaFile.DataSection[DataSectionLocation + 5] < PsaFile.DataSectionSize) { commonActionFlags.Offset = PsaFile.DataSection[DataSectionLocation + 5]; commonActionFlags.ActionFlagsCount = 274; for (int i = 0; i < 274; i++) { if (PsaFile.DataSection[DataSectionLocation + 5] + i * 16 > 1479 && PsaFile.DataSection[DataSectionLocation + 5] + i * 16 < PsaFile.DataSectionSize) { int commonActionFlagActionLocation = PsaFile.DataSection[DataSectionLocation + 5] + i * 16; int commonActionFlagActionValuesLocation = commonActionFlagActionLocation / 4; int[] flagValues = new int[4]; // each flag has four values for (int j = 0; j < 4; j++) { flagValues[j] = PsaFile.DataSection[commonActionFlagActionValuesLocation + j]; } ActionFlag actionFlag = new ActionFlag(commonActionFlagActionLocation, flagValues); commonActionFlags.ActionFlags.Add(actionFlag); } } } Console.WriteLine(commonActionFlags); return(commonActionFlags); }
public ExtraActionFlags GetExtraActionFlags() { ExtraActionFlags extraActionFlags = new ExtraActionFlags(); // counts number of extra action flags if (PsaFile.DataSection[DataSectionLocation + 7] >= 1480 && PsaFile.DataSection[DataSectionLocation + 7] < PsaFile.DataSectionSize) { extraActionFlags.Offset = PsaFile.DataSection[DataSectionLocation + 6]; extraActionFlags.ActionFlagsCount = 274 + NumberOfSpecialActions; for (int i = 0; i < 274 + NumberOfSpecialActions; i++) { if (PsaFile.DataSection[DataSectionLocation + 7] + i * 8 > 1479 && PsaFile.DataSection[DataSectionLocation + 7] + i * 8 < PsaFile.DataSectionSize) { int extraActionFlagActionLocation = PsaFile.DataSection[DataSectionLocation + 7] + i * 8; int extraActionFlagActionValuesLocation = extraActionFlagActionLocation / 4; int[] flagValues = new int[2]; // each flag has two values for (int j = 0; j < 2; j++) { flagValues[j] = PsaFile.DataSection[extraActionFlagActionValuesLocation + j]; } ActionFlag actionFlag = new ActionFlag(extraActionFlagActionLocation, flagValues); extraActionFlags.ActionFlags.Add(actionFlag); } } } Console.WriteLine(extraActionFlags); return(extraActionFlags); }
public RepeatingAction(Action action, DateTime scheduledTime, TimeSpan interval, ActionFlag flags) { this.action = action; this.scheduledTime = scheduledTime; this.interval = interval; this.flags = flags; }
private void DoAction() { ActionFlag actionFlag = (ActionFlag)Enum.Parse(typeof(ActionFlag), action); WriteLog($"DoAction (flags={actionFlag.ToString()})"); command = (ICommand)Global.GetInstanceByClassName($"Shutdowntor.Command.{actionFlag.ToString()}Command"); command.Execute(); WriteLog($"DoAction (flags={actionFlag.ToString()}) END"); }
public void RemoveConditionalAction(ActionFlag kind, string actionName) { var action = _inputActionGroup[actionName]; _inputActionGroup.Remove(actionName); _conditionalEventArgs.Args.Remove(actionName); switch (kind) { case ActionFlag.OnNormalAttack: _onNormalAttackAction -= action; break; case ActionFlag.OnNormalAttackHit: _onNormalAttackHitAction -= action; break; case ActionFlag.OnChargeAttack: _onChargeAttackAction -= action; break; case ActionFlag.OnActiveSkill: _onActiveSkillAction -= action; break; case ActionFlag.OnDash: _onDashAction -= action; break; case ActionFlag.OnKillEnemy: _onKillEnemyAction -= action; break; case ActionFlag.OnHurt: _onHurtAction -= action; break; case ActionFlag.OnFiveSecond: _onFiveSecondAction -= action; break; case ActionFlag.OnHealthPointFull: _onHealthPointFullAction -= action; break; case ActionFlag.OnHealthPointUnderFifty: _onHealthPointUnderFiftyAction -= action; break; case ActionFlag.OnActionPointFull: _onActionPointFullAction -= action; break; default: throw new ArgumentOutOfRangeException(nameof(kind), kind, " Action Name : " + actionName); } }
public void SetActionFlag(ActionFlag flag, bool on) { if (on && ((int)flag & _actionFlag) == 0) { _actionFlag |= (int)flag; } else if (!on && ((int)flag & _actionFlag) != 0) { _actionFlag -= (int)flag; } }
public void AddConditionalAction(ActionFlag kind, Action <ConditionalEventArgs> action, string actionName, CustomActionArgs args) { _inputActionGroup.Add(actionName, action); _conditionalEventArgs.Args.Add(actionName, args); switch (kind) { case ActionFlag.OnNormalAttack: _onNormalAttackAction += action; break; case ActionFlag.OnNormalAttackHit: _onNormalAttackHitAction += action; break; case ActionFlag.OnChargeAttack: _onChargeAttackAction += action; break; case ActionFlag.OnActiveSkill: _onActiveSkillAction += action; break; case ActionFlag.OnDash: _onDashAction += action; break; case ActionFlag.OnKillEnemy: _onKillEnemyAction += action; break; case ActionFlag.OnHurt: _onHurtAction += action; break; case ActionFlag.OnFiveSecond: _onFiveSecondAction += action; break; case ActionFlag.OnHealthPointFull: _onHealthPointFullAction += action; break; case ActionFlag.OnHealthPointUnderFifty: _onHealthPointUnderFiftyAction += action; break; case ActionFlag.OnActionPointFull: _onActionPointFullAction += action; break; default: throw new ArgumentOutOfRangeException(nameof(kind), kind, " Action Name : " + actionName); } }
public int RemoveByFlag(ActionFlag flag, bool cancel = true) { var actionsWithFlag = actions.Where(action => action.Flags.HasFlag(flag)).ToList(); actions.RemoveAll(action => action.Flags.HasFlag(flag)); if (cancel) { actionsWithFlag.ForEach(action => action.Cancel()); } return(actionsWithFlag.Count); }
public async Task SetAndWait() { var MyFlag = new ActionFlag(WaitHalfSecond); var StartTime = DateTime.Now; await MyFlag.SetAndWait(); Assert.That(DateTime.Now.Subtract(StartTime).TotalMilliseconds, Is.InRange(400.0, 600.0)); Assert.AreEqual(1, _Counter, "Counter is not as expected"); }
public MobPrototypeData() { Actions = new ActionFlag(); AffectedBy = new AffectedByFlag(); Health = new DiceRoll(); Mana = new DiceRoll(); Damage = new DiceRoll(); ArmorRating = new ArmorRating(); Offense = new OffensiveFlag(); Immunity = new ImmunityFlag(); Resistance = new ResistanceFlag(); Vulnerability = new VulnerabilityFlag(); }
public async Task SetAndWaitTwiceDelay() { var MyFlag = new ActionFlag(WaitHalfSecond, new TimeSpan(0, 0, 0, 0, 100)); var StartTime = DateTime.Now; MyFlag.Set(); Thread.Sleep(200); await MyFlag.SetAndWait(); Assert.That(DateTime.Now.Subtract(StartTime).TotalMilliseconds, Is.InRange(1100.0, 1300.0)); Assert.AreEqual(2, _Counter, "Counter is not as expected"); }
public async Task SetRuns() { var MyFlag = new ActionFlag(WaitFiftyMs); var EndTime = DateTime.Now.AddSeconds(1.0); while (DateTime.Now < EndTime) { MyFlag.Set(); Interlocked.Exchange(ref _Counter, 0); Thread.Sleep(0); } await MyFlag.SetAndWait(); Assert.AreNotEqual(0, _Counter); }
public int RemoveByFlag(ActionFlag flag) { return(actions.RemoveAll(action => action.flags.HasFlag(flag))); }
public void CancelActionsByFlag(ActionFlag flag, bool cancel = true) { scheduledActions.RemoveByFlag(flag, cancel); }
public void CancelActionsByFlag(ActionFlag flag) { scheduledActions.RemoveByFlag(flag); }
public void ScheduleAction(Action action, DateTime time, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None) { scheduledActions.Add(new RepeatingAction(action, time, interval, flags)); }
public void ScheduleAction(Action action, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None) { ScheduleAction(action, DateTime.Now, interval, flags); }
public void ScheduleAction(Action action, DateTime time, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None) { if (Running && (flags == ActionFlag.None || !disabledActions.HasFlag(flags))) scheduledActions.Add(new RepeatingAction(action, time, interval, flags)); }
public void EnableActionsByFlag(ActionFlag flag) { disabledActions &= ~flag; }
public PdfActionAttribute(ActionFlag action) { Action = action; }
public void ForceFragClear() { ActStatus = ActionFlag.WAIT; IsTurning = false; IsSlideStart = false; IsSlide = false; IsSlideEnd = false; IsFlip = false; }
public int ScheduleAction(Action action, DateTime time, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None, Action cancel = null) { if (Running && (flags == ActionFlag.None || !disabledActions.HasFlag(flags))) { scheduledActionCounter++; scheduledActions.Add(new RepeatingAction(action, cancel, time, interval, flags, scheduledActionCounter)); return(scheduledActionCounter); } else { return(0); } }
public void DisableActionsByFlag(ActionFlag flag) { disabledActions |= flag; CancelActionsByFlag(flag); }
public int ScheduleAction(Action action, DateTime time, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None) { if (Running && (flags == ActionFlag.None || !disabledActions.HasFlag(flags))) { scheduledActionCounter++; scheduledActions.Add(new RepeatingAction(action, time, interval, flags, scheduledActionCounter)); return scheduledActionCounter; } else return 0; }
/// <summary> /// 撤单参数构造函数 /// </summary> public CancelOrderParameter() { ActionFlag = ActionFlag.Delete; Status = ParkedOrderStatusType.Deleted; }
public void DisableActionsByFlag(ActionFlag flag) { disabledActions |= flag; CancelActionsByFlag(flag); }
public int ScheduleAction(Action action, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None) { return ScheduleAction(action, DateTime.Now, interval, flags); }
public async Task SetNoWait() { var MyFlag = new ActionFlag(() => Task.CompletedTask); await MyFlag.SetAndWait(); }
public void CancelActionsByFlag(ActionFlag flag) { scheduledActions.RemoveByFlag(flag); }
public RepeatingAction(Action action, Action cancel, DateTime scheduledTime, TimeSpan interval, ActionFlag flags, int id) { this.Action = action; this.Cancel = cancel ?? new Action(() => { }); this.ScheduledTime = scheduledTime; this.Interval = interval; this.Flags = flags; this.Id = id; }
public void EnableActionsByFlag(ActionFlag flag) { disabledActions &= ~flag; }
public int ScheduleAction(Action action, TimeSpan interval = default(TimeSpan), ActionFlag flags = ActionFlag.None, Action cancel = null) { return(ScheduleAction(action, DateTime.Now, interval, flags, cancel)); }