Пример #1
0
        public static ScriptNode Read(Reader reader, Pointer offset, Script script) {
            MapLoader l = MapLoader.Loader;
            ScriptNode sn = new ScriptNode(offset);

            sn.script = script;
            sn.param = reader.ReadUInt32();
            sn.param_ptr = Pointer.GetPointerAtOffset(offset); // if parameter is pointer
            if (Settings.s.platform == Settings.Platform.DC) reader.ReadUInt32();

            if (Settings.s.mode == Settings.Mode.Rayman3GC) {
                reader.ReadByte();
                reader.ReadByte();
                reader.ReadByte();
                sn.type = reader.ReadByte();

                reader.ReadByte();
                reader.ReadByte();
                sn.indent = reader.ReadByte();
                reader.ReadByte();
            } else {
                reader.ReadByte();
                reader.ReadByte();
                sn.indent = reader.ReadByte();
                sn.type = reader.ReadByte();
            }
            sn.nodeType = NodeType.Unknown;
            if (Settings.s.aiTypes != null) sn.nodeType = Settings.s.aiTypes.GetNodeType(sn.type);
			
            if (sn.param_ptr != null && sn.nodeType != NodeType.Unknown) {
				//l.print("ScriptNode " + offset + " - " + sn.nodeType + " (" + sn.type + ") - " + sn.param_ptr);
				if (sn.nodeType == NodeType.WayPointRef) {
					WayPoint waypoint = WayPoint.FromOffsetOrRead(sn.param_ptr, reader);
				} else if (sn.nodeType == NodeType.String) {
					Pointer.DoAt(ref reader, sn.param_ptr, () => {
						string str = reader.ReadNullDelimitedString();
						l.strings[sn.param_ptr] = str;
					});
				} else if (sn.nodeType == NodeType.ObjectTableRef) {
					// In R2 some objects have object tables that aren't listed normally, but are referenced through scripts.
				} else if (sn.nodeType == NodeType.Button) {
					EntryAction.FromOffsetOrRead(sn.param_ptr, reader);
				} else if (sn.nodeType == NodeType.GameMaterialRef) {
                    GameMaterial.FromOffsetOrRead(sn.param_ptr, reader);
                } else if (sn.nodeType == NodeType.VisualMaterial) {
                    VisualMaterial.FromOffsetOrRead(sn.param_ptr, reader);
                }
            }
            return sn;
        }
Пример #2
0
        public void Read(Reader reader)
        {
            offset = Pointer.Current(reader);
            switch (type)
            {
            case DsgVarInfoEntry.DsgVarType.Boolean:
                valueBool = reader.ReadBoolean(); break;

            case DsgVarInfoEntry.DsgVarType.Byte:
                valueByte = reader.ReadSByte(); break;

            case DsgVarInfoEntry.DsgVarType.UByte:
                valueUByte = reader.ReadByte(); break;

            case DsgVarInfoEntry.DsgVarType.Float:
                valueFloat = reader.ReadSingle(); break;

            case DsgVarInfoEntry.DsgVarType.Int:
                valueInt = reader.ReadInt32(); break;

            case DsgVarInfoEntry.DsgVarType.UInt:
                valueUInt = reader.ReadUInt32(); break;

            case DsgVarInfoEntry.DsgVarType.Short:
                valueShort = reader.ReadInt16(); break;

            case DsgVarInfoEntry.DsgVarType.UShort:
                valueUShort = reader.ReadUInt16(); break;

            case DsgVarInfoEntry.DsgVarType.Vector:
                float x = reader.ReadSingle();
                float y = reader.ReadSingle();
                float z = reader.ReadSingle();
                valueVector = new Vector3(x, y, z);
                break;

            case DsgVarInfoEntry.DsgVarType.Text:
                valueText = reader.ReadInt32(); break;

            case DsgVarInfoEntry.DsgVarType.Graph:
                valuePointer = Pointer.Read(reader);
                valueGraph   = Graph.FromOffsetOrRead(valuePointer, reader);
                break;

            case DsgVarInfoEntry.DsgVarType.WayPoint:
                valuePointer  = Pointer.Read(reader);
                valueWayPoint = WayPoint.FromOffsetOrRead(valuePointer, reader);
                break;

            case DsgVarInfoEntry.DsgVarType.GameMaterial:
                valuePointer      = Pointer.Read(reader);
                valueGameMaterial = GameMaterial.FromOffsetOrRead(valuePointer, reader);
                break;

            case DsgVarInfoEntry.DsgVarType.VisualMaterial:
                valuePointer        = Pointer.Read(reader);
                valueVisualMaterial = VisualMaterial.FromOffsetOrRead(valuePointer, reader);
                break;

            case DsgVarInfoEntry.DsgVarType.ObjectList:
                valuePointer    = Pointer.Read(reader);
                valueObjectList = ObjectList.FromOffsetOrRead(valuePointer, reader);
                break;

            case DsgVarInfoEntry.DsgVarType.List:
                valueList = new List();
                valueList.Read(reader);
                break;

            case DsgVarInfoEntry.DsgVarType.Light:
                valuePointer = Pointer.Read(reader);
                valueLight   = MapLoader.Loader.FromOffsetOrRead <LightInfo>(reader, valuePointer);
                break;

            case DsgVarInfoEntry.DsgVarType.Comport:
                valuePointer = Pointer.Read(reader);
                valueComport = MapLoader.Loader.FromOffsetOrRead <Behavior>(reader, valuePointer);
                break;

            case DsgVarInfoEntry.DsgVarType.Input:
                valuePointer = Pointer.Read(reader);
                valueInput   = EntryAction.FromOffsetOrRead(valuePointer, reader);
                break;

            // Fill these in after loading
            case DsgVarInfoEntry.DsgVarType.Perso:
                valuePointer = Pointer.Read(reader);
                // Don't fill in perso yet
                MapLoader.Loader.onPostLoad.Add(InitPostLoad);
                break;

            case DsgVarInfoEntry.DsgVarType.Action:
                valuePointer = Pointer.Read(reader);
                // Don't fill in state yet
                MapLoader.Loader.onPostLoad.Add(InitPostLoad);
                break;

            case DsgVarInfoEntry.DsgVarType.SuperObject:
                valuePointer = Pointer.Read(reader);
                // Don't fill in SO yet
                MapLoader.Loader.onPostLoad.Add(InitPostLoad);
                break;

            // TODO: Figure these out
            case DsgVarInfoEntry.DsgVarType.Caps:
                valueCaps = reader.ReadUInt32(); break;

            case DsgVarInfoEntry.DsgVarType.SOLinks:
                valueSOLinks = reader.ReadUInt32(); break;

            case DsgVarInfoEntry.DsgVarType.SoundEvent:
                valueSoundEvent = reader.ReadUInt32(); break;

            case DsgVarInfoEntry.DsgVarType.Way:
                valueWay = reader.ReadUInt32(); break;

            // Arrays
            case DsgVarInfoEntry.DsgVarType.ActionArray:
            case DsgVarInfoEntry.DsgVarType.FloatArray:
            case DsgVarInfoEntry.DsgVarType.IntegerArray:
            case DsgVarInfoEntry.DsgVarType.PersoArray:
            case DsgVarInfoEntry.DsgVarType.SoundEventArray:
            case DsgVarInfoEntry.DsgVarType.SuperObjectArray:
            case DsgVarInfoEntry.DsgVarType.TextArray:
            case DsgVarInfoEntry.DsgVarType.TextRefArray:
            case DsgVarInfoEntry.DsgVarType.VectorArray:
            case DsgVarInfoEntry.DsgVarType.WayPointArray:
            case DsgVarInfoEntry.DsgVarType.GraphArray:
            case DsgVarInfoEntry.DsgVarType.Array11:
            case DsgVarInfoEntry.DsgVarType.Array9:
                ReadArray(reader); break;
            }
        }