public void DelayedUpdate(DelUpdate update, ulong delay = 0) { EnergyWeaponsCore.LoggerStatic?.Info( $"Invoking {update.Method} on {update.Target} delay={delay}"); using (_lock.AcquireExclusiveUsing()) _updatesToAdd.Add(new ScheduledUpdate(update, _ticks, _ticks + (long)delay)); }
public ScheduledUpdate(DelUpdate callback, long lastUpdate, long nextUpdate, long interval = -1) { Callback = callback; LastUpdate = lastUpdate; NextUpdate = nextUpdate; Interval = interval; }
public BehaviorState(int nState, DelStart delStart, DelEnd delEnd, DelUpdate delUpdate, string strStateName) { this.nBehavior = nState; mDelStart = delStart; mDelEnd = delEnd; mDelUpdate = delUpdate; this.strStateName = strStateName; }
public StateMode(int _stateID, DelStart _startState, DelUpdate _updateState, DelEnd _endState, string _ownerMachine = "????") { this.stateID = _stateID; this.StartState = _startState; this.UpdateState = _updateState; this.EndState = _endState; this.activeTime = 0.0f; this.ownerStatemachine = _ownerMachine; }
public void RepeatingUpdate(DelUpdate update, ulong interval, long delay = -1) { long nextUpdate; if (delay >= 0) { nextUpdate = _ticks + delay; } else { // kinda hacky way to spread updates out. Works best when people use the same interval var block = (_intervalsScheduled++) % (long)interval; nextUpdate = (_ticks / (long)interval) * (long)interval + block; } EnergyWeaponsCore.LoggerStatic?.Info( $"Repeating {update.Method} on {update.Target} interval={interval}, delay={delay}"); using (_lock.AcquireExclusiveUsing()) _updatesToAdd.Add( new ScheduledUpdate(update, nextUpdate - (long)interval, nextUpdate, (long)interval)); }
public static void DeregisterOnLateUpdate(DelUpdate onLateUpdate, UpdateType updateType = UpdateType.Main) { onLateUpdateListTypeDic[updateType].Remove(onLateUpdate); }
public static void RegisterOnLateUpdate(DelUpdate onLateUpdate, UpdateType updateType = UpdateType.Main) { Init(); onLateUpdateListTypeDic[updateType].Add(onLateUpdate); }
public void RemoveUpdate(DelUpdate update) { EnergyWeaponsCore.LoggerStatic?.Info($"Removing {update.Method} on {update.Target}"); using (_lock.AcquireExclusiveUsing()) _updatesToRemove.Add(update); }