public ActorEntry CreateActorEntry(ActorTypes type, string name) { ActorExtraData extraData = new ActorExtraData(); extraData.BufferType = type; extraData.Data = ActorFactory.CreateExtraData(type); ActorEntry entry = ActorFactory.CreateActorItem(type, name); entry.DataID = (ushort)(ExtraData.Count); entry.Data = extraData; ExtraData.Add(extraData); Items.Add(entry); return(entry); }
public void ReadFromFile(BinaryReader reader) { int poolLength = reader.ReadInt32(); pool = new string(reader.ReadChars(poolLength)); int hashesLength = reader.ReadInt32(); definitions = new ActorDefinition[hashesLength]; for (int i = 0; i != hashesLength; i++) { definitions[i] = new ActorDefinition(reader); int pos = definitions[i].NamePos; definitions[i].name = pool.Substring(pos, pool.IndexOf('\0', pos) - pos); } filesize = reader.ReadInt32(); const6 = reader.ReadInt16(); const2 = reader.ReadInt16(); const16 = reader.ReadInt32(); size = reader.ReadInt32(); //size of sector end. unk12 = reader.ReadInt32(); unk13 = reader.ReadInt32(); //if (const2 != 2) // throw new Exception("const_6 is not 6"); //if (const6 != 6) // throw new Exception("const_2 is not 2"); //if (const16 != 16) // throw new Exception("const_16 is not 16"); unk14 = reader.ReadInt32(); if (const2 == 2) { int newpos = (unk14 / 4 - 2) * 4; if (unk14 - 8 != newpos) { throw new FormatException("unk14-8 != newpos"); } int count = (unk14 - 8) / sizeof(int); reader.BaseStream.Seek(unk14 - 12, SeekOrigin.Current); extraData = new ActorExtraData[count]; for (int i = 0; i < count; i++) { extraData[i] = new ActorExtraData(reader); } } else { unk02 = reader.ReadBytes(size - unk14); } int itemCount = reader.ReadInt32(); reader.BaseStream.Seek(itemCount * 4, SeekOrigin.Current); items = new ActorItem[itemCount]; for (int i = 0; i != itemCount; i++) { items[i] = new ActorItem(reader); items[i].Data = ExtraData[items[i].DataID]; } unk16 = reader.ReadInt32(); //if (unk16 != 0) // throw new Exception("UNK16 is not 0. Message Greavesy with this message and the name of the SDS you tried to read"); }