Exemplo n.º 1
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            using (s.EnterOwnerBookmark(this))
            {
                using (s.EnterCursorBookmark("Base"))
                    s.StreamObject(BaseVariant);

                using (s.EnterCursorBookmark("Megalo"))
                    SerializeImpl(s);

                if (s.IsWriting && s.IgnoreWritePredicates)                 // #HACK_BLAM: IgnoreWritePredicates hack!
                {
                    Debug.Trace.Megalo.TraceInformation("Always write 'default' data HACK: Skipping MegaloScript element (output will be incomplete) in {0}, '{1}'",
                                                        s.StreamName,
                                                        BaseVariant.Header.Title);

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine();
                    Console.WriteLine("Always write 'default' data HACK: Skipping MegaloScript element (output will be incomplete)");
                    Console.ResetColor();
                    return;
                }

                using (s.EnterCursorBookmark("MegaloScript"))
                    s.StreamObject(EngineDefinition);
            }
        }
Exemplo n.º 2
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            using (s.EnterCursorBookmark("Language"))
            {
                s.StreamAttribute("name", ref mLanguage);

                if (s.IsReading)
                {
                    var       temp_list = new List <LocString>();
                    bool      is_sorted = true;
                    LocString prev_str  = null;
                    foreach (var n in s.ElementsByName("String"))
                    {
                        using (s.EnterCursorBookmark(n))
                        {
                            var str = new LocString();
                            str.Serialize(s);
                            temp_list.Add(str);

                            if (is_sorted && prev_str != null && prev_str.ID >= str.ID)
                            {
                                is_sorted = false;
                            }

                            prev_str = str;
                        }
                    }

                    if (!is_sorted)
                    {
                        temp_list.Sort((x, y) => x.ID.CompareTo(y.ID));
                    }

                    int last_id = temp_list[temp_list.Count - 1].ID;
                    UsedIndices.Length = last_id + 1;

                    mDoNotUpdateUsedIndices = true;
                    foreach (var str in temp_list)
                    {
                        int id = str.ID;
                        if (UsedIndices[id])
                        {
                            s.ThrowReadException(new System.IO.InvalidDataException(string.Format(
                                                                                        "Duplicate LocString: #{0} '{1}'",
                                                                                        str.ID, str.Text)));
                        }

                        UsedIndices[id] = true;
                    }
                    this.AddRange(temp_list);
                    mDoNotUpdateUsedIndices = false;
                }
                else if (s.IsWriting)
                {
                    s.WriteStreamableElements("String", this);
                }
            }
        }
Exemplo n.º 3
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            s.StreamAttributeEnum("filterType", ref mFilterType);

            if (FilterType == MegaloScriptPlayerFilterType.PlayerMask)
            {
                using (s.EnterCursorBookmark("Player")) mPlayer.SerializePlayer(model, s);
                using (s.EnterCursorBookmark("AddOrRemove")) mPlayerAddOrRemove.SerializeCustom(model, s);
            }
        }
Exemplo n.º 4
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            s.StreamAttributeEnum("shapeType", ref mShapeType);

            switch (ShapeType)
            {
            case MegaloScriptShapeType.Sphere:
                using (s.EnterCursorBookmark(kVar0ElementName)) mRadius.SerializeCustom(model, s);
                break;

            case MegaloScriptShapeType.Cylinder:
                using (s.EnterCursorBookmark(kVar0ElementName)) mRadius.SerializeCustom(model, s);
                using (s.EnterCursorBookmark(kVar2ElementName)) mTop.SerializeCustom(model, s);
                using (s.EnterCursorBookmark(kVar3ElementName)) mBottom.SerializeCustom(model, s);
                break;

            case MegaloScriptShapeType.Box:
                using (s.EnterCursorBookmark("Width")) mRadius.SerializeCustom(model, s);
                using (s.EnterCursorBookmark(kVar1ElementName)) mLength.SerializeCustom(model, s);
                using (s.EnterCursorBookmark(kVar2ElementName)) mTop.SerializeCustom(model, s);
                using (s.EnterCursorBookmark(kVar3ElementName)) mBottom.SerializeCustom(model, s);
                break;

            case MegaloScriptShapeType.None: break;

            default: throw new KSoft.Debug.UnreachableException(ShapeType.ToString());
            }
        }
Exemplo n.º 5
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            s.StreamAttributeEnum("meterType", ref mType);

            if (Type == MegaloScriptWidgetMeterType.Numeric)
            {
                using (s.EnterCursorBookmark("Value")) mNumeric1.SerializeCustom(model, s);
                using (s.EnterCursorBookmark("MaxValue")) mNumeric2.SerializeCustom(model, s);
            }
            else if (Type == MegaloScriptWidgetMeterType.Timer)
            {
                using (s.EnterCursorBookmark("Timer"))
                    mTimer.SerializeTimer(model, s);
            }
        }
Exemplo n.º 6
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            bool reading = s.IsReading;

            var system = KSoft.Debug.TypeCheck.CastReference <LanguageSystem>(s.UserData);

            Engine.EngineBuildHandle.SerializeWithBaseline(s, system.Engine.RootBuildHandle,
                                                           ref mBuildHandle);

            if (reading)
            {
                InitializeEngineLanguageTableWithBuildHandle();
            }

            using (s.EnterCursorBookmark("Entries"))
            {
                if (reading)
                {
                    ReadEngineLanguageTable(s);
                }
                else
                {
                    throw new KSoft.Debug.UnreachableException("Writing not supported");
                }
            }
        }
Exemplo n.º 7
0
        void Read <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s,
                                  bool embedValues)
            where TDoc : class
            where TCursor : class
        {
            int param_index = 0;

            foreach (var node in s.ElementsByName("Param"))
            {
                using (s.EnterCursorBookmark(node))
                {
                    if (embedValues)
                    {
                        MegaloScriptValueBase.SerializeValueForEmbed(model, s, ref mValueIds[param_index]);
                    }
                    else
                    {
                        s.StreamCursor(ref mValueIds[param_index]);
                    }

                    Contract.Assert(mValueIds[param_index].IsNotNone());
                    param_index++;

                    if (param_index == mValueIds.Length)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 8
0
 protected void SerializeContentHeader <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Header"))
         s.StreamObject(Header);
 }
Exemplo n.º 9
0
 protected void SerializMapOverrides <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("MapOverrides"))
         s.StreamObject(OptionsMapOverrides);
 }
Exemplo n.º 10
0
 protected void SerializRespawnOptions <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Respawning"))
         s.StreamObject(OptionsRespawning);
 }
Exemplo n.º 11
0
        public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
        {
            base.Serialize(s);

            using (s.EnterCursorBookmark("Powerups"))
            {
                GameOptionsPowerup             pu;
                Predicate <GameOptionsPowerup> pu_is_not_default = obj => !obj.IsUnchanged;

                pu = Powerups[0];
                using (var bm = s.EnterCursorBookmarkOpt("DamageBoost", pu, pu_is_not_default)) if (bm.IsNotNull)
                    {
                        s.StreamObject(pu);
                    }
                pu = Powerups[1];
                using (var bm = s.EnterCursorBookmarkOpt("SpeedBoost", pu, pu_is_not_default)) if (bm.IsNotNull)
                    {
                        s.StreamObject(pu);
                    }
                pu = Powerups[2];
                using (var bm = s.EnterCursorBookmarkOpt("Overshield", pu, pu_is_not_default)) if (bm.IsNotNull)
                    {
                        s.StreamObject(pu);
                    }
                pu = Powerups[3];
                using (var bm = s.EnterCursorBookmarkOpt("Custom", pu, pu_is_not_default)) if (bm.IsNotNull)
                    {
                        s.StreamObject(pu);
                    }
            }
        }
Exemplo n.º 12
0
 static void SerializeLanguages <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Languages"))
         s.StreamElements("Language", gLanguageNames);
 }
Exemplo n.º 13
0
 protected virtual void SerializeImpl <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Base"))
         s.StreamObject(BaseVariant);
 }
Exemplo n.º 14
0
        public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
        {
            base.Serialize(s);

            using (s.EnterCursorBookmark("Powerups"))
            {
                Predicate <PlayerTraits> traits_are_changed = obj => !obj.IsUnchanged;

                using (var bm = s.EnterCursorBookmarkOpt("Red", Red, traits_are_changed)) if (bm.IsNotNull)
                    {
                        s.StreamAttribute("duration", ref RedDuration);
                        s.StreamObject(Red);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("Blue", Blue, traits_are_changed)) if (bm.IsNotNull)
                    {
                        s.StreamAttribute("duration", ref BlueDuration);
                        s.StreamObject(Blue);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("Yellow", Yellow, traits_are_changed)) if (bm.IsNotNull)
                    {
                        s.StreamAttribute("duration", ref YellowDuration);
                        s.StreamObject(Yellow);
                    }
            }
        }
Exemplo n.º 15
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            bool   should_stream = true;
            string root_name     = Params.GetOptionalRootName();
            var    xs            = s.GetSerializerInterface();

            if (s.IsReading)             // If the stream doesn't have the expected element, don't try to stream
            {
                should_stream = root_name == null || s.ElementsExists(root_name);
            }
            else if (s.IsWriting)
            {
                should_stream = List != null && List.IsEmpty == false;
            }

            if (should_stream)
            {
                using (s.EnterCursorBookmark(root_name))
                {
                    if (s.IsReading)
                    {
                        ReadNodes(s, xs);
                    }
                    else if (s.IsWriting)
                    {
                        WriteNodes(s, xs);
                    }
                }
            }
        }
Exemplo n.º 16
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            var build = s.IsWriting ? BuildHandle : Engine.EngineBuildHandle.None;

            using (s.EnterCursorBookmark("Game"))
                Engine.EngineBuildHandle.Serialize(s, ref build);
            if (s.IsReading)
            {
                // #TODO_BLAM: validate build handle?
                BuildHandle = build;
            }

            s.StreamElementEnum("Content", ref Type);

            s.StreamElement("TimeStamp", ref Timestamp);
            s.WriteComment(this, _this => _this.Timestamp.ToString(System.Globalization.CultureInfo.InvariantCulture));

            s.StreamElement("SessionSalt", ref SessionSalt, NumeralBase.Hex);
            SerializeActivity(s);
            s.StreamElementEnum("Engine", ref EngineType);
            s.StreamAttributeOpt("unk4_", ref unk4, Predicates.IsNotNone);
            s.StreamAttributeOpt("megaloCategory", ref MegaloCategoryIndex, Predicates.IsNotNone);
            s.StreamAttributeOpt("engineIcon", ref EngineIconIndex, Predicates.IsNotNone);
            s.StreamAttribute("unkA_", ref unkA);
            s.StreamAttribute("unkB_", ref unkB);
            s.StreamElement("Author", ref Author);
        }
Exemplo n.º 17
0
 public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark(kXmlRoot))
         StreamHPBarData(s);
 }
Exemplo n.º 18
0
        public static void Write <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, BListXmlParams p,
                                                 Collections.IProtoEnumWithUndefined undefined)
            where TDoc : class
            where TCursor : class
        {
            if (p.DoNotWriteUndefinedData)
            {
                return;
            }

            if (undefined.MemberUndefinedCount == 0)
            {
                return;
            }

            string element_name = "Undefined" + p.ElementName;

            foreach (string str in undefined.UndefinedMembers)
            {
                using (s.EnterCursorBookmark(element_name))
                {
                    string temp = str;
                    p.StreamDataName(s, ref temp);
                }
            }
        }
Exemplo n.º 19
0
 protected void SerializeMiscOptions <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Misc"))
         s.StreamObject(OptionsMisc);
 }
Exemplo n.º 20
0
        void Read <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            string[] names = kInfo.kValuesEnum.GetEnumNames();

            foreach (var element in s.ElementsByName(kEntryElementName))
            {
                using (s.EnterCursorBookmark(element))
                {
                    string name = null;
                    s.ReadAttribute(kEntryAttrKeyName, ref name);

                    int name_index = Array.IndexOf(names, name);
                    if (name_index < 0)
                    {
                        s.ThrowReadException(new System.IO.InvalidDataException("Invalid name value: " + name));
                    }

                    mArray[name_index] = 0.0f;
                    if (s.ReadAttributeOpt(kEntryAttrValueName, ref mArray[name_index]))                     // #HACK_BLAM: IgnoreWritePredicates hack! didn't used to be Opt
                    {
                        mValidFlags |= 1U << name_index;
                    }
                }
            }
        }
Exemplo n.º 21
0
        void Write <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s,
                                   bool embedValues)
            where TDoc : class
            where TCursor : class
        {
            bool multiple_params  = mValueIds.Length > 1;
            bool write_extra_info = s.IsWriting && model.TagElementStreamSerializeFlags.HasParamFlags();

            for (int x = 0; x < mValueIds.Length; x++)
            {
                using (s.EnterCursorBookmark("Param"))
                {
                    if (write_extra_info)
                    {
                        ProtoData.ParameterList[x].WriteExtraModelInfo(model.Database, s, multiple_params, model.TagElementStreamSerializeFlags);
                    }

                    Contract.Assert(mValueIds[x].IsNotNone());
                    if (embedValues)
                    {
                        MegaloScriptValueBase.SerializeValueForEmbed(model, s, ref mValueIds[x]);
                    }
                    else
                    {
                        s.StreamCursor(ref mValueIds[x]);
                    }
                }
            }
        }
Exemplo n.º 22
0
 protected void SerializeReferences <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
     where TDoc : class
     where TCursor : class
 {
     using (s.EnterCursorBookmark("Elements"))
         References.Serialize(model, s);
 }
Exemplo n.º 23
0
            static void ReadElements(IO.TagElementStream <TDoc, TCursor, string> s, IEnumerable <TCursor> elements,
                                     ActiveList <T> list,
                                     TContext ctxt, Func <IO.TagElementStream <TDoc, TCursor, string>, TContext, T> ctor,
                                     Func <TContext, TagElementStreamReadMode> getReadMode)
            {
                var read_mode = getReadMode == null
                                        ? TagElementStreamReadMode.PostConstructor
                                        : getReadMode(ctxt);

                foreach (var node in elements)
                {
                    using (s.EnterCursorBookmark(node))
                    {
                        var value = ctor(s, ctxt);
                        if (read_mode == TagElementStreamReadMode.PostConstructor)
                        {
                            value.Serialize(s);
                        }

                        int index = list.Description.ObjectToIndex(value);
                        list.AddExplicit(value, index);

                        if (read_mode == TagElementStreamReadMode.PostAdd)
                        {
                            value.Serialize(s);
                        }
                    }
                }
            }
Exemplo n.º 24
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.EmbedObjects) != 0)
            {
                using (s.EnterCursorBookmark("VT"))                 // have to nest or MegaloScriptModelObjectHandle will overwrite our Param ID with the VT's
                    MegaloScriptModelObjectHandle.SerializeForEmbed(s, model, ref mVirtualTriggerHandle);
            }
            else
            {
                if (s.IsReading)
                {
                    int id = TypeExtensions.kNone; s.ReadCursor(ref id);
                    if (id < 0)
                    {
                        throw new System.IO.InvalidDataException(string.Format(Util.InvariantCultureInfo,
                                                                               "VirtualTrigger value #{0} has an invalid value {1}", Id, id));
                    }

                    mVirtualTriggerHandle = model.VirtualTriggers[id].Handle;
                }
                else
                {
                    s.WriteCursor(VirtualTriggerHandle.Id);
                }
            }
        }
Exemplo n.º 25
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            using (s.EnterUserDataBookmark(this))
            {
                s.StreamAttributeOpt("name", this, obj => EcfName, Predicates.IsNotNullOrEmpty);
                s.StreamAttributeOpt("ext", this, obj => EcfFileExtension, Predicates.IsNotNullOrEmpty);

                using (s.EnterCursorBookmark("Header"))
                {
                    s.StreamAttribute("id", this, obj => HeaderId, NumeralBase.Hex);
                    s.StreamAttributeOpt("ChunkExtraDataSize", this, obj => ChunkExtraDataSize, Predicates.IsNotZero, NumeralBase.Hex);
                }

                using (var bm = s.EnterCursorBookmarkOpt("Chunks", Chunks, Predicates.HasItems))
                    s.StreamableElements("C", Chunks, obj => obj.HasPossibleFileData);
            }

            // #NOTE leaving this as an exercise for the caller instead, so they can yell when something is culled
                        #if false
            if (s.IsReading)
            {
                CullChunksPossiblyWithoutFileData();
            }
                        #endif
        }
Exemplo n.º 26
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            using (s.EnterCursorBookmark("Object"))
                base.SerializeValue(model, s);

            model.Database.ObjectReferenceWithPlayerVarIndex.StreamPlayerVarIndex(s, ref mPlayerVarIndex,
                                                                                  Var.Type, model);
        }
Exemplo n.º 27
0
        public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
        {
            var xs = s.GetSerializerInterface();

            using (s.EnterCursorBookmark("Attributes"))
            {
                base.Serialize(s);

                using (var bm = s.EnterCursorBookmarkOpt("Cost", Cost, x => x.HasNonZeroItems)) if (bm.IsNotNull)
                    {
                        XML.XmlUtil.SerializeCostHack(s, Cost);
                    }
                XML.XmlUtil.Serialize(s, DynamicCosts, BPowerDynamicCost.kBListXmlParams);
                XML.XmlUtil.Serialize(s, TargetEffectiveness, BPowerTargetEffectiveness.kBListXmlParams);
                XML.XmlUtil.Serialize(s, Populations, BPopulation.kBListXmlParamsSingle_LowerCase);
                s.StreamElementOpt("UIRadius", ref mUIRadius, Predicates.IsNotZero);
                s.StreamElementEnumOpt("PowerType", ref mPowerType, e => e != BPowerType.Invalid);
                s.StreamElementOpt("AutoRecharge", ref mAutoRecharge, Predicates.IsNotZero);
                s.StreamElementOpt("UseLimit", ref mUseLimit, Predicates.IsNotZero);
                XML.XmlUtil.Serialize(s, Flags, XML.BBitSetXmlParams.kFlagsAreElementNamesThatMeanTrue);
                XML.XmlUtil.Serialize(s, Flags2, XML.BBitSetXmlParams.kFlagsAreElementNamesThatMeanTrue);
                s.StreamElementOpt("Icon", ref mIconTextureName, Predicates.IsNotNullOrEmpty);
                s.StreamElements("IconLocation", IconLocations, xs, StreamIconLocation);
                s.StreamElements("TechPrereq", TechPrereqs, xs, XML.BDatabaseXmlSerializerBase.StreamTechID);
                s.StreamElementEnumOpt("Action", ref mActionType, BProtoAction.kNotInvalidActionType);
                s.StreamElementEnumOpt("Minigame", ref mMinigameType, e => e != BMinigameType.None);
                s.StreamElementOpt("CameraZoomMin", ref mCameraZoomMin, Predicates.IsNotZero);
                s.StreamElementOpt("CameraZoomMax", ref mCameraZoomMax, Predicates.IsNotZero);
                s.StreamElementOpt("CameraPitchMin", ref mCameraPitchMin, Predicates.IsNotZero);
                s.StreamElementOpt("CameraPitchMax", ref mCameraPitchMax, Predicates.IsNotZero);
                s.StreamElementOpt("CameraEffectIn", ref mCameraEffectIn, Predicates.IsNotNullOrEmpty);
                s.StreamElementOpt("CameraEffectOut", ref mCameraEffectOut, Predicates.IsNotNullOrEmpty);
                s.StreamElementOpt("MinDistanceToSquad", ref mMinDistanceToSquad, PhxPredicates.IsNotInvalid);
                s.StreamElementOpt("MaxDistanceToSquad", ref mMaxDistanceToSquad, PhxPredicates.IsNotInvalid);
                using (var bm = s.EnterCursorBookmarkOpt("ShowTargetHighlight", this, x => x.HasShowTargetHighlightData)) if (bm.IsNotNull)
                    {
                        xs.StreamDBID(s, "ObjectType", ref mShowTargetHighlightObjectType, DatabaseObjectKind.ObjectType, xmlSource: XML.XmlUtil.kSourceAttr);
                        s.StreamAttributeEnumOpt("Relation", ref mShowTargetHighlightRelation, e => e != BRelationType.Any);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("ChildObjects", ChildObjectIDs, Predicates.HasItems)) if (bm.IsNotNull)
                    {
                        s.StreamElements("Object", ChildObjectIDs, xs, XML.BDatabaseXmlSerializerBase.StreamObjectID);
                    }
                using (var bm = s.EnterCursorBookmarkOpt("BaseDataLevel", this, x => x.BaseDataLevel != null)) if (bm.IsNotNull)
                    {
                        if (s.IsReading)
                        {
                            mBaseDataLevel = new BProtoPowerDataLevel();
                        }

                        BaseDataLevel.Serialize(s);
                    }
                XML.XmlUtil.Serialize(s, LevelData, BProtoPowerDataLevel.kBListExplicitIndexXmlParams);
            }
            s.StreamElementOpt("TriggerScript", ref mTriggerScript, Predicates.IsNotNullOrEmpty);
            s.StreamElementOpt("CommandTriggerScript", ref mCommandTriggerScript, Predicates.IsNotNullOrEmpty);
        }
Exemplo n.º 28
0
 protected override void SerializeExternBody <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
 {
     using (s.EnterCursorBookmark("BuildFiles"))
     {
         s.StreamableElements("Files",
                              mBuildProtoFiles, this.RootBuildHandle,
                              Blam.Engine.EngineBuildHandle.SerializeWithBaseline);
     }
 }
Exemplo n.º 29
0
        protected override void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s)
        {
            bool reading = s.IsReading;

            model.MegaloVariant.SerializeStringTableIndex(s, "stringIndex", ref mStringIndex);

            if (!s.StreamAttributeOpt("tokenCount", ref mTokenCount, Predicates.IsNotZero) &&
                reading)
            {
                TokenCount = 0;
            }

            if (reading)
            {
                ValidateTokenCount();

                int max_tokens = MaxTokens;
                if (max_tokens >= 1)
                {
                    Token0.Nullify();
                }
                if (max_tokens >= 2)
                {
                    Token1.Nullify();
                }
                if (max_tokens >= 3)
                {
                    Token2.Nullify();
                }
            }

            if (TokenCount >= 1)
            {
                using (s.EnterCursorBookmark("Token0")) Token0.Serialize(model, s);
            }
            if (TokenCount >= 2)
            {
                using (s.EnterCursorBookmark("Token1")) Token1.Serialize(model, s);
            }
            if (TokenCount >= 3)
            {
                using (s.EnterCursorBookmark("Token2")) Token2.Serialize(model, s);
            }
        }
Exemplo n.º 30
0
        protected override void SerializeExternBody <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
        {
            IO.TagElementStreamDefaultSerializer.Serialize(s, ref mGroupTags,
                                                           "BlobGroupTags");

            using (s.EnterCursorBookmark("BlobGroups"))
            {
                s.StreamableElements("BlobGroup", mGroups, this, SerializeGroupsKey);
            }
        }