public ScriptVariable(System.IO.BinaryReader reader, int size) { index = reader.ReadByte(); type = (ScriptVariableType)reader.ReadByte(); function = (ScriptFunction)reader.ReadInt16(); compareOp = (CompareOp)reader.ReadByte(); variable = reader.ReadString(size - 5); // Do a switch here to determine the variable to save looking it up each frame switch (type) { case ScriptVariableType.Global: global = Record.GetRecord <Global>(variable); break; case ScriptVariableType.Item: item = Record.GetRecord <ItemRecord>(variable); break; case ScriptVariableType.NotClass: characterClass = Record.GetRecord <ClassRecord>(variable); break; case ScriptVariableType.NotFaction: faction = Record.GetRecord <Faction>(variable); break; case ScriptVariableType.NotRace: race = Record.GetRecord <Race>(variable); break; } }
public void Initialize(BinaryReader reader, RecordHeader header) { while (reader.BaseStream.Position < header.DataEndPos) { var type = (SubRecordType)reader.ReadInt32(); var size = reader.ReadInt32(); switch (type) { case SubRecordType.InfoName: infoName = reader.ReadString(size); break; case SubRecordType.PreviousName: previousInfoId = reader.ReadString(size); break; case SubRecordType.NextName: nextInfoId = reader.ReadString(size); break; case SubRecordType.Data: infoData = new InfoRecordData(reader); break; case SubRecordType.ObjectName: character = Record.GetRecord <CreatableRecord>(reader.ReadString(size)); break; case SubRecordType.RaceName: race = Record.GetRecord <Race>(reader.ReadString(size)); break; case SubRecordType.CreatureName: classId = Record.GetRecord <ClassRecord>(reader.ReadString(size)); break; case SubRecordType.Name: var contents = reader.ReadString(size); if (contents != "FFFF") { faction = Record.GetRecord <Faction>(contents); } break; case SubRecordType.Anam: cell = reader.ReadString(size); break; case SubRecordType.DoorName: playerFaction = Record.GetRecord <Faction>(reader.ReadString(size)); break; case SubRecordType.Id: response = reader.ReadString(size); break; case SubRecordType.SoundName: soundClip = reader.ReadString(size); break; case SubRecordType.JournalName: journalName = reader.ReadByte(); break; case SubRecordType.JournalFinished: journalFinished = reader.ReadByte(); break; case SubRecordType.JournalRestart: journalRestart = reader.ReadByte(); break; case SubRecordType.ScriptVariable: scriptVariables.Add(new ScriptVariable(reader, size)); break; case SubRecordType.IntValue: scriptVariables.Last().IntValue = reader.ReadInt32(); break; case SubRecordType.FloatValue: scriptVariables.Last().FloatValue = reader.ReadSingle(); break; case SubRecordType.BodyName: result = reader.ReadString(size); break; } } DialogRecord.currentDialogueInfo.Add(this); }