mu3-mods/UnlockGameEvents/MU3.Client/patch_PacketGetGameEvent.cs
akanyan cc7bc8613b feat: add the remaining things
* DisableMaintenance
* UnlockAllMusic
* UnlockGameEvents
* UnlockMemoryChapters
2024-07-08 02:10:46 +09:00

36 lines
1.3 KiB
C#

using MU3.Data;
using MU3.Operation;
using MU3.Util;
using System;
using System.Linq;
namespace MU3.Client;
class patch_PacketGetGameEvent: Packet {
public Operation.GameEvent _gameEvent;
public Operation.GameEvent gameEvent => _gameEvent;
public extern State orig_proc();
public override State proc() {
State state = orig_proc();
if(state == State.Done) {
DateTime endDate = DateTime.Parse("2099-01-01 05:00:00.0");
_gameEvent ??= new Operation.GameEvent();
foreach(EventData eventData in SingletonStateMachine<DataManager, DataManager.EState>.instance.allEventData) {
IdPeriod idPeriod = Enumerable.FirstOrDefault(_gameEvent.list, (IdPeriod e) => e.id == eventData.id);
if(idPeriod != null) {
if(idPeriod.period.endDate < CustomDateTime.Now) {
idPeriod.period.endDate = endDate;
}
} else {
idPeriod = new();
idPeriod.id = eventData.id;
idPeriod.period = new Period(DateTime.MinValue.Date, endDate);
_gameEvent.list.Add(idPeriod);
_gameEvent.lastUpdate = CustomDateTime.Now;
}
}
}
return state;
}
}