public MegaloScriptObjectReferenceWithPlayerVarIndexValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.ObjectReferenceWithPlayerVarIndex); Var = MegaloScriptVariableReferenceData.Object; PlayerVarIndex = TypeExtensions.kNone; }
public MegaloScriptIndexValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Index); if (valueType.IndexTraits != Proto.MegaloScriptValueIndexTraits.Reference) { mValue = -1; } }
public MegaloScriptEnumValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Enum); if (valueType.EnumTraits == Proto.MegaloScriptValueEnumTraits.HasNoneMember) { mValue = -1; } }
internal static void SerializeValue(MegaloScriptModel model, IO.BitStream s, MegaloScriptValueType valueType, ref int value) { if (valueType.EnumTraits == Proto.MegaloScriptValueEnumTraits.HasNoneMember) { s.StreamNoneable(ref value, valueType.BitLength); } else { s.Stream(ref value, valueType.BitLength); } if (s.IsReading && !model.EnumIndexIsValid(valueType, value)) { throw new System.IO.InvalidDataException(string.Format("{0} doesn't have a #{1} member", model.Database.Enums[valueType.EnumIndex].Name, value)); } }
static void SerializeTriggerReferenceValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s, MegaloScriptValueType valueType, ref int value) where TDoc : class where TCursor : class { var handle = s.IsWriting ? new MegaloScriptModelObjectHandle(MegaloScriptModelObjectType.Trigger, value) : MegaloScriptModelObjectHandle.Null; if (s.IsWriting) { Contract.Assert(model.Triggers[handle.Id].TriggerType == MegaloScriptTriggerType.InnerLoop); } using (s.EnterCursorBookmark("T")) // have to nest or MegaloScriptModelObjectHandle will overwrite our Param ID with the Trigger's MegaloScriptModelObjectHandle.SerializeForEmbed(s, model, ref handle); if (s.IsReading) { value = handle.Id; } }
public MegaloScriptTokensValue(MegaloScriptModel model, MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Tokens); int max_tokens = valueType.MaxTokens; if (max_tokens >= 1) { Token0 = model.NewToken(); } if (max_tokens >= 2) { Token1 = model.NewToken(); } if (max_tokens >= 3) { Token2 = model.NewToken(); } }
internal static void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s, MegaloScriptValueType valueType, ref uint value, IO.TagElementNodeType nodeType = IO.TagElementNodeType.Text, string nodeName = null) where TDoc : class where TCursor : class { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Flags); if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.UseEnumNames) != 0) { var id_resolving_ctxt = new Proto.MegaloScriptEnum.FlagsNameResolvingContext(model.Database, valueType); var id_resolver = Proto.MegaloScriptEnum.FlagsNameResolvingContext.IdResolver; var name_resolver = Proto.MegaloScriptEnum.FlagsNameResolvingContext.NameResolver; switch (nodeType) { case IO.TagElementNodeType.Element: s.StreamElementIdAsString(nodeName, ref value, id_resolving_ctxt, id_resolver, name_resolver); break; case IO.TagElementNodeType.Attribute: s.StreamAttributeIdAsString(nodeName, ref value, id_resolving_ctxt, id_resolver, name_resolver); break; case IO.TagElementNodeType.Text: s.StreamCursorIdAsString(ref value, id_resolving_ctxt, id_resolver, name_resolver); break; } } else { switch (nodeType) { case IO.TagElementNodeType.Element: s.StreamElement(nodeName, ref value); break; case IO.TagElementNodeType.Attribute: s.StreamAttribute(nodeName, ref value); break; case IO.TagElementNodeType.Text: s.StreamCursor(ref value); break; } } }
internal static void SerializeValue(MegaloScriptModel model, IO.BitStream s, MegaloScriptValueType valueType, ref int value) { var traits = valueType.IndexTraits; int bit_length = valueType.BitLength; int local_value = value; if (s.IsWriting && valueType.IndexTarget == Proto.MegaloScriptValueIndexTarget.Trigger) { model.mCompilerState.RemapTriggerReference(ref local_value); } switch (traits) { case Proto.MegaloScriptValueIndexTraits.PointerHasValue: s.StreamIndex(ref local_value, bit_length); break; case Proto.MegaloScriptValueIndexTraits.Pointer: s.StreamNoneable(ref local_value, bit_length); break; case Proto.MegaloScriptValueIndexTraits.PointerRaw: s.Stream(ref local_value, bit_length, signExtend: true); break; case Proto.MegaloScriptValueIndexTraits.Reference: s.Stream(ref local_value, bit_length); break; default: throw new KSoft.Debug.UnreachableException(traits.ToString()); } if (s.IsReading) { value = local_value; } }
public MegaloScriptTargetVarValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.TargetVar); }
public MegaloScriptBoolValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Bool); }
public MegaloScriptFlagsValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Flags); }
internal static void SerializeValue <TDoc, TCursor>(MegaloScriptModel model, IO.TagElementStream <TDoc, TCursor, string> s, MegaloScriptValueType valueType, ref int value, IO.TagElementNodeType nodeType = IO.TagElementNodeType.Text, string nodeName = null) where TDoc : class where TCursor : class { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Index); var target = valueType.IndexTarget; if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.EmbedObjects) != 0 && target == MegaloScriptValueIndexTarget.Trigger) { SerializeTriggerReferenceValue(model, s, valueType, ref value); } #region UseIndexNames else if ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.UseIndexNames) != 0 && target.HasIndexName()) { var id_resolving_ctxt = new MegaloScriptModel.IndexNameResolvingContext(model, target); var id_resolver = MegaloScriptModel.IndexNameResolvingContext.IdResolver; var name_resolver = MegaloScriptModel.IndexNameResolvingContext.NameResolver; switch (nodeType) { case IO.TagElementNodeType.Element: s.StreamElementIdAsString(nodeName, ref value, id_resolving_ctxt, id_resolver, name_resolver); break; case IO.TagElementNodeType.Attribute: s.StreamAttributeIdAsString(nodeName, ref value, id_resolving_ctxt, id_resolver, name_resolver); break; case IO.TagElementNodeType.Text: s.StreamCursorIdAsString(ref value, id_resolving_ctxt, id_resolver, name_resolver); break; } } #endregion else { switch (nodeType) { case IO.TagElementNodeType.Element: s.StreamElement(nodeName, ref value); break; case IO.TagElementNodeType.Attribute: s.StreamAttribute(nodeName, ref value); break; case IO.TagElementNodeType.Text: s.StreamCursor(ref value); break; } } // #REVIEW_BLAM: this will fail when embedding and the target is a Trigger since we don't preload triggers or such if (s.IsReading && ((model.TagElementStreamSerializeFlags & MegaloScriptModelTagElementStreamFlags.EmbedObjects) == 0 || target != MegaloScriptValueIndexTarget.Trigger) ) { if (!model.IndexTargetIsValid(target, valueType.IndexTraits, value)) { s.ThrowReadException(new System.IO.InvalidDataException(string.Format(Util.InvariantCultureInfo, "A {0} reference has an invalid value {1}", target, value))); } } }
protected MegaloScriptVarReferenceValueBase(MegaloScriptValueType valueType) : base(valueType) { }
public MegaloScriptVarReferenceValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.VarReference); }
public MegaloScriptVirtualTriggerValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.VirtualTrigger); mVirtualTriggerHandle = MegaloScriptModelObjectHandle.Null; }
public MegaloScriptNavpointIconParametersValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.NavpointIconParameters); }
public MegaloScriptWidgetMeterParametersValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.WidgetMeterParameters); }
public MegaloScriptTeamFilterParametersValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.TeamFilterParameters); }
public MegaloScriptSingleValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Single); }
public MegaloScriptVarIndexValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Var); }
public MegaloScriptPoint3dValue(MegaloScriptValueType valueType) : base(valueType) { Contract.Requires(valueType.BaseType == MegaloScriptValueBaseType.Point3d); }