private static void ReinitUpdateFeatureDefDatabase(IEnumerable <UpdateFeatureDef> defs) { // defs "inherited" from 1.0 through the folder versioning system are removed at this point DefDatabase <UpdateFeatureDef> .Clear(); DefDatabase <UpdateFeatureDef> .Add(defs); }
/** * Injects StockGenerators into existing traders. */ private void InjectTraderStocks() { var allInjectors = DefDatabase <TraderStockInjectorDef> .AllDefs; var affectedTraders = new List <TraderKindDef>(); foreach (var injectorDef in allInjectors) { if (injectorDef.traderDef == null || injectorDef.stockGenerators.Count == 0) { continue; } affectedTraders.Add(injectorDef.traderDef); foreach (var stockGenerator in injectorDef.stockGenerators) { injectorDef.traderDef.stockGenerators.Add(stockGenerator); } } if (affectedTraders.Count > 0) { Logger.Trace(string.Format("Injected stock generators for {0} traders", affectedTraders.Count)); } // Unless all defs are reloaded, we no longer need the injector defs DefDatabase <TraderStockInjectorDef> .Clear(); }
public static void PlayOneShot(this SoundDef soundDef, SoundInfo info) { if (!UnityData.IsInMainThread) { return; } if (soundDef == null) { Log.Error("Tried to PlayOneShot with null SoundDef. Info=" + info); return; } DebugSoundEventsLog.Notify_SoundEvent(soundDef, info); if (soundDef == null) { return; } if (soundDef.isUndefined) { if (Prefs.DevMode && Find.WindowStack.IsOpen(typeof(EditWindow_DefEditor))) { DefDatabase <SoundDef> .Clear(); DefDatabase <SoundDef> .AddAllInMods(); SoundDef soundDef2 = SoundDef.Named(soundDef.defName); if (!soundDef2.isUndefined) { soundDef2.PlayOneShot(info); } } return; } if (soundDef.sustain) { Log.Error("Tried to play sustainer SoundDef " + soundDef + " as a one-shot sound."); return; } if (!SoundSlotManager.CanPlayNow(soundDef.slot)) { return; } for (int i = 0; i < soundDef.subSounds.Count; i++) { soundDef.subSounds[i].TryPlay(info); } }
public static Sustainer TrySpawnSustainer(this SoundDef soundDef, SoundInfo info) { DebugSoundEventsLog.Notify_SoundEvent(soundDef, info); Sustainer result; if (soundDef == null) { result = null; } else if (soundDef.isUndefined) { if (Prefs.DevMode && Find.WindowStack.IsOpen(typeof(EditWindow_DefEditor))) { DefDatabase <SoundDef> .Clear(); DefDatabase <SoundDef> .AddAllInMods(); SoundDef soundDef2 = SoundDef.Named(soundDef.defName); if (!soundDef2.isUndefined) { return(soundDef2.TrySpawnSustainer(info)); } } result = null; } else if (!soundDef.sustain) { Log.Error("Tried to spawn a sustainer from non-sustainer sound " + soundDef + ".", false); result = null; } else if (!info.IsOnCamera && info.Maker.Thing != null && info.Maker.Thing.Destroyed) { result = null; } else { if (soundDef.sustainStartSound != null) { soundDef.sustainStartSound.PlayOneShot(info); } result = new Sustainer(soundDef, info); } return(result); }
public void StopSong() { try { currentState = false; if (JukeBoxCore.orignalSongList.Count <= 0) { JukeBoxCore.orignalSongList.AddRange(DefDatabase <SongDef> .AllDefs); Log.Message("OriginalSongList is Empty"); } DefDatabase <SongDef> .Clear(); DefDatabase <SongDef> .Add(JukeBoxCore.orignalSongList); Find.MusicManagerPlay.ForceStartSong(((CompProperties_JukeBox)props).stopSong, false); } catch (Exception ee) { Log.Error(ee.ToString()); } }
public void PlaySong() { currentState = true; if (JukeBoxCore.orignalSongList.Count <= 0) { JukeBoxCore.orignalSongList.AddRange(DefDatabase <SongDef> .AllDefs); } if (JukeBoxCore.customSongList.Count <= 0) { JukeBoxCore.Scanning(); if (JukeBoxCore.customSongList.Count <= 0) { Log.Error("Songs Folder is Empty"); return; } } DefDatabase <SongDef> .Clear(); DefDatabase <SongDef> .Add(JukeBoxCore.customSongList); Find.MusicManagerPlay.ForceStartSong(DefDatabase <SongDef> .GetRandom(), false); }
public override void PostExposeData() { //이미 존재하는 개체 base.PostExposeData(); if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs) { if (JukeBoxCore.orignalSongList.Count > 0) { DefDatabase <SongDef> .Clear(); DefDatabase <SongDef> .Add(JukeBoxCore.orignalSongList); } JukeBoxCore.jukeBoxList.Clear(); } if (Scribe.mode == LoadSaveMode.PostLoadInit) { compPowerTrader = parent.GetComp <CompPowerTrader>(); if (compPowerTrader.PowerOn) { JukeBoxCore.AddJukeBox(this); } currentState = false; } }
public static void CanDoNext_Prefix() { if (PokemonConfig.startWith) { DefDatabase<PawnKindDef>.Clear (); var hashSet = new HashSet<string>(); foreach (ModContentPack modContentPack in (from m in LoadedModManager.RunningMods orderby m.OverwritePriority select m).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x))){ hashSet.Clear(); foreach (PawnKindDef t in GenDefDatabase.DefsToGoInDatabase<PawnKindDef>(modContentPack)){ if (!modContentPack.IsCoreMod) { if (hashSet.Contains (t.defName)) { Log.Error (string.Concat (new object[] { "Mod ", modContentPack, " has multiple ", typeof(PawnKindDef), "s named ", t.defName, ". Skipping." })); } else { if (t.defName == "UnnamedDef") { var text = "Unnamed" + nameof(PawnKindDef) + Rand.Range (1, 100000).ToString () + "A"; Log.Error (string.Concat(new [] { nameof(PawnKindDef), " in ", modContentPack.ToString (), " with label ", t.label, " lacks a defName. Giving name ", text })); t.defName = text; } /*PawnKindDef def; if (DefDatabase<PawnKindDef>.defsByName.TryGetValue(t.defName, out def)){ DefDatabase<PawnKindDef>.Remove(def); }*/ DefDatabase<PawnKindDef>.Add (t); } } } } } else { DefDatabase<PawnKindDef>.Clear (); var hashSet = new HashSet<string>(); foreach (ModContentPack modContentPack in (from m in LoadedModManager.RunningMods orderby m.OverwritePriority select m).ThenBy((ModContentPack x) => LoadedModManager.RunningModsListForReading.IndexOf(x))){ hashSet.Clear(); foreach (PawnKindDef t in GenDefDatabase.DefsToGoInDatabase<PawnKindDef>(modContentPack)){ if (hashSet.Contains (t.defName)) { Log.Error (string.Concat (new object[] { "Mod ", modContentPack, " has multiple ", typeof(PawnKindDef), "s named ", t.defName, ". Skipping." })); } else { if (t.defName == "UnnamedDef") { var text = "Unnamed" + typeof(PawnKindDef).Name + Rand.Range (1, 100000).ToString () + "A"; Log.Error (string.Concat (new string[] { typeof(PawnKindDef).Name, " in ", modContentPack.ToString (), " with label ", t.label, " lacks a defName. Giving name ", text })); t.defName = text; } /*PawnKindDef def; if (DefDatabase<PawnKindDef>.defsByName.TryGetValue(t.defName, out def)){ DefDatabase<PawnKindDef>.Remove(def); }*/ DefDatabase<PawnKindDef>.Add (t); } } } } }