static bool SET_MODEL_ID(byte[] commandBytes) { try { if (commandBytes[0] == 0x21) { return(true); } int address = cvt.int32(commandBytes, 4); GeoLayout lol = GeoLayout.LoadSegmented(address); if (lol != null) { Level.modelIDs[commandBytes[3]] = lol; } if (current != null && current.recordingLevelGeos) { current.levelGeos[commandBytes[3]] = address; } return(true); } catch (Exception ex) { ; } return(false); }
public GeoLayout DeepCopy() { GeoLayout output = new GeoLayout(); output.root = root.DeepCopy(); return(output); }
public static GeoLayout LoadSegmented(int segmentedPointer) { validGeoLayout = false; current = new GeoLayout(); current.segmentedPointer = segmentedPointer; currentNode = current.root = new Node(); GeoLayoutReader.ReadFromSegmented(segmentedPointer); if (validGeoLayout) { return(current); } return(null); }
public void CleanLevelGeos() { Dictionary <byte, int> newGeo = new Dictionary <byte, int>(levelGeos); levelGeos.Clear(); current = this; foreach (int jumpAddress in levelGeoJumps) { LevelScriptReader.ReadFromSegmented(jumpAddress); } current = null; foreach (var jumpGeoLayout in levelGeos) { newGeo.Remove(jumpGeoLayout.Key); } levelGeos.Clear(); foreach (var layout in newGeo) { try { GeoLayout.LoadSegmented(layout.Value); levelGeos[layout.Key] = layout.Value; } catch { //Geo layout could not be loaded, thus should not be added to the levels geo layout list. } } levelGeos = newGeo; foreach (Area area in areas) { foreach (Object obj in area) { byte id = obj.model_ID; obj.SetModelID(0); obj.SetModelID(id); } } }
public void AddLevelGeo(byte id, GeoLayout layout) { levelGeos[id] = layout.segmentedPointer; Level.modelIDs[id] = layout; }
public Area(Level level, int geoLayoutPointer) { this.level = level; selectedObjects = new List <Object>(); geometry = GeoLayout.LoadSegmented(geoLayoutPointer); }
void WriteLevelData() { foreach (LevelBankDescription bank in new LevelBankDescription[] { bank0x5, bank0x6, bank0x9 }) { if (bank == null) { continue; } byte[][] cmd17; if (bank.commandBytes.TryGetValue("cmd17", out cmd17)) { foreach (byte[] cmd in cmd17) { BankDescription newDescription = BankDescription.Parse(cmd); foreach (BankDescription desc in new List <BankDescription>(Editor.currentLevel.loadedBanks)) { if (desc.ID == newDescription.ID) { Editor.currentLevel.loadedBanks.Remove(desc); } } Editor.currentLevel.loadedBanks.Add(newDescription); SM64RAM.EmulationState.instance.banks[newDescription.ID] = new SM64RAM.EmulationState.RAMBank(newDescription.ID, (int)newDescription.ROM_Start, (int)newDescription.ROM_End, cmd[0] != 0x17); } } byte[][] cmd1A; if (bank.commandBytes.TryGetValue("cmd1a", out cmd1A)) { foreach (byte[] cmd in cmd1A) { BankDescription newDescription = BankDescription.Parse(cmd); foreach (BankDescription desc in new List <BankDescription>(Editor.currentLevel.loadedBanks)) { if (desc.ID == newDescription.ID) { Editor.currentLevel.loadedBanks.Remove(desc); } } Editor.currentLevel.loadedBanks.Add(newDescription); SM64RAM.EmulationState.instance.banks[newDescription.ID] = new SM64RAM.EmulationState.RAMBank(newDescription.ID, (int)newDescription.ROM_Start, (int)newDescription.ROM_End, true); } } byte[][] cmd22; if (bank.commandBytes.TryGetValue("cmd22", out cmd22)) { foreach (byte[] cmd in cmd22) { Editor.currentLevel.AddLevelGeo(cmd[3], Level.modelIDs[cmd[3]] = GeoLayout.LoadSegmented(SM64RAM.cvt.int32(cmd, 4))); } } byte[][] cmd06; if (bank.commandBytes.TryGetValue("cmd06", out cmd06)) { foreach (byte[] cmd in bank.commandBytes["cmd06"]) { Editor.currentLevel.ReadJump(cmd); } } Editor.currentLevel.CleanLevelGeos(); } }