Exemplo n.º 1
0
        public void Serialize(IO.BitStream s, GameEngineMegaloVariant megalo)
        {
            megalo.StreamStringTableIndexReference(s, ref NameStringIndex);
            megalo.StreamStringTableIndexReference(s, ref DescriptionStringIndex);
            s.Stream(ref IsRangeValue);
            if (IsRangeValue)
            {
                s.Stream(ref Value, 10, signExtend: true);
                // min, max
                if (s.IsReading)
                {
                    ValuesRead(s, megalo, 2, IsRangeValue);
                }
                else if (s.IsWriting)
                {
                    ValuesWrite(s, megalo, IsRangeValue);
                }
            }
            else
            {
                megalo.StreamUserDefinedValueIndex(s, ref DefaultValueIndex);
                if (s.IsReading)
                {
                    ValuesRead(s, megalo, TypeExtensions.kNone, IsRangeValue);
                }
                else if (s.IsWriting)
                {
                    int count = Values.Count;
                    megalo.StreamUserDefinedValuesCount(s, ref count);

                    ValuesWrite(s, megalo, IsRangeValue);
                }
            }
        }
Exemplo n.º 2
0
        void ValuesRead(IO.BitStream s, GameEngineMegaloVariant megalo, int count, bool isRangeValue)
        {
            if (count.IsNone())
            {
                megalo.StreamUserDefinedValuesCount(s, ref count);
            }

            for (int x = 0; x < count; x++)
            {
                var e = new MegaloVariantUserDefinedOptionValueElement();
                e.Serialize(s, megalo, isRangeValue);
                Values.Add(e);
            }
        }