Пример #1
0
 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);
 }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
 public Area(Level level, int geoLayoutPointer)
 {
     this.level      = level;
     selectedObjects = new List <Object>();
     geometry        = GeoLayout.LoadSegmented(geoLayoutPointer);
 }
Пример #4
0
        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();
            }
        }