private void RenderVertex(SceneryEntry entry, SceneryVertex vertex) { if (vertex.Color < entry.Colors.Count) { SceneryColor color = entry.Colors[vertex.Color]; GL.Color3(color.Red, color.Green, color.Blue); } else { GL.Color3(Color.Fuchsia); } GL.Vertex3(entry.XOffset + vertex.X * 16, entry.YOffset + vertex.Y * 16, entry.ZOffset + vertex.Z * 16); }
void ModProcess() { Random rand = new Random(ModLoaderGlobals.RandomizerSeed); SceneryColor PantsColor = new SceneryColor(0, 0, 0); if (Option_RandPantsColor.Enabled) { PantsColor = new SceneryColor((byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256), 0); // just so that it doesn't affect gameplay randomizers rand = new Random(ModLoaderGlobals.RandomizerSeed); } if (Prop_PantsColor.HasChanged) { PantsColor = new SceneryColor((byte)Prop_PantsColor.R, (byte)Prop_PantsColor.G, (byte)Prop_PantsColor.B, 0); } bool CachingPass = false; if (Option_RandMusic.Enabled || Option_RandMusicTracks.Enabled || Option_RandMusicInstruments.Enabled) { CachingPass = true; } CrashTri_Common.ResetCache(); List <FileInfo> nsfs = new List <FileInfo>(); List <FileInfo> nsds = new List <FileInfo>(); DirectoryInfo di = new DirectoryInfo(ConsolePipeline.ExtractedPath); AppendFileInfoDir(nsfs, nsds, di); // this should return all NSF/NSD file pairs for (int i = 0; i < Math.Min(nsfs.Count, nsds.Count); ++i) { FileInfo nsfFile = nsfs[i]; FileInfo nsdFile = nsds[i]; if (Path.GetFileNameWithoutExtension(nsfFile.Name) != Path.GetFileNameWithoutExtension(nsdFile.Name)) { //MessageBox.Show($"NSF/NSD file pair mismatch. First mismatch:\n\n{nsfFile.Name}\n{nsdFile.Name}"); continue; } NSF nsf; NewNSD nsd; try { nsf = NSF.LoadAndProcess(File.ReadAllBytes(nsfFile.FullName), GameVersion.Crash3); nsd = NewNSD.Load(File.ReadAllBytes(nsdFile.FullName)); } catch (Exception ex) { if (ex is LoadAbortedException) { Console.WriteLine("Crash: LoadAbortedException: " + nsfFile.Name + "\n" + ex.Message); continue; //return; } else if (ex is LoadSkippedException) { Console.WriteLine("Crash: LoadSkippedException: " + nsfFile.Name + "\n" + ex.Message); continue; //return; } else { throw; } } Crash3_Levels NSF_Level = GetLevelFromNSF(nsfFile.Name); if (CachingPass) { if (Option_RandMusicTracks.Enabled) { CrashTri_Common.Cache_Music(nsf); } } else { if (Option_AllCratesWumpa.Enabled) { Crash3_Mods.Mod_TurnCratesIntoWumpa(nsf, rand); } if (Option_RandWarpRoom.Enabled) { Crash3_Mods.Mod_RandomizeWarpRoom(nsf, nsd, NSF_Level, rand); } if (Option_BackwardsLevels.Enabled || Option_RandBackwardsLevels.Enabled) { Crash3_Mods.Mod_BackwardsLevels(nsf, nsd, NSF_Level, Option_RandBackwardsLevels.Enabled, rand); } if (Option_CameraBigFOV.Enabled || Option_RandCameraFOV.Enabled) { Crash3_Mods.Mod_CameraFOV(nsf, rand, Option_RandCameraFOV.Enabled); } if (Option_AllCratesBlank.Enabled) { Crash3_Mods.Mod_AllWoodCrates(nsf, rand); } if (Option_RandCrates.Enabled) { Crash3_Mods.Rand_WoodenCrates(nsf, rand, NSF_Level); } if (Option_RandBosses.Enabled) { Crash3_Mods.Mod_RandomizeBosses(nsf, nsd, NSF_Level, rand, false); } if (Option_RandFlyingLevels.Enabled) { Crash3_Mods.Mod_RandomizeFlyingLevels(nsf, nsd, NSF_Level, rand, false); } if (Option_RandBoxCount.Enabled) { Crash3_Mods.Rand_BoxCount(nsf, rand, NSF_Level); } if (Option_AllEnemiesMissing.Enabled) { Crash3_Mods.Mod_RemoveEnemies(nsf, rand, NSF_Level, false); } if (Option_RandEnemiesAreCrates.Enabled) { Crash3_Mods.Mod_EnemyCrates(nsf, rand, NSF_Level, true); } if (Option_AllEnemiesAreCrates.Enabled) { Crash3_Mods.Mod_EnemyCrates(nsf, rand, NSF_Level, false); } if (Option_RandEnemiesMissing.Enabled) { Crash3_Mods.Mod_RemoveEnemies(nsf, rand, NSF_Level, true); } if (Option_RandCratesMissing.Enabled) { Crash3_Mods.Rand_CratesMissing(nsf, rand); } if (Option_RandCrateContents.Enabled) { Crash3_Mods.Mod_RandomCrateContents(nsf, rand); } if (Option_RandCrateParams.Enabled) { Crash3_Mods.Mod_RandomCrateParams(nsf, rand, NSF_Level); } if (Option_RandInvisibleCrates.Enabled) { Crash3_Mods.Mod_InvisibleCrates(nsf, rand, NSF_Level, true); } if (Option_InvisibleCrates.Enabled) { Crash3_Mods.Mod_InvisibleCrates(nsf, rand, NSF_Level, false); } if (Option_RemoveWarpRoomBarriers.Enabled) { Crash3_Mods.Mod_RemoveBarriers(nsf, NSF_Level); } if (Option_RandWorldPalette.Enabled) { CrashTri_Common.Mod_Scenery_Swizzle(nsf, rand); } if (Option_GreyscaleWorld.Enabled) { CrashTri_Common.Mod_Scenery_Greyscale(nsf); } if (Option_RandWorldColors.Enabled) { CrashTri_Common.Mod_Scenery_Rainbow(nsf, rand); } if (Option_UntexturedWorld.Enabled) { CrashTri_Common.Mod_Scenery_Untextured(nsf); } if (Option_RandWorldTex.Enabled) { CrashTri_Common.Mod_RandomizeWGEOTex(nsf, rand); } if (Option_RandPantsColor.Enabled || Prop_PantsColor.HasChanged) { Crash3_Mods.Mod_PantsColor(nsf, PantsColor); } if (Option_RandObjCol.Enabled) { CrashTri_Common.Mod_RandomizeTGEOCol(nsf, rand); } if (Option_AllCratesAshed.Enabled) { Crash3_Mods.Mod_AshedCrates(nsf, rand, false); } if (Option_RandCratesAshed.Enabled) { Crash3_Mods.Mod_AshedCrates(nsf, rand, true); } if (Option_RandObjTex.Enabled) { CrashTri_Common.Mod_RandomizeTGEOTex(nsf, rand); } if (NSF_Level != Crash3_Levels.Unknown && Option_RandMusicTracks.Enabled) { CrashTri_Common.Randomize_Music(nsf, rand); } if (Option_RandSounds.Enabled) { CrashTri_Common.Mod_RandomizeADIO(nsf, rand); } if (Option_RandStreams.Enabled) { CrashTri_Common.Mod_RandomizeSDIO(nsf, rand); } if (Option_RandObjPalette.Enabled) { CrashTri_Common.Mod_SwizzleObjectColors(nsf, rand); } if (Option_UntexturedObj.Enabled) { CrashTri_Common.Mod_RemoveTGEOTex(nsf, rand); } if (Option_UncoloredObj.Enabled) { CrashTri_Common.Mod_RemoveObjectColors(nsf, rand); } Crash3_Mods.Mod_Metadata(nsf, nsd, NSF_Level, GameRegion.Region); } PatchNSD(nsf, nsd); File.WriteAllBytes(nsfFile.FullName, nsf.Save()); File.WriteAllBytes(nsdFile.FullName, nsd.Save()); if (CachingPass && i == Math.Min(nsfs.Count, nsds.Count) - 1) { CachingPass = false; i = -1; } } }