// Triggers when the game makes a timed update (every 5 seconds) internal static void OnGameTimedUpdate() { if (!isInitialized) { return; } TimedUpdate?.Invoke(); }
public static void Add(Action action, float TimeInterval) { if (Instance.periodicUpdateActions.Any(x => x.Action == action)) { return; } TimedUpdate timedUpdate = Instance.GetTimedUpdates(); timedUpdate.SetUp(action, TimeInterval); Instance.periodicUpdateActions.Add(timedUpdate); }
public static void Add(Action action, float timeInterval) { if (Instance.periodicUpdateActions.Any(x => x.Action == action)) { return; } TimedUpdate timedUpdate = Instance.GetTimedUpdates(); timedUpdate.SetUp(action, timeInterval); timedUpdate.TimeTitleNext += NumberOfUpdatesAdded * 0.1f; NumberOfUpdatesAdded++; Instance.periodicUpdateActions.Add(timedUpdate); }
public static void Remove(CallbackType type, Action action) { if (action == null || Instance == null) { return; } if (type == CallbackType.UPDATE) { if (Instance.updateActions.Contains(action)) { Instance.updateActions.Remove(action); return; } } if (type == CallbackType.FIXED_UPDATE) { Instance.fixedUpdateActions.Remove(action); return; } if (type == CallbackType.LATE_UPDATE) { Instance.lateUpdateActions.Remove(action); return; } if (type == CallbackType.PERIODIC_UPDATE) { TimedUpdate RemovingAction = null; foreach (var periodicUpdateAction in Instance.periodicUpdateActions) { if (periodicUpdateAction.Action == action) { RemovingAction = periodicUpdateAction; } } if (RemovingAction != null) { RemovingAction.Pool(); Instance.periodicUpdateActions.Remove(RemovingAction); } return; } }
public static void Add(Action action, float timeInterval) { if (Instance.periodicUpdateActions.Any(x => x.Action == action)) { return; } TimedUpdate timedUpdate = Instance.GetTimedUpdates(); timedUpdate.SetUp(action, timeInterval); timedUpdate.TimeTitleNext += NumberOfUpdatesAdded * 0.01f; NumberOfUpdatesAdded++; if (NumberOfUpdatesAdded > 500) { NumberOfUpdatesAdded = 0; //So the delay can't be too big } Instance.periodicUpdateActions.Add(timedUpdate); }
public bool isActionReady(GameTime gameTime, int updateTime, TimedUpdate updateType) { long stateChangeTime = updateTime; if (serverTimedUpdates.ContainsKey(updateType)) { stateChangeTime = serverTimedUpdates[updateType]; serverTimedUpdates.Remove(updateType); } stateChangeTime -= gameTime.ElapsedGameTime.Ticks; if (stateChangeTime < 0) { serverTimedUpdates.Add(updateType, updateTime); return(true); } serverTimedUpdates.Add(updateType, stateChangeTime); return(false); }