public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); s.StreamAttributeOpt("groupTag", ref GroupTag, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("tagName", ref TagName, Predicates.IsNotNullOrEmpty); }
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 }
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); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); s.StreamAttributeOpt("hidden", ref IsHidden, Predicates.IsTrue); s.StreamAttributeOpt("runtime", ref IsRuntime, Predicates.IsTrue); }
// #NOTE the attributes here should match the ones used in EcfChunk's code public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var ecf_expander = s.Owner as EcfFileExpander; if (s.IsReading) { Parent = (EcfFileDefinition)s.UserData; } s.StreamAttribute("id", this, obj => Id, NumeralBase.Hex); s.StreamAttributeOpt("align", this, obj => AlignmentBit, b => b != EcfChunk.kDefaultAlignmentBit, NumeralBase.Hex); if (s.StreamAttributeEnumOpt("Compression", this, obj => CompressionType, e => e != EcfCompressionType.Stored)) { // #NOTE DeflateRaw requires the decompressed size to be known somewhere, and generic ECF files do not store such info // Only available in ERAs if (CompressionType == EcfCompressionType.DeflateRaw) { s.ThrowReadException(new InvalidDataException(CompressionType + " is not supported in this context")); } } if (s.IsReading) { ReadResourceFlags(s); } else if (s.IsWriting) { WriteResourceFlags(s); } s.StreamAttributeOpt("Path", this, obj => FilePath, Predicates.IsNotNullOrEmpty); // Don't try to write the file bytes bool try_to_serialize_file_bytes = s.IsReading || FilePath.IsNullOrEmpty(); if (ecf_expander != null) { if (!ecf_expander.ExpanderOptions.Test(EcfFileExpanderOptions.DontSaveChunksToFiles)) { try_to_serialize_file_bytes = true; } } if (try_to_serialize_file_bytes) { if (!s.StreamCursorBytesOpt(this, obj => FileBytes)) { if (FilePath.IsNullOrEmpty()) { s.ThrowReadException(new InvalidDataException("Expect Path attribute or file hex bytes")); } } } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("timeStamp", ref TimeStamp); s.StreamAttributeOpt("xuid", ref Xuid, Predicates.IsNotZero, NumeralBase.Hex); s.StreamAttributeOpt("onlineId", ref IsOnlineId, Predicates.IsTrue); s.StreamAttributeOpt("name", ref Name, Predicates.IsNotNullOrEmpty); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); s.StreamAttributeOpt("desc", ref DescriptionId, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("header", ref HeaderId, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("help", ref HelpId, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("icon", ref IconId, Predicates.IsNotNullOrEmpty); }
protected virtual void SerializeTimes <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("respawn", ref RespawnTime /*, v=>v!=5*/); // #HACK_BLAM: default respawn times differ in Reach and H4, so leaving predicate out for now s.StreamAttributeOpt("suicide", ref SuicideTime, v => v != TypeExtensionsBlam.kUsualDefaultRespawnTimeInSeconds); s.StreamAttributeOpt("betrayal", ref BetrayalTime, v => v != TypeExtensionsBlam.kUsualDefaultRespawnTimeInSeconds); s.StreamAttributeOpt("respawnGrowth", ref RespawnGrowthTime, Predicates.IsNotZero); s.StreamAttributeOpt("initialLoadoutSelection", ref InitialLoadoutSelectionTime, v => v != 10); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); using (var bm = s.EnterCursorBookmarkOpt("WeaponSkins", this, obj => !obj.WeaponSkinsAreUnchanged)) if (bm.IsNotNull) { s.StreamAttributeOpt("primary", ref PrimaryWeaponSkin, Predicates.IsNotZero); s.StreamAttributeOpt("secondary", ref SecondaryWeaponSkin, Predicates.IsNotZero); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("weight", ref Weight, Predicates.IsNotZero); if (!s.StreamAttributeOpt("name", ref Name, Predicates.IsNotNullOrEmpty)) { Name = ""; } }
protected virtual void SerializeOverrides <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("primaryColor", ref PrimaryColorOverride, v => v != uint.MaxValue, NumeralBase.Hex); s.StreamAttributeOpt("secondaryColor", ref SecondaryColorOverride, v => v != uint.MaxValue, NumeralBase.Hex); s.StreamAttributeOpt("textColor", ref TextColorOverride, v => v != uint.MaxValue, NumeralBase.Hex); s.StreamAttributeEnumOpt("model", ref ModelOverride, e => e != GameOptionsSingleTeamModelOverride.Spartan); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("rating", ref mRating, PhxPredicates.IsNotOne); s.StreamCursor(ref mDamagePercentage); s.StreamAttributeOpt("reflectDamageFactor", ref mReflectDamageFactor, Predicates.IsNotZero); s.StreamAttributeOpt("bowlable", ref mBowlable, Predicates.IsTrue); s.StreamAttributeOpt("rammable", ref mRammable, Predicates.IsTrue); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamCursor(ref mName); s.StreamAttribute("ikRange", ref mIKRange); s.StreamAttribute("linkCount", ref mLinkCount); s.StreamAttributeOpt("x", ref mAxisPositioning.X, Predicates.IsNotZero); s.StreamAttributeOpt("z", ref mAxisPositioning.Z, Predicates.IsNotZero); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeEnumOpt("LeftRumbleType", ref mLeftRumbleType, e => e != BRumbleType.None); s.StreamAttributeEnumOpt("RightRumbleType", ref mRightRumbleType, e => e != BRumbleType.None); s.StreamAttributeOpt("Duration", ref mDuration, Predicates.IsNotZero); s.StreamAttributeOpt("LeftStrength", ref mLeftStrength, Predicates.IsNotZero); s.StreamAttributeOpt("RightStrength", ref mRightStrength, Predicates.IsNotZero); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("sizeX", ref mSize.X, f => f != 2.0f); s.StreamAttributeOpt("sizeZ", ref mSize.Z, f => f != 2.0f); s.StreamAttributeOpt("timeFullyOpaque", ref mTimeFullyOpaque, f => f != 5.0f); s.StreamAttributeOpt("fadeOutTime", ref mFadeOutTime, f => f != 10.0f); s.StreamAttributeEnumOpt("orientation", ref mOrientation, e => e != OrientationType.Random); s.StreamCursor(ref mTextureName); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("playerRequisitionFrequencySeconds", ref PlayerRequisitionFrequencySeconds, Predicates.IsNotZero); s.StreamAttributeOpt("initialGameCurrency", ref InitialGameCurrency, Predicates.IsNotZero); using (var bm = s.EnterCursorBookmarkOpt("Items", RequisitionItems, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("entry", RequisitionItems); } }
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 => PkgName, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("alignment", this, obj => Alignment, Predicates.IsNotZero); using (var bm = s.EnterCursorBookmarkOpt("Files", FileNames, Predicates.HasItems)) s.StreamElements("File", FileNames); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { if (!s.StreamAttributeOpt("useDefault", ref UseDefault, Predicates.IsFalse)) { NameIndex = -1; } else { s.StreamAttributeOpt("nameIndex", ref NameIndex); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("bitLength", ref BitLength); if (!NoEncoding) { s.StreamAttribute("min", ref Min); s.StreamAttribute("max", ref Max); s.StreamAttributeOpt("isSigned", ref IsSigned, Predicates.IsTrue); s.StreamAttributeOpt("flag1", ref Flag1, Predicates.IsFalse); } s.StreamAttribute("name", ref Name); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var xs = s.GetSerializerInterface(); s.StreamAttributeEnumOpt("Type", ref mType, e => e != ChildObjectType.Object); xs.StreamDBID(s, XML.XmlUtil.kNoXmlName, ref mID, TypeObjectKind, isOptional: false, xmlSource: XML.XmlUtil.kSourceCursor); s.StreamAttributeOpt("AttachBone", ref mAttachBone, Predicates.IsNotNullOrEmpty); s.StreamBVector("Offset", ref mOffset, xmlSource: XML.XmlUtil.kSourceAttr); s.StreamAttributeOpt("Rotation", ref mRotation, Predicates.IsNotZero); xs.StreamDBID(s, "UserCiv", ref mUserCivID, DatabaseObjectKind.Civ, xmlSource: XML.XmlUtil.kSourceAttr); }
protected virtual void SerializeImpl <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterCursorBookmark("SerializeFlags")) s.StreamCursorEnum(ref TagElementStreamSerializeFlags, true); s.StreamAttribute("encoding", ref mEncodingVersion, NumeralBase.Hex); s.StreamAttribute("version", ref EngineVersion); // Must come first. Most of the other variant data contains string references SerializeLocaleStrings(s); using (var bm = s.EnterCursorBookmarkOpt("PlayerTraits", PlayerTraits, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("entry", PlayerTraits, this, _this => _this.NewMegaloPlayerTraits()); } using (var bm = s.EnterCursorBookmarkOpt("UserDefinedOptions", UserDefinedOptions, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("entry", UserDefinedOptions); } if (!s.StreamAttributeOpt("engineIcon", ref EngineIconIndex, Predicates.IsNotNone)) { EngineIconIndex = TypeExtensions.kNone; } if (!s.StreamAttributeOpt("engineCategory", ref EngineCategory, Predicates.IsNotNone)) { EngineCategory = TypeExtensions.kNone; } using (var bm = s.EnterCursorBookmarkOpt("MapPermissions", MapPermissions, mp => !mp.IsDefault)) if (bm.IsNotNull) { s.StreamObject(MapPermissions); } using (var bm = s.EnterCursorBookmarkOpt("PlayerRatingParams", PlayerRatingParameters, prp => !prp.IsDefault)) if (bm.IsNotNull) { s.StreamObject(PlayerRatingParameters); } else { PlayerRatingParameters.RevertToDefault(); } s.StreamAttributeOpt("scoreToWinRound", ref ScoreToWinRound, Predicates.IsNotZero); SerializeOptionToggles(s); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("_locID", ref mID); s.StreamAttributeEnumOpt("category", ref mCategory, e => e != LocStringCategory.None); s.StreamAttributeOpt("scenario", ref mScenario, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("subtitle", ref mIsSubtitle, Predicates.IsTrue); s.StreamAttributeOpt("Update", ref mIsUpdate, Predicates.IsTrue); s.StreamAttributeOpt("_mouseKeyboard", ref mMouseKeyboardID, Predicates.IsNotNone); s.StreamAttributeOpt("originally", ref mOriginalID, Predicates.IsNotNullOrEmpty); if (s.IsReading || mText.IsNotNullOrEmpty()) { s.StreamCursor(ref mText); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var db = s.Owner as MegaloScriptDatabase; bool reading = s.IsReading; s.StreamAttributeEnum("type", ref Type); s.StreamAttribute("name", ref Name); bool read_only = IsReadOnly; s.StreamAttributeOpt("readonly", ref read_only, Predicates.IsTrue); if (db.SerializeValueTypeReference(s, "paramTypeEnum", ref EnumValueType, isOptional: true)) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.HasDataType; } if (db.SerializeValueTypeReference(s, "paramValueType", ref ValueType, isOptional: true)) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.HasDataValue; s.StreamAttribute("paramValueName", ref ValueName); } if (reading) { if (read_only) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.Readonly; } } }
public bool StreamStringID <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string xmlName, ref int value, IO.TagElementNodeType xmlSource = XmlUtil.kSourceElement) where TDoc : class where TCursor : class { Contract.Requires(xmlSource.RequiresName() == (xmlName != XML.XmlUtil.kNoXmlName)); bool was_streamed = false; if (xmlSource == XmlUtil.kSourceElement) { was_streamed = s.StreamElementOpt(xmlName, ref value, Predicates.IsNotNone); } else if (xmlSource == XmlUtil.kSourceAttr) { was_streamed = s.StreamAttributeOpt(xmlName, ref value, Predicates.IsNotNone); } else if (xmlSource == XmlUtil.kSourceCursor) { was_streamed = true; s.StreamCursor(ref value); } if (s.IsReading) { if (value.IsNotNone()) { Database.AddStringIDReference(value); } } return(was_streamed); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var model = (Model.MegaloScriptModel)s.Owner; model.MegaloVariant.SerializeStringTableIndexOpt(s, "labelIndex", ref mLabelStringIndex); SerializeCodeName(s); s.StreamAttributeEnumOpt("params", ref mValidParameters, f => f != 0, true); s.StreamAttributeOpt("min", ref mMinimum, Predicates.IsNotZero); if (HasObjectTypeIndex) { Model.MegaloScriptIndexValue.SerializeValue(model, s, model.Database.ObjectTypeIndexValueType, ref mObjectTypeIndex, IO.TagElementNodeType.Element, "ObjectType"); } if (HasTeam) { Model.MegaloScriptEnumValue.SerializeValue(model, s, model.Database.TeamDesignatorValueType, ref mTeam, IO.TagElementNodeType.Element, "Team"); } if (HasNumeric) { s.StreamElement("Numeric", ref mNumeric); } }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { s.StreamAttributeEnumOpt("flags", ref Flags, flags => flags != 0, true); if (!s.StreamAttributeOpt("infinityMissionId", ref InfinityMissionId, Predicates.IsNotNone)) { InfinityMissionId = TypeExtensions.kNone; } SerializeContentHeader(s); SerializeMiscOptions(s); using (var bm = s.EnterCursorBookmarkOpt("Prototype", OptionsPrototype, obj => !obj.IsEmpty)) if (bm.IsNotNull) { s.StreamObject(OptionsPrototype); } SerializRespawnOptions(s); SerializeSocialOptions(s); SerializMapOverrides(s); using (var bm = s.EnterCursorBookmarkOpt("Requisitions", OptionsRequisitions, obj => !obj.IsDefault)) if (bm.IsNotNull) { s.StreamObject(OptionsRequisitions); } SerializeTeams(s); SerializeLoadoutOptions(s); using (var bm = s.EnterCursorBookmarkOpt("Ordnance", OrdnanceOptions, obj => !obj.IsDefault)) if (bm.IsNotNull) { s.StreamObject(OrdnanceOptions); } else if (s.IsReading) { OrdnanceOptions.RevertToDefault(); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { if (!s.StreamAttributeOpt("name", ref mCodeName, Predicates.IsNotNullOrEmpty)) { mCodeName = ""; } using (var bm = s.EnterCursorBookmarkOpt("String", this, obj => obj.JustEnglish)) if (bm.IsNotNull) { LanguageRegistry.CodeExpectsEnglishFirst(); int k_english_index = mLanguageTable.EnglishGameLangaugeHandle.GameIndex; s.StreamCursor(ref mLanguageStrings[k_english_index]); if (s.IsReading) { // empty cursor text returns null, at least in the XML implementation if (mLanguageStrings[k_english_index] == null) { mLanguageStrings[k_english_index] = ""; } for (int x = 1; x < mLanguageStrings.Length; x++) { mLanguageStrings[x] = mLanguageStrings[k_english_index]; } } } else { SerializeLanguages(s); } }
internal bool SerializeValueTypeReference <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string attributeName, ref MegaloScriptValueType type, bool isOptional = false) where TDoc : class where TCursor : class { bool streamed = true; bool reading = s.IsReading; string type_name = reading ? null : ValueTypeNames[type.NameIndex]; if (isOptional) { streamed = s.StreamAttributeOpt(attributeName, ref type_name, ValueTypeNameIsNotNone); if (!streamed && reading) { type_name = kNoValueTypeName; } } else { s.StreamAttribute(attributeName, ref type_name); } if (reading) { type = GetValueType(type_name); } return(streamed); }
public virtual void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeOpt("designatorSwitchType", ref DesignatorSwitchType, v => v != 2); s.StreamAttributeEnumOpt("model", ref ModelOverride, e => e != GameOptionsTeamOptionsModelOverride.Default); SerializeTeams(s); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamCursorEnum(ref mType); s.StreamAttributeEnumOpt("target", ref mTarget, e => e != BCollectibleSkullTarget.None); s.StreamAttributeOpt("value", ref mValue, PhxPredicates.IsNotInvalid); }