Esempio n. 1
0
        public TpDstObject AddTpDstObject(int layer)
        {
            TpDstObject obj = new TpDstObject(
                InitialiseDataForObject(LevelObject.Type.TELEPORT_DESTINATION), (int)GetNextUniqueID(), layer);

            m_LevelObjects.Add(obj.m_UniqueID, obj);
            return(obj);
        }
Esempio n. 2
0
        protected virtual void WriteTpDstObjectToXML(XmlWriter writer, TpDstObject obj)
        {
            writer.WriteStartElement("TpDstObject");

            WriteObjectPositionToXML(writer, obj);

            writer.WriteStartElement("Parameters");
            writer.WriteAttributeString("count", "1");
            for (int j = 0; j < 1; j++)
            {
                writer.WriteStartElement("Parameter");
                writer.WriteAttributeString("id", j.ToString());
                writer.WriteString(obj.Parameters[j].ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Esempio n. 3
0
        protected virtual void ReadTpDstObject(XmlReader reader, Level level)
        {
            TpDstObject obj = level.AddTpDstObject(0);

            while (reader.Read())
            {
                reader.MoveToContent();
                if (reader.NodeType.Equals(XmlNodeType.Element) && reader.LocalName.Equals("Position"))
                {
                    Vector3 position = ReadPositionVector3(reader);
                    obj.Position = position;
                }
                else if (reader.NodeType.Equals(XmlNodeType.Element) && reader.LocalName.Equals("Parameters"))
                {
                    obj.Parameters = ReadParameters(reader, 1);
                }
                else if (reader.NodeType.Equals(XmlNodeType.EndElement) && reader.LocalName.Equals("TpDstObject"))
                {
                    break;
                }
            }
        }
Esempio n. 4
0
        private static void WriteTpDstObjectToXML(XmlWriter writer, TpDstObject obj)
        {
            writer.WriteStartElement("TpDstObject");

            writer.WriteStartElement("Position");
            writer.WriteElementString("X", obj.Position.X.ToString(usa));
            writer.WriteElementString("Y", obj.Position.Y.ToString(usa));
            writer.WriteElementString("Z", obj.Position.Z.ToString(usa));
            writer.WriteEndElement();

            writer.WriteStartElement("Parameters");
            writer.WriteAttributeString("count", "1");
            for (int j = 0; j < 1; j++)
            {
                writer.WriteStartElement("Parameter");
                writer.WriteAttributeString("id", j.ToString());
                writer.WriteString(obj.Parameters[j].ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Esempio n. 5
0
        private static void WriteTpDstObjectToXML(XmlWriter writer, TpDstObject obj)
        {
            writer.WriteStartElement("TpDstObject");

            writer.WriteStartElement("Position");
            writer.WriteElementString("X", obj.Position.X.ToString(usa));
            writer.WriteElementString("Y", obj.Position.Y.ToString(usa));
            writer.WriteElementString("Z", obj.Position.Z.ToString(usa));
            writer.WriteEndElement();

            writer.WriteStartElement("Parameters");
            writer.WriteAttributeString("count", "1");
            for (int j = 0; j < 1; j++)
            {
                writer.WriteStartElement("Parameter");
                writer.WriteAttributeString("id", j.ToString());
                writer.WriteString(obj.Parameters[j].ToString());
                writer.WriteEndElement();
            }
            writer.WriteEndElement();

            writer.WriteEndElement();
        }
Esempio n. 6
0
        private void ReadObjectTable(NitroOverlay ovl, uint offset, int area)
        {
            uint subtbl_num    = ovl.Read32(offset);
            uint subtbl_offset = ovl.ReadPointer(offset + 0x4);

            for (uint st = 0; st < subtbl_num; st++)
            {
                uint curoffset = subtbl_offset + (st * 8);

                byte flags          = ovl.Read8(curoffset);
                byte entries_num    = ovl.Read8(curoffset + 0x1);
                uint entries_offset = ovl.ReadPointer(curoffset + 0x4);

                byte type  = (byte)(flags & 0x1F);
                byte layer = (byte)(flags >> 5);

                if (type == 11)
                {
                    m_MinimapFileIDs = new ushort[entries_num];
                }

                for (byte e = 0; e < entries_num; ++e)
                {
                    LevelObject    obj;
                    INitroROMBlock objData = new INitroROMBlock();
                    objData.m_Data = ovl.ReadBlock((uint)(entries_offset + e * k_LevelObjTypeSizes[type]), (uint)k_LevelObjTypeSizes[type]);
                    switch (type)
                    {
                    case 0:
                        obj = new StandardObject(objData, m_LevelObjects.Count, layer, area);
                        break;

                    case 1:
                        obj = new EntranceObject(objData, m_LevelObjects.Count, layer, m_EntranceID++);
                        break;

                    case 2:     // Path Node
                        obj = new PathPointObject(objData, m_LevelObjects.Count, m_PathNodeID++);
                        break;

                    case 3:     // Path
                        obj = new PathObject(objData, m_LevelObjects.Count, (ushort)m_PathID++);
                        break;

                    case 4:
                        obj = new ViewObject(objData, m_LevelObjects.Count, m_ViewID++);
                        break;

                    case 5:
                        obj = new SimpleObject(objData, m_LevelObjects.Count, layer, area);
                        break;

                    case 6:
                        obj = new TpSrcObject(objData, m_LevelObjects.Count, layer);
                        break;

                    case 7:
                        obj = new TpDstObject(objData, m_LevelObjects.Count, layer);
                        break;

                    case 8:
                        // Fog
                        obj = new FogObject(objData, m_LevelObjects.Count, layer, area);
                        break;

                    case 9:
                        obj = new DoorObject(objData, m_LevelObjects.Count, layer);
                        break;

                    case 10:
                        obj = new ExitObject(objData, m_LevelObjects.Count, layer);
                        break;

                    case 11:
                        obj = new MinimapTileIDObject(objData, m_LevelObjects.Count, layer, m_MinimapTileIDNum++);
                        // This is still used by Minimap Editor
                        m_MinimapFileIDs[e] = ovl.Read16((uint)(entries_offset + (e * 2)));
                        break;

                    case 12:
                        // per-area minimap scale factors
                        obj = new MinimapScaleObject(objData, m_LevelObjects.Count, layer, area);
                        break;

                    case 14:
                        // ??? Unknown
                        obj = new Type14Object(objData, m_LevelObjects.Count, layer, area);
                        break;

                    default:
                        throw new InvalidDataException("Bad object type: " + type);
                    }

                    m_LevelObjects.Add(obj.m_UniqueID, obj);
                }
            }
        }