예제 #1
0
 public TickerEvent(TickerId tickerId, NumericOperation operation, byte amount, byte unk4)
 {
     TickerId  = tickerId;
     Operation = operation;
     Amount    = amount;
     Unk4      = unk4;
 }
예제 #2
0
파일: Chaos.cs 프로젝트: udoprog/ChaosMod
        /// <summary>
        /// Add a ticker which there can only exist one of.
        ///
        /// If the ticker exists, replaces it and returns false.
        /// Otherwise returns true.
        /// </summary>
        public bool AddUniqueTicker(TickerId id, ITicker ticker)
        {
            ITicker value = null;
            var     added = true;

            if (uniqueTickers.TryGetValue(id, out value))
            {
                value.Stop();
                added = false;
            }

            uniqueTickers[id] = ticker;
            return(added);
        }
예제 #3
0
    public static QueryTickerEvent Serdes(QueryTickerEvent e, AssetMapping mapping, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }
        e ??= new QueryTickerEvent();
        e.Operation = s.EnumU8(nameof(Operation), e.Operation);
        e.Immediate = s.UInt8(nameof(Immediate), e.Immediate);
        int zeroes = s.UInt8(null, 0);

        zeroes    += s.UInt8(null, 0);
        e.TickerId = TickerId.SerdesU16(nameof(TickerId), e.TickerId, mapping, s);
        // field 8 is the next event id when the condition is false and is deserialised as part of the BranchEventNode that this event should belong to.

        s.Assert(zeroes == 0, "QueryTickerEvent: Expected fields 3,4 to be 0");
        return(e);
    }
예제 #4
0
        public static SetTickerEvent Serdes(SetTickerEvent e, AssetMapping mapping, ISerializer s)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }

            e ??= new SetTickerEvent();
            e.Operation = s.EnumU8(nameof(Operation), e.Operation);
            e.Amount    = s.UInt8(nameof(Amount), e.Amount);
            e.Unk4      = s.UInt8(nameof(Unk4), e.Unk4);
            e.Unk5      = s.UInt8(nameof(Unk5), e.Unk5);
            e.TickerId  = TickerId.SerdesU16(nameof(TickerId), e.TickerId, mapping, s);
            e.Unk8      = s.UInt16(nameof(Unk8), e.Unk8);
            ApiUtil.Assert(e.Unk4 == 0 || e.Unk4 == 1);
            ApiUtil.Assert(e.Unk5 == 0);
            ApiUtil.Assert(e.Unk8 == 0);
            return(e);
        }
예제 #5
0
    public static TickerEvent Serdes(TickerEvent e, AssetMapping mapping, ISerializer s)
    {
        if (s == null)
        {
            throw new ArgumentNullException(nameof(s));
        }

        e ??= new TickerEvent();
        e.Operation = s.EnumU8(nameof(Operation), e.Operation);
        e.Amount    = s.UInt8(nameof(Amount), e.Amount);
        e.Unk4      = s.UInt8(nameof(Unk4), e.Unk4);
        int zeroed = s.UInt8(null, 0);

        e.TickerId = TickerId.SerdesU16(nameof(TickerId), e.TickerId, mapping, s);
        zeroed    += s.UInt16(null, 0);
        ApiUtil.Assert(e.Unk4 is 0 or 1);
        s.Assert(zeroed == 0, "TickerEvent: Expected fields 5, 8 to be 0");
        return(e);
    }
예제 #6
0
 public QueryTickerEvent(QueryOperation operation, byte immediate, TickerId tickerId)
 {
     Operation = operation;
     Immediate = immediate;
     TickerId  = tickerId;
 }
예제 #7
0
 public short GetTicker(TickerId id) => _game.Tickers.TryGetValue(id, out var value) ? value : (short)0;
예제 #8
0
 public QueryTickerEvent(TickerId tickerId, QueryOperation operation, byte immediate)
 {
     TickerId  = tickerId;
     Operation = operation;
     Immediate = immediate;
 }
예제 #9
0
파일: Chaos.cs 프로젝트: udoprog/ChaosMod
 /// <summary>
 /// Check if the given ticker is active.
 /// </summary>
 public bool HasTicker(TickerId id)
 {
     return(uniqueTickers.ContainsKey(id));
 }