// Add room state to active room. private bool ForceAddRoomState(StateType type) { if (ActiveRoom == null) { return(false); } RoomStateHeader newHeader = new RoomStateHeader(); newHeader.SetDefault(); newHeader.HeaderType = type; var newState = new RoomState(); var newLevelData = new LevelData(RoomWidthInScreens, RoomHeightInScreens); var newPlmSet = new PlmSet(); var newEnemySet = new EnemySet(); var newEnemyGfx = new EnemyGfx(); var newFx = new Fx(); newState.SetDefault(); newLevelData.SetDefault(); newPlmSet.SetDefault(); newEnemySet.SetDefault(); newEnemyGfx.SetDefault(); newFx.SetDefault(); newState.SetLevelData(newLevelData, out var ignore1); newState.SetScrollSet(null, out var ignore2); newState.SetPlmSet(newPlmSet, out var ignore3); newState.SetEnemySet(newEnemySet, out var ignore4); newState.SetEnemyGfx(newEnemyGfx, out var ignore5); newState.SetFx(newFx, out var ignore6); newState.SetBackground(null, out var ignore7); newState.SetSetupAsm(null, out var ignore8); newState.SetMainAsm(null, out var ignore9); ActiveRoom.RoomStateHeaders.Insert(0, newHeader); ActiveRoom.RoomStates.Insert(0, newState); LevelDatas.Add(newState.MyLevelData); PlmSets.Add(newState.MyPlmSet); EnemySets.Add(newState.MyEnemySet); EnemyGfxs.Add(newState.MyEnemyGfx); Fxs.Add(newState.MyFx); ChangesMade = true; return(true); }
// Read all enemy sets from ROM. private void ReadEnemySets(Rom rom, List <RoomState> roomStates) { List <int> addressesPC = new List <int> (); foreach (RoomState r in roomStates) { int address = Tools.LRtoPC(r.EnemySetPtr); if (address != 0) // Skip invalid addresses { addressesPC.Add(address); } } Tools.RemoveDuplicates(addressesPC); EnemySets.Clear(); for (int n = 0; n < addressesPC.Count; n++) { EnemySets.Add(new EnemySet()); EnemySets [n].ReadFromROM(rom, addressesPC [n]); } }