コード例 #1
0
            /// <summary>
            /// Writes the data element into the given buffer (at its current position).
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
            public void WriteData(RAMBuffer buffer)
            {
                buffer.WriteUShort((ushort)PlayerName.Length);
                buffer.WriteString(PlayerName);
                buffer.WriteFloat(InitialCameraX);
                buffer.WriteFloat(InitialCameraY);
                buffer.WriteShort(UnknownX);
                buffer.WriteShort(UnknownY);
                buffer.WriteByte(AlliedVictory);

                ScenarioDataElementTools.AssertTrue(Diplomacy1.Count == Diplomacy2.Count);
                buffer.WriteUShort((ushort)Diplomacy1.Count);
                Diplomacy1.ForEach(d => buffer.WriteByte((byte)d));
                Diplomacy2.ForEach(d => buffer.WriteUInteger((uint)d));

                buffer.WriteUInteger(Color);
                buffer.WriteFloat(Unknown1);
                buffer.WriteUShort(Unknown3Count);

                if (Unknown1 == 2)
                {
                    ScenarioDataElementTools.AssertListLength(Unknown2, 8);
                    Unknown2.ForEach(b => buffer.WriteByte(b));
                }

                ScenarioDataElementTools.AssertListLength(Unknown3, Unknown3Count * 44);
                Unknown3.ForEach(b => buffer.WriteByte(b));

                ScenarioDataElementTools.AssertListLength(Unknown4, 7);
                Unknown4.ForEach(b => buffer.WriteByte(b));

                buffer.WriteInteger(Unknown5);
            }
コード例 #2
0
            /// <summary>
            /// Reads the data element from the given buffer.
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
            public Condition ReadData(RAMBuffer buffer)
            {
                Type = (ConditionTypes)buffer.ReadUInteger();

                ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0x00000010);

                Amount          = buffer.ReadInteger();
                ResourceId      = buffer.ReadInteger();
                UnitInstanceId  = buffer.ReadInteger();
                UnitLocation    = buffer.ReadInteger();
                UnitType        = buffer.ReadInteger();
                Player          = buffer.ReadInteger();
                ResearchId      = buffer.ReadInteger();
                Timer           = buffer.ReadInteger();
                Unknown         = buffer.ReadInteger();
                AreaBottomLeftX = buffer.ReadInteger();
                AreaBottomLeftY = buffer.ReadInteger();
                AreaTopRightX   = buffer.ReadInteger();
                AreaTopRightY   = buffer.ReadInteger();
                UnitClass       = buffer.ReadInteger();
                UnitType2       = buffer.ReadInteger();
                AiSignal        = buffer.ReadInteger();

                return(this);
            }
コード例 #3
0
            /// <summary>
            /// Writes the data element into the given buffer (at its current position).
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
            public void WriteData(RAMBuffer buffer)
            {
                buffer.WriteUInteger(Enabled);
                buffer.WriteUInteger(Looping);

                buffer.WriteByte(State);
                buffer.WriteByte(ShowAsObjective);
                buffer.WriteInteger(ObjectiveDescriptionIndex);
                buffer.WriteUInteger(Unknown);

                if (Description.Length == 0 || Description.Last() != '\0')
                {
                    Description += '\0';
                }
                buffer.WriteInteger(Description.Length);
                buffer.WriteString(Description);

                if (Name.Length == 0 || Name.Last() != '\0')
                {
                    Name += '\0';
                }
                buffer.WriteInteger(Name.Length);
                buffer.WriteString(Name);

                ScenarioDataElementTools.AssertTrue(Effects.Count == EffectDisplayIndices.Count);
                buffer.WriteInteger(Effects.Count);
                Effects.ForEach(t => t.WriteData(buffer));
                EffectDisplayIndices.ForEach(t => buffer.WriteInteger(t));

                ScenarioDataElementTools.AssertTrue(Conditions.Count == ConditionDisplayIndices.Count);
                buffer.WriteInteger(Conditions.Count);
                Conditions.ForEach(t => t.WriteData(buffer));
                ConditionDisplayIndices.ForEach(t => buffer.WriteInteger(t));
            }
コード例 #4
0
        /// <summary>
        /// Writes the data element into the given buffer (at its current position).
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized into.</param>
        public void WriteData(RAMBuffer buffer)
        {
            buffer.WriteByte(Unknown);

            ScenarioDataElementTools.AssertTrue(TriggerData.Count == TriggerDisplayIndices.Count);
            buffer.WriteInteger(TriggerData.Count);
            TriggerData.ForEach(t => t.WriteData(buffer));
            TriggerDisplayIndices.ForEach(t => buffer.WriteInteger(t));
        }
コード例 #5
0
            /// <summary>
            /// Reads the data element from the given buffer.
            /// </summary>
            /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
            public Effect ReadData(RAMBuffer buffer)
            {
                Type = (EffectTypes)buffer.ReadUInteger();

                ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0x00000017);

                AiGoal     = buffer.ReadInteger();
                Amount     = buffer.ReadInteger();
                ResourceId = buffer.ReadInteger();
                Diplomacy  = buffer.ReadInteger();

                int selectedUnitsCount = buffer.ReadInteger();

                if (selectedUnitsCount < 0)
                {
                    selectedUnitsCount = 0;
                }

                LocationUnitInstanceId = buffer.ReadInteger();
                UnitType         = buffer.ReadInteger();
                PlayerSource     = buffer.ReadInteger();
                PlayerTarget     = buffer.ReadInteger();
                ResearchId       = buffer.ReadInteger();
                StringId         = buffer.ReadInteger();
                SoundId          = buffer.ReadInteger();
                DisplayTime      = buffer.ReadInteger();
                TriggerIndex     = buffer.ReadInteger();
                LocationX        = buffer.ReadInteger();
                LocationY        = buffer.ReadInteger();
                AreaBottomLeftX  = buffer.ReadInteger();
                AreaBottomLeftY  = buffer.ReadInteger();
                AreaTopRightX    = buffer.ReadInteger();
                AreaTopRightY    = buffer.ReadInteger();
                UnitClass        = buffer.ReadInteger();
                UnitType2        = buffer.ReadInteger();
                InstructionPanel = buffer.ReadInteger();

                Text          = buffer.ReadString(buffer.ReadInteger());
                SoundFileName = buffer.ReadString(buffer.ReadInteger());

                SelectedUnitInstanceIds = new List <uint>(selectedUnitsCount);
                for (int i = 0; i < selectedUnitsCount; i++)
                {
                    SelectedUnitInstanceIds.Add(buffer.ReadUInteger());
                }

                return(this);
            }
コード例 #6
0
        /// <summary>
        /// Reads the data element from the given buffer.
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
        public GlobalVictory ReadData(RAMBuffer buffer)
        {
            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            ConquestRequired            = buffer.ReadUInteger();
            Unused1                     = buffer.ReadUInteger();
            NumberOfRelicsRequired      = buffer.ReadUInteger();
            Unused2                     = buffer.ReadUInteger();
            ExploredPercentRequired     = buffer.ReadUInteger();
            Unused3                     = buffer.ReadUInteger();
            AllCustomConditionsRequired = buffer.ReadUInteger();
            Mode          = (VictoryMode)buffer.ReadUInteger();
            ScoreRequired = buffer.ReadUInteger();
            TimeRequired  = buffer.ReadUInteger();

            return(this);
        }
コード例 #7
0
        /// <summary>
        /// Reads the data element from the given buffer.
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
        public Diplomacy ReadData(RAMBuffer buffer)
        {
            StancesPerPlayer = new List <StancesToPlayers>(16);
            for (int i = 0; i < 16; ++i)
            {
                StancesPerPlayer.Add(new StancesToPlayers().ReadData(buffer));
            }

            // Separator
            buffer.ReadByteArray(11520);
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            AlliedVictoryObsolete = new List <uint>(16);
            for (int i = 0; i < 16; ++i)
            {
                AlliedVictoryObsolete.Add(buffer.ReadUInteger());
            }

            return(this);
        }
コード例 #8
0
ファイル: Map.cs プロジェクト: JanWichelmann/ScenarioLibrary
        /// <summary>
        /// Reads the data element from the given buffer.
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
        public Map ReadData(RAMBuffer buffer)
        {
            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            Player1CameraY = buffer.ReadInteger();
            Player1CameraX = buffer.ReadInteger();
            AiMapCode      = buffer.ReadInteger();
            MapWidth       = buffer.ReadUInteger();
            MapHeight      = buffer.ReadUInteger();

            Tiles = new List <List <MapTileTerrainData> >((int)MapWidth);
            for (int i = 0; i < MapWidth; ++i)
            {
                Tiles.Add(new List <MapTileTerrainData>((int)MapHeight));
                for (int j = 0; j < MapHeight; ++j)
                {
                    Tiles[i].Add(new MapTileTerrainData().ReadData(buffer));
                }
            }
            return(this);
        }
コード例 #9
0
        // Resources

        #endregion

        #region Functions

        /// <summary>
        /// Reads the data element from the given buffer.
        /// </summary>
        /// <param name="buffer">The buffer where the data element should be deserialized from.</param>
        public PlayerAiResources ReadData(RAMBuffer buffer)
        {
            UnknownStrings = new List <string>(32);
            for (int i = 0; i < 32; ++i)
            {
                UnknownStrings.Add(buffer.ReadString(buffer.ReadShort()));
            }

            AiNames = new List <string>(16);
            for (int i = 0; i < 16; ++i)
            {
                AiNames.Add(buffer.ReadString(buffer.ReadShort()));
            }

            AiFiles = new List <AiFile>(16);
            for (int i = 0; i < 16; ++i)
            {
                AiFiles.Add(new AiFile().ReadData(buffer));
            }

            AiTypes = new List <byte>(16);
            for (int i = 0; i < 16; ++i)
            {
                AiTypes.Add(buffer.ReadByte());
            }

            // Separator
            ScenarioDataElementTools.AssertTrue(buffer.ReadUInteger() == 0xFFFFFF9D);

            ResourceEntries = new List <ResourceEntry>(16);
            for (int i = 0; i < 16; ++i)
            {
                ResourceEntries.Add(new ResourceEntry().ReadData(buffer));
            }

            return(this);
        }