示例#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);
                }
            }
        }
示例#2
0
 void ValuesWrite(IO.BitStream s, GameEngineMegaloVariant megalo, bool isRangeValue)
 {
     for (int x = 0; x < Values.Count; x++)
     {
         Values[x].Serialize(s, megalo, isRangeValue);
     }
 }
示例#3
0
        protected GameEngineSandboxVariant(GameEngineVariant variantManager)
        {
            MegaloVariant = GameEngineMegaloVariant.Create(variantManager);

            EditorTraits = MegaloVariant.BaseVariant.NewPlayerTraits();

            RevertToDefault();
        }
示例#4
0
 public void Serialize(IO.BitStream s, GameEngineMegaloVariant megalo, bool isRangeValue)
 {
     s.Stream(ref Value, 10, signExtend: true);
     if (!isRangeValue)
     {
         megalo.StreamStringTableIndexReference(s, ref NameStringIndex);
         megalo.StreamStringTableIndexReference(s, ref DescriptionStringIndex);
     }
 }
示例#5
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);
            }
        }
示例#6
0
 internal void SerializeHeader <TDoc, TCursor>(GameEngineMegaloVariant variant, IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     variant.SerializeStringTableIndex(s, "nameIndex", ref NameStringIndex);
     variant.SerializeStringTableIndex(s, "descIndex", ref DescriptionStringIndex);
     if (s.StreamAttributeOpt("isRangeValue", ref IsRangeValue, Predicates.IsTrue))
     {
         SerializeRangeValues(s);
     }
     else
     {
         SerializeValues(s);
     }
 }
示例#7
0
        void InitializeVariant()
        {
            var engine = GameBuild.Engine;

            mLanguageSystemRef = engine.GetSystem <Localization.LanguageSystem>(GameBuild);

            if (RequiresMegaloProtoSystem)
            {
                mMegaloProtoSystemRef = engine.TryGetSystem <Megalo.Proto.MegaloProtoSystem>(GameBuild);
            }

            switch (Type)
            {
            case GameEngineType.None:
                Variant = GameEngineBaseVariant.Create(this);
                break;

            case GameEngineType.Sandbox:
                Variant = GameEngineSandboxVariant.Create(this);
                break;

            case GameEngineType.Megalo:
                Variant = GameEngineMegaloVariant.Create(this);
                break;

            case GameEngineType.Campaign:
                Variant = GameEngineCampaignVariant.Create(this);
                break;

            case GameEngineType.Survival:
                throw new NotImplementedException(Type.ToString());

            //Variant = GameEngineSurvivalVariant.Create(this);
            //break;
            case GameEngineType.Firefight:
                throw new NotImplementedException(Type.ToString());
            //Variant = GameEngineFirefightVariant.Create(this);
            //break;

            default: throw new KSoft.Debug.UnreachableException(Type.ToString());
            }
        }
示例#8
0
        static int SerializeUserOptionToggle <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                             Collections.BitSet bitset, int bitIndex, GameEngineMegaloVariant variant)
            where TDoc : class
            where TCursor : class
        {
            if (!variant.TagElementStreamSerializeFlags.UseUserOptionNames())
            {
                s.StreamCursor(ref bitIndex);
            }
            else if (s.IsReading)
            {
                string option_name = null;
                s.ReadCursor(ref option_name);
                bitIndex = variant.EngineDefinition.FromIndexName(
                    Megalo.Proto.MegaloScriptValueIndexTarget.Option, option_name);
            }
            else if (s.IsWriting)
            {
                string option_name = variant.EngineDefinition.ToIndexName(
                    Megalo.Proto.MegaloScriptValueIndexTarget.Option, bitIndex);
                s.WriteCursor(option_name);
            }

            return(bitIndex);
        }
示例#9
0
        static int SerializeEngineOptionToggle <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s,
                                                               Collections.BitSet bitset, int bitIndex, GameEngineMegaloVariant variant)
            where TDoc : class
            where TCursor : class
        {
            s.StreamCursor(ref bitIndex);

            return(bitIndex);
        }