コード例 #1
0
        public override void Read(R1TextParser parser)
        {
            var tempList      = new List <R1_Mapper_SaveEventInstance[]>();
            var tempGroupList = new List <R1_Mapper_SaveEventInstance>();

            parser.SupportsComments  = false;
            parser.SeparateAtPadding = true;

            string value;

            while ((value = parser.ReadValue()) != null)
            {
                // NOTE: There is data before the instances, but the game doesn't read it. It's auto-generated by the editor when saving based on memory offsets, probably for debugging and/or compiling on Jaguar.

                // Check for event instances
                if (value == "ev_ty1")
                {
                    R1_Mapper_SaveEventInstance item = new R1_Mapper_SaveEventInstance();
                    item.IsValid            = parser.ReadShortValue();
                    item.OffsetX            = parser.ReadShortValue();
                    item.OffsetY            = parser.ReadShortValue();
                    item.EventDefinitionKey = parser.ReadValue();
                    item.HitPoints          = parser.ReadShortValue();
                    item.DisplayPrio        = parser.ReadByteValue();
                    item.LinkID             = parser.ReadShortValue();
                    tempGroupList.Add(item);
                }
                // Check for group end
                else if (value == "ev_end")
                {
                    tempList.Add(tempGroupList.ToArray());
                    tempGroupList.Clear();
                }
            }

            SaveEventInstances = tempList.ToArray();
        }
コード例 #2
0
        public override void Read(R1TextParser parser)
        {
            var ed  = new List <R1_Mapper_EventDefinition>();
            var aed = new List <R1_Mapper_AlwaysEventDefinition>();

            while (true)
            {
                // Get the next value
                var value = parser.ReadValue();

                // Stop reading once we reached the end
                if (value == null)
                {
                    break;
                }

                // Only parse event definitions
                if (value != "£def")
                {
                    continue;
                }

                // Create a definition
                R1_Mapper_BaseEventDefinition item;

                // Get the name
                var name = parser.ReadValue();

                // Create the definition
                if (name == "always")
                {
                    var alwaysItem = new R1_Mapper_AlwaysEventDefinition();
                    aed.Add(alwaysItem);
                    item = alwaysItem;
                }
                else
                {
                    var normalItem = new R1_Mapper_EventDefinition();
                    ed.Add(normalItem);
                    item = normalItem;
                }

                // Set the name
                item.Name = name;

                var nextValue = parser.ReadValue();

                // Read the if values if it's an always object
                if (item is R1_Mapper_AlwaysEventDefinition ae && nextValue == "£if")
                {
                    var ifBuffer = new List <string>();

                    while (true)
                    {
                        nextValue = parser.ReadValue();

                        if (nextValue == "£endif")
                        {
                            break;
                        }

                        ifBuffer.Add(nextValue);
                    }

                    ae.IfCommand = ifBuffer.ToArray();

                    nextValue = parser.ReadValue();
                }

                item.DESFile     = nextValue;
                item.DisplayPrio = parser.ReadByteValue();
                item.ETAFile     = parser.ReadValue();

                var cmdBuffer = new List <short>();

                do
                {
                    // Since command parameters can be both signed and unsigned bytes we read them as shorts
                    cmdBuffer.Add(parser.ReadShortValue());
                } while (cmdBuffer.Last() != 0xFF);

                item.EventCommands = cmdBuffer.Select(x => (byte)x).ToArray();

                // Read values
                item.XPosition = parser.ReadShortValue();
                item.YPosition = parser.ReadShortValue();

                item.Etat    = parser.ReadByteValue();
                item.SubEtat = parser.ReadByteValue();

                item.OffsetBX = parser.ReadByteValue();
                item.OffsetBY = parser.ReadByteValue();
                item.OffsetHY = parser.ReadByteValue();

                item.FollowEnabled = parser.ReadByteValue();
                item.FollowSprite  = parser.ReadByteValue();
                item.HitPoints     = parser.ReadUIntValue();

                item.Type      = (R1_EventType)parser.ReadShortValue();
                item.HitSprite = parser.ReadByteValue();

                // Read the group if it's not an always object
                if (item is R1_Mapper_EventDefinition e)
                {
                    e.DesignerGroup = parser.ReadByteValue();
                }
            }

            // Set the parsed values
            EventDefinitions       = ed.ToArray();
            AlwaysEventDefinitions = aed.ToArray();
        }
コード例 #3
0
        public override void Read(R1TextParser parser)
        {
            var ed  = new List <R1_Mapper_EventCMDItem>();
            var aed = new List <R1_Mapper_AlwaysEventCMDItem>();

            while (true)
            {
                // Get the next value
                var etaFile = parser.ReadValue();

                // Stop reading once we reached the end
                if (etaFile == null)
                {
                    break;
                }

                // Create a definition
                R1_Mapper_EventDefinition item;

                // Get the name
                var name = parser.ReadValue();

                // Create the definition
                if (name == "always")
                {
                    var alwaysItem = new R1_Mapper_AlwaysEventCMDItem();
                    aed.Add(alwaysItem);
                    item = alwaysItem;
                }
                else
                {
                    var normalItem = new R1_Mapper_EventCMDItem();
                    ed.Add(normalItem);
                    item = normalItem;
                }

                // Set the ETA file name
                item.ETAFile = etaFile;

                // Set the name
                item.Name = name;

                var cmdBuffer = new List <short>();

                do
                {
                    // Since command parameters can be both signed and unsigned bytes we read them as shorts
                    cmdBuffer.Add(parser.ReadShortValue());
                } while (cmdBuffer.Last() != 0xFF);

                item.EventCommands = cmdBuffer.Select(x => (byte)x).ToArray();

                // Read values
                item.XPosition = parser.ReadShortValue();
                item.YPosition = parser.ReadShortValue();

                if (item is R1_Mapper_EventCMDItem med)
                {
                    med.DisplayPrio = parser.ReadByteValue();
                    med.LinkID      = parser.ReadShortValue();
                }

                item.Etat    = parser.ReadByteValue();
                item.SubEtat = parser.ReadByteValue();

                item.OffsetBX = parser.ReadByteValue();
                item.OffsetBY = parser.ReadByteValue();
                item.OffsetHY = parser.ReadByteValue();

                item.FollowEnabled = parser.ReadByteValue();
                item.FollowSprite  = parser.ReadByteValue();
                item.HitPoints     = parser.ReadUIntValue();

                item.Type          = (R1_EventType)parser.ReadShortValue();
                item.HitSprite     = parser.ReadByteValue();
                item.DesignerGroup = parser.ReadByteValue();
            }

            // Set the parsed values
            Events       = ed.ToArray();
            AlwaysEvents = aed.ToArray();
        }