public override void OnComponentUsed(AddonComponent component, Mobile from) { if (!Activated && component != null && component is InternalComponent && from.InRange(component.Location, 2)) { InternalComponent comp = component as InternalComponent; if (!comp.Active) { comp.Active = true; comp.WhoActivated = from; if (Activator1.Active && Activator2.Active && Activator1.WhoActivated != Activator2.WhoActivated) { if (ActiveTimer != null) { ActiveTimer.Stop(); ActiveTimer = null; } Activated = true; CheckNetwork(); } else if (ActiveTimer == null) { ActiveTimer = Timer.DelayCall(TimeSpan.FromSeconds(1), Reset); } } } }
void OnDoorOpened(Door door, BasePlayer player) { float time; if (!PlayersData.TryGetValue(player.userID, out time)) { time = DefaultTime; } if (time <= 0) { return; } Timer ActiveTimer; if (ActiveTimers.TryGetValue(door, out ActiveTimer)) { ActiveTimer.Destroy(); ActiveTimers.Remove(door); } ActiveTimers[door] = timer.Once(time, () => { ActiveTimers.Remove(door); if (door == null || !door.IsOpen()) { return; } door.SetFlag(BaseEntity.Flags.Open, false); UpdateLayerMethod.Invoke(door, null); door.SendNetworkUpdateImmediate(false); }); }
protected override void StepTimers(float deltaTime) { if (!UpdateBoth) { base.StepTimers(deltaTime); } else { ActiveTimer.AdvanceTimeIfNotDone(deltaTime); InactiveTimer.AdvanceTimeIfNotDone(deltaTime); } }
public void StartTimer(string startTime) { bool timeOK = startTime == ""; if (timeOK) { ActiveTimer.StartTimer(); } else { int pos = startTime.IndexOf(':'); int check = startTime.LastIndexOf(':'); int starthour = 0, startmin = 0; timeOK = true; if (pos != check) { timeOK = false; } if (pos >= 3 || pos == 0) { timeOK = false; } if ((pos == 1 && startTime.Length >= 5) || startTime.Length >= 6) { timeOK = false; } try { starthour = Int32.Parse(startTime.Substring(0, pos)); } catch (Exception) { timeOK = false; } try { startmin = Int32.Parse(startTime.Substring(pos + 1)); } catch (Exception) { timeOK = false; } if (timeOK) { ActiveTimer.StartTimer(starthour, startmin); } else { ActiveIO.ShowMessage("The Time is only allowed in the format HH:MM."); } } }
public void ResetTimer() { ActiveTimer.ResetTimer(); }
public void PauseTimer() { ActiveTimer.PauseTimer(); }