public static void Deserialize(GenericReader reader) { int version = reader.ReadEncodedInt(); //Version 0 if (version >= 0) { m_Enabled = reader.ReadBool(); m_Active = reader.ReadBool(); NextScheduledCaptureEventStartTime = reader.ReadDateTime(); AnnouncementMade = reader.ReadBool(); TimeElapsed = reader.ReadTimeSpan(); CurrentSchedulePosition = reader.ReadInt(); CurrentCyclePosition = reader.ReadInt(); CurrentEventPosition = reader.ReadInt(); int captureEventCount = reader.ReadInt(); for (int a = 0; a < captureEventCount; a++) { FactionCaptureEvent captureEvent = (FactionCaptureEvent)reader.ReadItem(); CaptureEvents.Add(captureEvent); } CurrentCaptureEvent = (FactionCaptureEvent)reader.ReadItem(); } }
public static void StartCaptureEvent() { if (Active) { return; } FactionCaptureEvent.CreateCaptureEvent(); if (CurrentCaptureEvent == null) { return; } CurrentCaptureEvent.OnEventStart(); Active = true; CurrentCaptureEvent.EventStart = DateTime.UtcNow; TimeElapsed = TimeSpan.FromSeconds(0); if (m_Timer != null) { m_Timer.Stop(); m_Timer = null; } m_Timer = new FactionTimer(); m_Timer.Start(); }
public static void EndCaptureEvent() { if (!Active) { return; } Active = false; TimeElapsed = TimeSpan.FromSeconds(0); if (CurrentCaptureEvent != null) { CurrentCaptureEvent.OnEventCompletion(); CurrentCaptureEvent.EventCompletion = DateTime.UtcNow; CurrentCaptureEvent.Completed = true; CurrentCaptureEvent = null; } CurrentEventPosition++; //Cycle Completed if (CurrentEventPosition > EventsInCycle.Count) { CurrentCyclePosition++; CurrentEventPosition = 1; //Schedule Completed if (CurrentCyclePosition > CyclesPerSchedule) { CurrentSchedulePosition++; CurrentCyclePosition = 1; ResolveScheduleCompletion(); } } if (CurrentCyclePosition > EventsInCycle.Count) { CurrentCyclePosition = EventsInCycle.Count; } TimeSpan timeUntilNextEvent = EventsInCycle[CurrentCyclePosition - 1]; if (CurrentCyclePosition == 1) { timeUntilNextEvent = timeUntilNextEvent + CycleDowntime; } FactionPersistance.NextScheduledCaptureEventStartTime = FactionPersistance.NextScheduledCaptureEventStartTime + timeUntilNextEvent; }
public static void CreateCaptureEvent() { FactionCaptureEvent factionCaptureEvent = null; //TEST: Populate factionCaptureEvent.SchedulePosition = FactionPersistance.CurrentSchedulePosition; factionCaptureEvent.CyclePosition = FactionPersistance.CurrentCyclePosition; factionCaptureEvent.EventPosition = FactionPersistance.CurrentEventPosition; FactionPersistance.CurrentCaptureEvent = factionCaptureEvent; FactionPersistance.CaptureEvents.Add(factionCaptureEvent); }
public static void ResolveScheduleCompletion() { if (DeletePreviousCycleRecords) { Queue m_Queue = new Queue(); while (m_Queue.Count > 0) { FactionCaptureEvent captureEvent = (FactionCaptureEvent)m_Queue.Dequeue(); captureEvent.Delete(); } } }
public static void FactionDeleteAllCaptureEvents(CommandEventArgs arg) { PlayerMobile pm_Mobile = arg.Mobile as PlayerMobile; if (pm_Mobile == null) { return; } CurrentSchedulePosition = 1; CurrentEventPosition = 1; CurrentCyclePosition = 1; if (Active) { EndCaptureEvent(); } Queue m_Queue = new Queue(); foreach (FactionCaptureEvent FactionCaptureEvent in CaptureEvents) { m_Queue.Enqueue(FactionCaptureEvent); } while (m_Queue.Count > 0) { FactionCaptureEvent factionCaptureEvent = (FactionCaptureEvent)m_Queue.Dequeue(); factionCaptureEvent.Delete(); } CurrentCaptureEvent = null; //Prevent New Event Immediately Occuring: Will Require Schedule Realignment if (DateTime.UtcNow >= FactionPersistance.NextScheduledCaptureEventStartTime) { FactionPersistance.NextScheduledCaptureEventStartTime = DateTime.UtcNow + TimeSpan.FromDays(365); } }