Beispiel #1
0
 //将事件通知观察者
 public void NotifyObservers(DateTime UTC)
 {
     //枚举容器中的观察者,将事件一一通知给他们
     if (ChangeTimeEvent != null)
     {
         //e 获取观察者兴趣的变量
         CorrectionEventArgs e       = new CorrectionEventArgs(UTC);
         Delegate[]          delArry = ChangeTimeEvent.GetInvocationList();
         foreach (Delegate item in delArry)
         {
             item.DynamicInvoke(this, e);
         }
     }
 }
Beispiel #2
0
    public static ChangeTimeEvent Serdes(ChangeTimeEvent e, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }
        e ??= new ChangeTimeEvent();
        e.Operation = s.EnumU8(nameof(Operation), e.Operation);
        int zeroes = s.UInt8(null, 0);

        zeroes  += s.UInt8(null, 0);
        zeroes  += s.UInt8(null, 0);
        e.Amount = s.UInt16(nameof(Amount), e.Amount);
        zeroes  += s.UInt16(null, 0);
        s.Assert(zeroes == 0, "ChangeTime: Expected fields 3,4,5,8 to be 0");
        return(e);
    }
Beispiel #3
0
    public static ModifyEvent BaseSerdes(ModifyEvent genericEvent, AssetMapping mapping, AssetId eventSource, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }
        var subType = s.EnumU8("SubType", genericEvent?.SubType ?? ModifyType.Unk2);

        return(subType switch
        {
            ModifyType.Switch => SwitchEvent.Serdes((SwitchEvent)genericEvent, mapping, s),                                        // 0
            ModifyType.DisableEventChain => DisableEventChainEvent.Serdes((DisableEventChainEvent)genericEvent, eventSource, s),   // 1
            ModifyType.Unk2 => ModifyUnk2Event.Serdes((ModifyUnk2Event)genericEvent, s),                                           // 2
            ModifyType.NpcActive => DisableNpcEvent.Serdes((DisableNpcEvent)genericEvent, s),                                      // 4
            ModifyType.AddPartyMember => AddPartyMemberEvent.Serdes((AddPartyMemberEvent)genericEvent, mapping, s),                // 5
            ModifyType.InventoryItem => AddRemoveInventoryItemEvent.Serdes((AddRemoveInventoryItemEvent)genericEvent, mapping, s), // 6
            ModifyType.MapLighting => SetMapLightingEvent.Serdes((SetMapLightingEvent)genericEvent, s),                            // B
            ModifyType.PartyGold => ChangePartyGoldEvent.Serdes((ChangePartyGoldEvent)genericEvent, s),                            // F
            ModifyType.PartyRations => ChangePartyRationsEvent.Serdes((ChangePartyRationsEvent)genericEvent, s),                   // 10
            ModifyType.Time => ChangeTimeEvent.Serdes((ChangeTimeEvent)genericEvent, s),                                           // 12
            ModifyType.Leader => SetPartyLeaderEvent.Serdes((SetPartyLeaderEvent)genericEvent, mapping, s),                        // 1A
            ModifyType.Ticker => TickerEvent.Serdes((TickerEvent)genericEvent, mapping, s),                                        // 1C
            _ => throw new InvalidEnumArgumentException(nameof(subType), (int)subType, typeof(ModifyType))
        });