Exemplo n.º 1
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.º 2
0
        public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s)
            where TDoc : class
            where TCursor : class
        {
            bool reading = s.IsReading;

            #region Internal
            if (reading)
            {
                int max_trigger_groups = 0, max_virtual_triggers = 0, max_script_values = 0
                ;

                s.ReadElement(kMaxTriggerGroupsElementName, ref max_trigger_groups);
                s.ReadElementOpt(kMaxVirtualTriggersElementName, ref max_virtual_triggers);
                s.ReadElement(kMaxScriptValuesElementName, ref max_script_values);

#if false // #TODO_BLAM
                TriggerGroupsDesc = Collections.ActiveListDesc <Editor.LogicalGroupUI> .
                                    CreateForNullData(max_trigger_groups, fixedLength : false);
#endif
                VirtualTriggersDesc = Collections.ActiveListDesc <Model.MegaloScriptVirtualTrigger> .
                                      CreateForNullData(max_virtual_triggers, fixedLength : false);

                VirtualTriggersDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;

                ScriptValuesDesc = Collections.ActiveListDesc <Model.MegaloScriptValueBase> .
                                   CreateForNullData(max_script_values, fixedLength : false);

                ScriptValuesDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;
            }
            else
            {
//				s.WriteElement(kMaxTriggerGroupsElementName, TriggerGroupsDesc.Capacity);
                s.WriteElement(kMaxVirtualTriggersElementName, VirtualTriggersDesc.Capacity);
                s.WriteElement(kMaxScriptValuesElementName, ScriptValuesDesc.Capacity);
            }
            #endregion

            #region Scripting
            s.StreamElementEnum("EntryPoints", ref SupportedEntryPoints, true);
            s.StreamElementOpt("SupportsVirtualTriggers", ref SupportsVirtualTriggers);
            s.StreamElementOpt("StreamEntryPointIndexAsPointer", ref StreamEntryPointIndexAsPointer);
            s.StreamElementOpt("StreamConditionsAndActionsRefsAsRefs", ref StreamConditionsAndActionsRefsAsRefs);

            ListLimitTraits.SerializeViaElement(s, "MaxConditions", ref Conditions);
            ListLimitTraits.SerializeViaElement(s, "MaxActions", ref Actions);
            ListLimitTraits.SerializeViaElement(s, "MaxTriggers", ref Triggers);

            if (reading)
            {
                UnionGroupsDesc = Collections.ActiveListDesc <Model.MegaloScriptUnionGroup> .
                                  CreateForNullData(Conditions.MaxCount);

                UnionGroupsDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;

                ConditionsDesc = Collections.ActiveListDesc <Model.MegaloScriptCondition> .
                                 CreateForNullData(Conditions.MaxCount);

                ConditionsDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;

                ActionsDesc = Collections.ActiveListDesc <Model.MegaloScriptAction> .
                              CreateForNullData(Actions.MaxCount);

                ActionsDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;

                TriggersDesc = Collections.ActiveListDesc <Model.MegaloScriptTrigger> .
                               CreateForNullData(Triggers.MaxCount);

                TriggersDesc.ObjectToIndex = Model.MegaloScriptModelObject.kObjectToIndex;
            }
            #endregion

            #region Static
            ListLimitTraits.SerializeViaElement(s, "NumberOfGameEngineOptions", ref GameEngineOptions);
            ListLimitTraits.SerializeViaElement(s, "MaxMultiplayerObjectTypes", ref MultiplayerObjectTypes);
            ListLimitTraits.SerializeViaElement(s, "MaxMegaloStringIds", ref MegaloStringIds);
            ListLimitTraits.SerializeViaElement(s, "MaxMegaloEngineSounds", ref MegaloEngineSounds);
            ListLimitTraits.SerializeViaElement(s, "MaxGameIncidentTypes", ref GameIncidentTypes);
            ListLimitTraits.SerializeViaElement(s, "MaxMegaloHudWidgetIcons", ref MegaloHudWidgetIcons);
            ListLimitTraits.SerializeViaElement(s, "MaxGameEngineIcons", ref GameEngineIcons);
            ListLimitTraits.SerializeViaElement(s, "MaxGameMedals", ref GameMedals);
            ListLimitTraits.SerializeViaElementOpt(s, "MaxGameOrdnanceTypes", ref GameOrdnanceTypes);

            ListLimitTraits.SerializeViaElement(s, "NumberOfEngineCategories", ref EngineCategories);
            #endregion

            #region Variant
            ListLimitTraits.SerializeViaElement(s, "NumberOfLoadoutPalettes", ref LoadoutPalettes);
            ListLimitTraits.SerializeViaElement(s, "MaxUserDefinedOptions", ref UserDefinedOptions);
            ListLimitTraits.SerializeViaElement(s, "MaxUserDefinedOptionValues", ref UserDefinedOptionValues);
            ListLimitTraits.SerializeViaElement(s, "MaxVariantStrings", ref VariantStrings);
            ListLimitTraits.SerializeViaElementOpt(s, "MaxLoadouts", ref Loadouts);
            ListLimitTraits.SerializeViaElement(s, "MaxPlayerTraits", ref PlayerTraits);
            ListLimitTraits.SerializeViaElement(s, "MaxGameStatistics", ref GameStatistics);
            ListLimitTraits.SerializeViaElement(s, "MaxHudWidgets", ref HudWidgets);
            ListLimitTraits.SerializeViaElement(s, "MaxObjectFilters", ref ObjectFilters);

            ListLimitTraits.SerializeViaElementOpt(s, "MaxGameObjectFilters", ref GameObjectFilters);
            #endregion
        }