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); }
private static void UpdateNPCFactions(ref SpeciesControl speciesControl) { if (speciesControl.Pirate) { UpdateNPCFaction("Pirate", speciesControl.Label); } if (speciesControl.Outlander) { UpdateNPCFaction("OutlanderCivil", speciesControl.Label); UpdateNPCFaction("OutlanderRough", speciesControl.Label); } if (speciesControl.Tribal) { UpdateNPCFaction("TribeCivil", speciesControl.Label); UpdateNPCFaction("TribeRough", speciesControl.Label); UpdateNPCFaction("TribeSavage", speciesControl.Label); } DefDatabase <FactionDef> .AddAllInMods(); if (Factions.IsStarWarsFactionsLoaded()) { if (speciesControl.Rebels) { UpdateNPCFaction("PJ_RebelFac", speciesControl.Label); } if (speciesControl.Scum) { UpdateNPCFaction("PJ_Bounty", speciesControl.Label); } if (speciesControl.Empire) { UpdateNPCFaction("PJ_GalacticEmpire", speciesControl.Label); } } }
static Main() { // var harmony = HarmonyInstance.Create("humanlike.life.stages"); // harmony.PatchAll(Assembly.GetExecutingAssembly()); DefDatabase <PokedexDef> .AddAllInMods(); //Log.Error("Starting the Pokemon Rap!"); foreach (var pokedexDef in DefDatabase <PokedexDef> .AllDefs) { ThingDef thingDef = DefDatabase <ThingDef> .GetNamed(pokedexDef.defName); PawnKindDef pawnKindDef = DefDatabase <PawnKindDef> .GetNamed(pokedexDef.defName); if (thingDef == null) { Error(pokedexDef, "No thing def"); continue; } if (pawnKindDef == null) { Error(pokedexDef, "No thing def"); continue; } SetupSounds(thingDef, pokedexDef); thingDef.race.trainability = TrainabilityDefOf.Advanced; thingDef.race.baseBodySize = pokedexDef.Mass / 50f; var healthScale = 1f * pokedexDef.HP / Pokemon.latest.BaseStat + 1f * pokedexDef.Def / Pokemon.latest.BaseStat / 2F + 1f * pokedexDef.SpD / Pokemon.latest.BaseStat / 2F; thingDef.race.baseHealthScale *= healthScale; GetAddStatDef(thingDef, StatDefOf.MarketValue).value *= pokedexDef.Total / Pokemon.latest.BaseStat; GetAddStatDef(thingDef, StatDefOf.MaxHitPoints).value = healthScale; GetAddStatDef(thingDef, StatDefOf.MoveSpeed).value = 3.5f * pokedexDef.Spe / Pokemon.latest.BaseStat; GetAddStatDef(thingDef, StatDefOf.ArmorRating_Blunt).value = pokedexDef.Def / Pokemon.latest.BaseStat * 10f; GetAddStatDef(thingDef, StatDefOf.ArmorRating_Heat).value = pokedexDef.SpD / Pokemon.latest.BaseStat * 10f; GetAddStatDef(thingDef, StatDefOf.ArmorRating_Sharp).value = pokedexDef.Def / Pokemon.latest.BaseStat * 10f; foreach (var tool in thingDef.tools) { if (tool.untranslatedLabel.Contains("special")) { tool.power *= 1f * pokedexDef.SpA / Pokemon.latest.BaseStat; } else { tool.power *= 1f * pokedexDef.Atk / Pokemon.latest.BaseStat; } } // Log.Message("Setup " + thingDef.label); } }