private void OnRecipeElementsFullySelected() { BuildingDef buildingDef = null; foreach (KeyValuePair <BuildingDef, KToggle> activeToggle in ActiveToggles) { if ((UnityEngine.Object)activeToggle.Value == (UnityEngine.Object)currentlySelectedToggle) { buildingDef = activeToggle.Key; break; } } DebugUtil.DevAssert(buildingDef, "def is null"); if ((bool)buildingDef) { if (buildingDef.isKAnimTile && buildingDef.isUtility) { IList <Tag> getSelectedElementAsList = productInfoScreen.materialSelectionPanel.GetSelectedElementAsList; BaseUtilityBuildTool baseUtilityBuildTool = (!((UnityEngine.Object)buildingDef.BuildingComplete.GetComponent <Wire>() != (UnityEngine.Object)null)) ? ((BaseUtilityBuildTool)UtilityBuildTool.Instance) : ((BaseUtilityBuildTool)WireBuildTool.Instance); baseUtilityBuildTool.Activate(buildingDef, getSelectedElementAsList); } else { BuildTool.Instance.Activate(buildingDef, productInfoScreen.materialSelectionPanel.GetSelectedElementAsList, null); } } }
private void StartConsuming() { DebugUtil.DevAssert(!isBeingConsumed, "Can't StartConsuming()...we've already started"); isBeingConsumed = true; consumptionTime = 0f; base.worker.Trigger(1406130139, this); }
public void ContractGerms(string germ_id) { ExposureState exposureState = GetExposureState(germ_id); DebugUtil.DevAssert(exposureState == ExposureState.Exposed, "Duplicant is contracting a sickness but was never exposed to it!"); SetExposureState(germ_id, ExposureState.Contracted); }
public void FullRefresh() { if (base.isSpawned && base.isActiveAndEnabled) { DebugUtil.DevAssert(isRegistered, "shouldn't be refreshing if we aren't spawned and enabled"); RefreshShapeAndPosition(); emitter.Refresh(pending_emitter_state, true); } }
private bool DoTalking(Conversation setup, MinionIdentity new_speaker) { DebugUtil.Assert(setup != null, "setup was null"); DebugUtil.Assert((UnityEngine.Object)new_speaker != (UnityEngine.Object)null, "new_speaker was null"); if ((UnityEngine.Object)setup.lastTalked != (UnityEngine.Object)null) { setup.lastTalked.Trigger(25860745, setup.lastTalked.gameObject); } DebugUtil.Assert(setup.conversationType != null, "setup.conversationType was null"); Conversation.Topic nextTopic = setup.conversationType.GetNextTopic(new_speaker, setup.lastTopic); if (nextTopic == null || nextTopic.mode == Conversation.ModeType.End || nextTopic.mode == Conversation.ModeType.Segue) { return(false); } Thought thoughtForTopic = GetThoughtForTopic(setup, nextTopic); if (thoughtForTopic == null) { return(false); } ThoughtGraph.Instance sMI = new_speaker.GetSMI <ThoughtGraph.Instance>(); if (sMI == null) { return(false); } sMI.AddThought(thoughtForTopic); setup.lastTopic = nextTopic; setup.lastTalked = new_speaker; setup.lastTalkedTime = GameClock.Instance.GetTime(); DebugUtil.Assert(lastConvoTimeByMinion != null, "lastConvoTimeByMinion was null"); lastConvoTimeByMinion[setup.lastTalked] = GameClock.Instance.GetTime(); Effects component = setup.lastTalked.GetComponent <Effects>(); DebugUtil.Assert((UnityEngine.Object)component != (UnityEngine.Object)null, "effects was null"); component.Add("GoodConversation", true); Conversation.Mode mode = Conversation.Topic.Modes[(int)nextTopic.mode]; DebugUtil.Assert(mode != null, "mode was null"); StartedTalkingEvent startedTalkingEvent = new StartedTalkingEvent(); startedTalkingEvent.talker = new_speaker.gameObject; startedTalkingEvent.anim = mode.anim; StartedTalkingEvent data = startedTalkingEvent; foreach (MinionIdentity minion in setup.minions) { if (!(bool)minion) { DebugUtil.DevAssert(false, "minion in setup.minions was null"); } else { minion.Trigger(-594200555, data); } } setup.numUtterances++; return(true); }
public void RegisterBatchUpdate <UpdateInterface, T>(UpdateBucketWithUpdater <UpdateInterface> .BatchUpdateDelegate batch_update) { string text = MakeBucketId(typeof(T), GetUpdateRate <UpdateInterface>()); Entry value = ManifestEntry <UpdateInterface>(text, false); DebugUtil.DevAssert(GetImplementedInterfaces(typeof(T)).Contains(GetUpdateRate <UpdateInterface>()), "T does not implement the UpdateInterface it is registering for BatchUpdate under"); DebugUtil.DevAssert(value.buckets.Length == 1, "don't do a batch update with load balancing because load balancing will produce many small batches which is inefficient"); ((UpdateBucketWithUpdater <UpdateInterface>)value.buckets[0]).batch_update_delegate = batch_update; bucketTable[text] = value; }
public void UpdateMods(IEnumerable <PublishedFileId_t> added, IEnumerable <PublishedFileId_t> updated, IEnumerable <PublishedFileId_t> removed, IEnumerable <SteamUGCService.Mod> loaded_previews) { foreach (PublishedFileId_t item in added) { SteamUGCService.Mod mod = SteamUGCService.Instance.FindMod(item); if (mod == null) { DebugUtil.DevAssert(false, "SteamUGCService just told us this id was valid!"); } else { Mod mod2 = MakeMod(mod); if (mod2 != null) { Global.Instance.modManager.Subscribe(mod2, this); } } } foreach (PublishedFileId_t item2 in updated) { SteamUGCService.Mod mod3 = SteamUGCService.Instance.FindMod(item2); if (mod3 == null) { DebugUtil.DevAssert(false, "SteamUGCService just told us this id was valid!"); } else { Mod mod4 = MakeMod(mod3); if (mod4 != null) { Global.Instance.modManager.Update(mod4, this); } } } foreach (PublishedFileId_t item3 in removed) { PublishedFileId_t current3 = item3; Global.Instance.modManager.Unsubscribe(new Label { id = current3.m_PublishedFileId.ToString(), distribution_platform = Label.DistributionPlatform.Steam }, this); } if (added.Count() != 0) { Global.Instance.modManager.Sanitize(null); } else { Global.Instance.modManager.Report(null); } }
public bool NeedsToPee() { DebugUtil.DevAssert(base.master != null, "master ref null"); DebugUtil.DevAssert(!base.master.isNull, "master isNull"); KPrefabID component = base.master.GetComponent <KPrefabID>(); DebugUtil.DevAssert(component, "kpid was null"); if (component.HasTag(GameTags.Asleep)) { return(false); } return(bladder.value >= 100f); }
public void AddToGrid(bool update_lit_cells) { DebugUtil.DevAssert(!update_lit_cells || litCells.Count == 0, "adding an already added emitter"); if (update_lit_cells) { UpdateLitCells(); } foreach (int litCell in litCells) { int num = Mathf.Max(0, Grid.LightCount[litCell] + ComputeLux(litCell)); Grid.LightCount[litCell] = num; previewLux[litCell] = num; } }
private Thought GetThoughtForTopic(Conversation setup, Conversation.Topic topic) { if (string.IsNullOrEmpty(topic.topic)) { DebugUtil.DevAssert(false, "topic.topic was null"); return(null); } Sprite sprite = setup.conversationType.GetSprite(topic.topic); if ((UnityEngine.Object)sprite != (UnityEngine.Object)null) { Conversation.Mode mode = Conversation.Topic.Modes[(int)topic.mode]; return(new Thought("Topic_" + topic.topic, null, sprite, mode.icon, mode.voice, "bubble_chatter", mode.mouth, DUPLICANTS.THOUGHTS.CONVERSATION.TOOLTIP, true, TuningData <Tuning> .Get().speakTime)); } return(null); }
public void PlayDynamicMusic() { if (DynamicMusicIsActive()) { Log("Trying to play DynamicMusic when it is already playing."); } else { string nextDynamicSong = GetNextDynamicSong(); if (!(nextDynamicSong == "NONE")) { PlaySong(nextDynamicSong, false); if (activeSongs.TryGetValue(nextDynamicSong, out SongInfo value)) { activeDynamicSong = value; AudioMixer.instance.Start(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot); if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null && SpeedControlScreen.Instance.IsPaused) { SetDynamicMusicPaused(); } if ((UnityEngine.Object)OverlayScreen.Instance != (UnityEngine.Object)null && OverlayScreen.Instance.mode != OverlayModes.None.ID) { SetDynamicMusicOverlayActive(); } SetDynamicMusicPlayHook(); string key = "Volume_Music"; if (KPlayerPrefs.HasKey(key)) { float @float = KPlayerPrefs.GetFloat(key); AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "userVolume_Music", @float, true); } AudioMixer.instance.SetSnapshotParameter(AudioMixerSnapshots.Get().DynamicMusicPlayingSnapshot, "intensity", value.sfxAttenuationPercentage / 100f, true); } else { Log("DynamicMusic song " + nextDynamicSong + " did not start."); string text = string.Empty; foreach (KeyValuePair <string, SongInfo> activeSong in activeSongs) { text = text + activeSong.Key + ", "; Debug.Log(text); } DebugUtil.DevAssert(false, "Song failed to play: " + nextDynamicSong); } } } }
public static GameObject ExtendEntityToFertileCreature(GameObject prefab, string eggId, string eggName, string eggDesc, string egg_anim, float egg_mass, string baby_id, float fertility_cycles, float incubation_cycles, List <FertilityMonitor.BreedingChance> egg_chances, int eggSortOrder = -1, bool is_ranchable = true, bool add_fish_overcrowding_monitor = false, bool add_fixed_capturable_monitor = true, float egg_anim_scale = 1f) { FertilityMonitor.Def def = prefab.AddOrGetDef <FertilityMonitor.Def>(); def.baseFertileCycles = fertility_cycles; DebugUtil.DevAssert(eggSortOrder > -1, "Added a fertile creature without an egg sort order!"); float base_incubation_rate = 100f / (600f * incubation_cycles); GameObject gameObject = EggConfig.CreateEgg(eggId, eggName, eggDesc, baby_id, egg_anim, egg_mass, eggSortOrder, base_incubation_rate); def.eggPrefab = new Tag(eggId); def.initialBreedingWeights = egg_chances; if (egg_anim_scale != 1f) { KBatchedAnimController component = gameObject.GetComponent <KBatchedAnimController>(); component.animWidth = egg_anim_scale; component.animHeight = egg_anim_scale; } KPrefabID egg_prefab_id = gameObject.GetComponent <KPrefabID>(); SymbolOverrideController symbol_override_controller = SymbolOverrideControllerUtil.AddToPrefab(gameObject); string symbolPrefix = prefab.GetComponent <CreatureBrain>().symbolPrefix; if (!string.IsNullOrEmpty(symbolPrefix)) { symbol_override_controller.ApplySymbolOverridesByAffix(Assets.GetAnim(egg_anim), symbolPrefix, null, 0); } KPrefabID creature_prefab_id = prefab.GetComponent <KPrefabID>(); creature_prefab_id.prefabSpawnFn += delegate { WorldInventory.Instance.Discover(eggId.ToTag(), WorldInventory.GetCategoryForTags(egg_prefab_id.Tags)); WorldInventory.Instance.Discover(baby_id.ToTag(), WorldInventory.GetCategoryForTags(creature_prefab_id.Tags)); }; if (is_ranchable) { prefab.AddOrGetDef <RanchableMonitor.Def>(); } if (add_fixed_capturable_monitor) { prefab.AddOrGetDef <FixedCapturableMonitor.Def>(); } if (add_fish_overcrowding_monitor) { gameObject.AddOrGetDef <FishOvercrowdingMonitor.Def>(); } return(prefab); }
private void StopConsuming(Worker worker) { DebugUtil.DevAssert(isBeingConsumed, "StopConsuming() called without StartConsuming()"); isBeingConsumed = false; if (float.IsNaN(consumptionTime)) { DebugUtil.DevAssert(false, "consumptionTime NaN in StopConsuming()"); } else { PrimaryElement component = base.gameObject.GetComponent <PrimaryElement>(); if ((Object)component != (Object)null && component.DiseaseCount > 0) { new EmoteChore(worker.GetComponent <ChoreProvider>(), Db.Get().ChoreTypes.EmoteHighPriority, "anim_react_contaminated_food_kanim", new HashedString[1] { "react" }, null); } float num = Mathf.Clamp01(consumptionTime / GetFeedingTime(worker)); unitsConsumed = Units * num; if (float.IsNaN(unitsConsumed)) { KCrashReporter.Assert(false, "Why is unitsConsumed NaN?"); unitsConsumed = Units; } caloriesConsumed = unitsConsumed * foodInfo.CaloriesPerUnit; Units -= unitsConsumed; for (int i = 0; i < foodInfo.Effects.Count; i++) { worker.GetComponent <Effects>().Add(foodInfo.Effects[i], true); } ReportManager.Instance.ReportValue(ReportManager.ReportType.CaloriesCreated, 0f - caloriesConsumed, StringFormatter.Replace(UI.ENDOFDAYREPORT.NOTES.EATEN, "{0}", this.GetProperName()), worker.GetProperName()); AddQualityEffects(worker); worker.Trigger(1121894420, this); Trigger(-10536414, worker.gameObject); unitsConsumed = float.NaN; caloriesConsumed = float.NaN; consumptionTime = float.NaN; if (Units <= 0f) { base.gameObject.DeleteObject(); } } }
public void Update(Mod mod, object caller) { Debug.LogFormat("Update mod {0}", mod.title); Mod mod2 = mods.Find((Mod candidate) => mod.label.Match(candidate.label)); DebugUtil.DevAssert(!string.IsNullOrEmpty(mod2.label.id), "Should be subscribed to a mod we are getting an Update notification for"); if (mod2.status != Mod.Status.UninstallPending) { events.Add(new Event { event_type = EventType.VersionUpdate, mod = mod.label }); string root = mod.file_source.GetRoot(); mod2.CopyPersistentDataTo(mod); mod.is_subscribed = mod2.is_subscribed; int index = mods.IndexOf(mod2); mods.RemoveAt(index); mods.Insert(index, mod); if (mod.enabled) { mod.reinstall_path = root; mod.status = Mod.Status.ReinstallPending; events.Add(new Event { event_type = EventType.RestartRequested, mod = mod.label }); } else { Uninstall(mod); Install(mod); } dirty = true; Update(caller); } }
public GameObject CreatePrefab() { //GameObject prefab = null; string eggId = "UnknownEgg"; string eggName = "Unknown Egg"; string eggDesc = "Unknown Egg"; string egg_anim = "floral_hatch_egg_kanim"; float egg_mass = 1f; string baby_id = BabyHatchConfig.ID; float fertility_cycles = 20.0f; float incubation_cycles = 1f; List <FertilityMonitor.BreedingChance> egg_chances = null; int eggSortOrder = 999; bool is_ranchable = false; bool add_fish_overcrowding_monitor = false; bool add_fixed_capturable_monitor = true; float egg_anim_scale = 1f; //FertilityMonitor.Def def = prefab.AddOrGetDef<FertilityMonitor.Def>(); //def.baseFertileCycles = fertility_cycles; DebugUtil.DevAssert(eggSortOrder > -1, "Added a fertile creature without an egg sort order!"); float base_incubation_rate = (float)(100.0 / (600.0 * (double)incubation_cycles)); GameObject egg = EggConfig.CreateEgg(eggId, eggName, eggDesc, (Tag)baby_id, egg_anim, egg_mass, eggSortOrder, base_incubation_rate); //def.eggPrefab = new Tag(eggId); //def.initialBreedingWeights = egg_chances; if ((double)egg_anim_scale != 1.0) { KBatchedAnimController component = egg.GetComponent <KBatchedAnimController>(); component.animWidth = egg_anim_scale; component.animHeight = egg_anim_scale; } KPrefabID egg_prefab_id = egg.GetComponent <KPrefabID>(); return(egg); }