示例#1
0
        void StreamEntryPointTriggerIndex(IO.BitStream s, ref int triggerIndex, Proto.MegaloScriptTriggerEntryPoints entryPoint)
        {
            if (Database.Limits.Supports(entryPoint))
            {
                int local_trigger_index = triggerIndex;
                if (s.IsWriting)
                {
                    mCompilerState.RemapTriggerPointer(ref local_trigger_index);
                }

                if (!Database.Limits.StreamEntryPointIndexAsPointer)
                {
                    s.StreamIndex(ref local_trigger_index, Database.Limits.Triggers.IndexBitLength);                     // pointer-has-value
                }
                else
                {
                    s.StreamNoneable(ref local_trigger_index, Database.Limits.Triggers.CountBitLength);                     // pointer
                }
                if (s.IsReading)
                {
                    triggerIndex = local_trigger_index;
                }
            }
            else
            {
                triggerIndex = -1;
            }
        }
示例#2
0
            public void StreamPlayerVarIndex(IO.BitStream s, ref int playerVarIndex,
                                             int refTypeIndex, Model.MegaloScriptModel model)
            {
                Contract.Assert(refTypeIndex >= 0 && refTypeIndex < ObjectReferenceType.Members.Count);

                var varIndexType = GetPlayerVarIndexValueType(refTypeIndex);

                s.StreamIndex(ref playerVarIndex, varIndexType.BitLength);
            }
示例#3
0
        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;
            }
        }
示例#4
0
 internal void StreamGameObjectFilterIndex(IO.BitStream s, ref int objectFilterIndex)
 {
     s.StreamIndex(ref objectFilterIndex, Limits.GameObjectFilters.IndexBitLength);
 }
示例#5
0
 internal void StreamObjectTypeIndex(IO.BitStream s, ref int objectTypeIndex)
 {
     s.StreamIndex(ref objectTypeIndex, Limits.MultiplayerObjectTypes.IndexBitLength);
 }
示例#6
0
 // #NOTE_BLAM: Assumes all Parameter instances need PointerHasValue encoding
 #region IBitStreamSerializable Members
 public override void Serialize(MegaloScriptModel model, IO.BitStream s)
 {
     s.StreamIndex(ref mValue, ValueType.BitLength);
 }
示例#7
0
 public virtual void Serialize(IO.BitStream s)
 {
     s.Stream(ref Flags, 1, GameOptionsSingleLoadoutFlagsBitStreamer.Instance);
     s.StreamIndex(ref NameIndex, 7);
     SerializeWeaponsAndEquipment(s);
 }