Example #1
0
 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));
 }
Example #2
0
 public ScheduledUpdate(DelUpdate callback, long lastUpdate, long nextUpdate, long interval = -1)
 {
     Callback   = callback;
     LastUpdate = lastUpdate;
     NextUpdate = nextUpdate;
     Interval   = interval;
 }
Example #3
0
 public BehaviorState(int nState, DelStart delStart, DelEnd delEnd, DelUpdate delUpdate, string strStateName)
 {
     this.nBehavior    = nState;
     mDelStart         = delStart;
     mDelEnd           = delEnd;
     mDelUpdate        = delUpdate;
     this.strStateName = strStateName;
 }
Example #4
0
    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;
    }
Example #5
0
        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));
        }
Example #6
0
 public static void DeregisterOnLateUpdate(DelUpdate onLateUpdate, UpdateType updateType = UpdateType.Main)
 {
     onLateUpdateListTypeDic[updateType].Remove(onLateUpdate);
 }
Example #7
0
 public static void RegisterOnLateUpdate(DelUpdate onLateUpdate, UpdateType updateType = UpdateType.Main)
 {
     Init();
     onLateUpdateListTypeDic[updateType].Add(onLateUpdate);
 }
Example #8
0
 public void RemoveUpdate(DelUpdate update)
 {
     EnergyWeaponsCore.LoggerStatic?.Info($"Removing {update.Method} on {update.Target}");
     using (_lock.AcquireExclusiveUsing())
         _updatesToRemove.Add(update);
 }