private static void AddPlant(List <KMonoBehaviour> list, KMonoBehaviour plant) { if (plant?.GetComponent <ExtraSeedProducer>()?.ExtraSeedAvailable ?? false) { list.Add(plant); } }
private void OnSelectBuilding(BuildingDef def) { PlanScreen.RequirementsState requirementsState = BuildMenu.Instance.BuildableState(def); if (requirementsState == PlanScreen.RequirementsState.Complete || requirementsState == PlanScreen.RequirementsState.Materials) { if ((UnityEngine.Object)def != (UnityEngine.Object)selectedBuilding) { selectedBuilding = def; KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); } else { selectedBuilding = null; ClearSelection(); CloseRecipe(true); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false)); } } else { selectedBuilding = null; ClearSelection(); CloseRecipe(true); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false)); } onBuildingSelected(selectedBuilding); }
public static void OnAwake(KMonoBehaviour c) { Type type = c.GetType(); FieldData[] fields = GetFields(type); FieldData[] array = fields; foreach (FieldData fieldData in array) { CmpFns cmpFns = fieldData.cmpFns; FieldInfo fieldInfo = fieldData.fieldInfo; if (!((UnityEngine.Object)(Component) fieldInfo.GetValue(c) != (UnityEngine.Object)null)) { if (fieldData.myCmpType == MyCmpType.Add) { Component value = cmpFns.mFindOrAddFn(c); fieldInfo.SetValue(c, value); } else if (fieldData.myCmpType == MyCmpType.Req) { Component value2 = cmpFns.mFindFn(c); fieldInfo.SetValue(c, value2); } else if (fieldData.myCmpType == MyCmpType.Get) { Component value3 = cmpFns.mFindFn(c); fieldInfo.SetValue(c, value3); } } } }
private void ChangePersonalPriority(IPersonalPriorityManager priority_mgr, ChoreGroup chore_group, int delta, bool wrap_around) { if (priority_mgr.IsChoreGroupDisabled(chore_group)) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false)); } else { int personalPriority = priority_mgr.GetPersonalPriority(chore_group); personalPriority += delta; if (wrap_around) { personalPriority %= 6; if (personalPriority < 0) { personalPriority += 6; } } personalPriority = Mathf.Clamp(personalPriority, 0, 5); priority_mgr.SetPersonalPriority(chore_group, personalPriority); if (delta > 0) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); } else { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false)); } } }
public static void Postfix(KMonoBehaviour ___root, Tag[] tags) { if (!IsActive(tags)) { return; } try{ KAnimControllerBase kanim = ___root.GetComponent <KAnimControllerBase>(); if (kanim != null) { if (___root.name.ToString().StartsWith("BigSolidStorage")) { kanim.TintColour = defaultColor; CaiLib.Logger.Logger.Log(string.Concat("Updating Filterable Object Color:", ___root.name.ToString())); } if (___root.name.ToString().StartsWith("BigBeautifulStorage")) { kanim.TintColour = beautifulColor; CaiLib.Logger.Logger.Log(string.Concat("Updating Filterable Object Color:", ___root.name.ToString())); } } } catch (Exception ex) { CaiLib.Logger.Logger.Log(ex.ToString()); } }
private void OnHoverExitNosweat() { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Mouseover", false)); nosweatButtonSelectionFrame.SetAlpha(0f); nosweatButtonHeader.color = new Color(0.309803933f, 0.34117648f, 0.384313732f, 1f); descriptionArea.text = UI.FRONTEND.MODESELECTSCREEN.BLANK_DESC; }
private void ToggleOpen(bool play_sound) { if (!anyDiscovered) { if (play_sound) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false)); } } else if (!IsOpen) { if (play_sound) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Open", false)); } SetOpen(true); elements.LabelText.fontSize = (float)maximizedFontSize; elements.QuantityText.fontSize = (float)maximizedFontSize; } else { if (play_sound) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Close", false)); } SetOpen(false); elements.LabelText.fontSize = (float)minimizedFontSize; elements.QuantityText.fontSize = (float)minimizedFontSize; } }
private void OnHoverEnterNosweat() { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Mouseover", false)); nosweatButtonSelectionFrame.SetAlpha(1f); nosweatButtonHeader.color = new Color(0.7019608f, 0.3647059f, 0.533333361f, 1f); descriptionArea.text = UI.FRONTEND.MODESELECTSCREEN.NOSWEAT_DESC; }
public override void OnKeyDown(KButtonEvent e) { if (mouseOver && ConsumeMouseScroll && !e.TryConsume(Action.ZoomIn) && !e.TryConsume(Action.ZoomOut)) { goto IL_002e; } goto IL_002e; IL_002e: if (HasFocus) { if (e.TryConsume(Action.Escape)) { Game.Instance.Trigger(288942073, null); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Close", false)); } else { base.OnKeyDown(e); if (!e.Consumed) { Action action = e.GetAction(); if (action >= Action.BUILD_MENU_START_INTERCEPT) { e.TryConsume(action); } } } } }
private void OnClickCategory(ToggleInfo toggle_info) { UserData userData = (UserData)toggle_info.userData; PlanScreen.RequirementsState requirementsState = userData.requirementsState; if (requirementsState == PlanScreen.RequirementsState.Complete || requirementsState == PlanScreen.RequirementsState.Materials) { if (selectedCategory != userData.category) { selectedCategory = userData.category; KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); } else { selectedCategory = HashedString.Invalid; ClearSelection(); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Deselect", false)); } } else { selectedCategory = HashedString.Invalid; ClearSelection(); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false)); } toggle_info.toggle.GetComponent <PlanCategoryNotifications>().ToggleAttention(false); if (onCategoryClicked != null) { onCategoryClicked(selectedCategory, userData.depth); } }
protected override void OnDragTool(int cell, int distFromOrigin) { if (path.Count == 0) { return; } PathNode pathNode = path[path.Count - 1]; if (pathNode.cell == cell) { return; } placeSound = GlobalAssets.GetSound("Place_building_" + def.AudioSize, false); Vector3 pos = Grid.CellToPos(cell); EventInstance instance = SoundEvent.BeginOneShot(placeSound, pos); if (path.Count > 1) { int num = cell; PathNode pathNode2 = path[path.Count - 2]; if (num == pathNode2.cell) { if ((Object)previousCellConnection != (Object)null) { previousCellConnection.ConnectedEvent(previousCell); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("OutletDisconnected", false)); previousCellConnection = null; } previousCell = cell; CheckForConnection(cell, def.PrefabID, string.Empty, ref previousCellConnection, false); PathNode pathNode3 = path[path.Count - 1]; Object.Destroy(pathNode3.visualizer); PathNode pathNode4 = path[path.Count - 1]; TileVisualizer.RefreshCell(pathNode4.cell, def.TileLayer, def.ReplacementLayer); path.RemoveAt(path.Count - 1); buildingCount = ((buildingCount != 1) ? (buildingCount - 1) : (buildingCount = 14)); instance.setParameterValue("tileCount", (float)buildingCount); SoundEvent.EndOneShot(instance); goto IL_029c; } } if (!path.Exists((PathNode n) => n.cell == cell)) { bool valid = CheckValidPathPiece(cell); path.Add(new PathNode { cell = cell, visualizer = null, valid = valid }); CheckForConnection(cell, def.PrefabID, "OutletConnected", ref previousCellConnection, true); buildingCount = buildingCount % 14 + 1; instance.setParameterValue("tileCount", (float)buildingCount); SoundEvent.EndOneShot(instance); } goto IL_029c; IL_029c: visualizer.SetActive(path.Count < 2); ResourceRemainingDisplayScreen.instance.SetNumberOfPendingConstructions(path.Count); }
public void OnSelectBuilding(GameObject button_go, BuildingDef def) { if ((UnityEngine.Object)button_go == (UnityEngine.Object)null) { Debug.Log("Button gameObject is null", base.gameObject); } else if ((UnityEngine.Object)button_go == (UnityEngine.Object)selectedBuildingGameObject) { CloseRecipe(true); } else { ignoreToolChangeMessages++; selectedBuildingGameObject = button_go; currentlySelectedToggle = button_go.GetComponent <KToggle>(); KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); HashedString category = tagCategoryMap[def.Tag]; if (GetToggleEntryForCategory(category, out ToggleEntry toggleEntry) && toggleEntry.pendingResearchAttentions.Contains(def.Tag)) { toggleEntry.pendingResearchAttentions.Remove(def.Tag); button_go.GetComponent <PlanCategoryNotifications>().ToggleAttention(false); if (toggleEntry.pendingResearchAttentions.Count == 0) { toggleEntry.toggleInfo.toggle.GetComponent <PlanCategoryNotifications>().ToggleAttention(false); } } productInfoScreen.ClearProduct(false); ToolMenu.Instance.ClearSelection(); PrebuildTool.Instance.Activate(def, BuildableState(def)); productInfoScreen.Show(true); productInfoScreen.ConfigureScreen(def); ignoreToolChangeMessages--; } }
/// <summary> /// Checks to see if the item can be eaten by a critter. /// </summary> /// <param name="item">The item to check.</param> /// <param name="diet">The critter's diet.</param> /// <returns>true if the item is edible, or false otherwise.</returns> private static bool CanEatItem(KMonoBehaviour item, Diet diet) { bool edible = false; if (item.TryGetComponent(out KPrefabID pid) && (edible = CanEatItem(pid, diet)) && pid.HasAnyTags_AssumeLaundered(ref SolidConsumerMonitor.plantMask)) { float grown = 0.0f; // Trees are special cased in the Klei code if (item.TryGetComponent(out BuddingTrunk trunk)) { grown = trunk.GetMaxBranchMaturity(); } else { var maturity = Db.Get().Amounts.Maturity.Lookup(item); if (maturity != null) { grown = maturity.value / maturity.GetMax(); } } // Could not find this hardcoded constant in the Klei code if (grown < 0.25f) { edible = false; } } return(edible); }
private void OnAssignablesChanged(object data) { if (!target.IsNull()) { KMonoBehaviour kMonoBehaviour = (KMonoBehaviour)target; kMonoBehaviour.Trigger(-1585839766, data); } }
public Context(KMonoBehaviour cmp) { cell = Grid.PosToCell(cmp); navigator = cmp.GetComponent <Navigator>(); oxygenBreather = cmp.GetComponent <OxygenBreather>(); minionBrain = cmp.GetComponent <MinionBrain>(); temperatureTransferer = cmp.GetComponent <SimTemperatureTransfer>(); primaryElement = cmp.GetComponent <PrimaryElement>(); }
public static void Unsubscribe(this GameObject go, GameObject target, int hash, Action <object> handler) { KMonoBehaviour component = go.GetComponent <KMonoBehaviour>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.Unsubscribe(target, hash, handler); } }
public static void Unsubscribe(this GameObject go, int id) { KMonoBehaviour component = go.GetComponent <KMonoBehaviour>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { component.Unsubscribe(id); } }
/// <summary> /// Centers and selects an entity. /// </summary> /// <param name="entity">The entity to center and focus.</param> public static void CenterAndSelect(KMonoBehaviour entity) { if (entity != null) { Transform transform = entity.transform; SelectTool.Instance.SelectAndFocus(transform.transform.GetPosition(), transform.GetComponent <KSelectable>(), Vector3.zero); } }
public MeterController(KMonoBehaviour target, Meter.Offset front_back, Grid.SceneLayer user_specified_render_layer, params string[] symbols_to_hide) { string[] array = new string[symbols_to_hide.Length + 1]; Array.Copy(symbols_to_hide, array, symbols_to_hide.Length); array[array.Length - 1] = "meter_target"; KBatchedAnimController component = target.GetComponent <KBatchedAnimController>(); Initialize(component, "meter_target", "meter", front_back, user_specified_render_layer, Vector3.zero, array); }
protected void DisableProceedButton() { proceedButton.ClearOnClick(); proceedButton.isInteractable = false; proceedButton.onClick += delegate { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Negative", false)); }; }
private void FindClimbableTree() { climbTarget = null; ListPool <ScenePartitionerEntry, GameScenePartitioner> .PooledList pooledList = ListPool <ScenePartitionerEntry, GameScenePartitioner> .Allocate(); ListPool <KMonoBehaviour, ClimbableTreeMonitor> .PooledList pooledList2 = ListPool <KMonoBehaviour, ClimbableTreeMonitor> .Allocate(); Vector3 position = base.master.transform.GetPosition(); Extents extents = new Extents(Grid.PosToCell(position), 10); GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.plants, pooledList); GameScenePartitioner.Instance.GatherEntries(extents, GameScenePartitioner.Instance.completeBuildings, pooledList); Navigator component = GetComponent <Navigator>(); foreach (ScenePartitionerEntry item in pooledList) { KMonoBehaviour kMonoBehaviour = item.obj as KMonoBehaviour; if (!kMonoBehaviour.HasTag(GameTags.Creatures.ReservedByCreature)) { int cell = Grid.PosToCell(kMonoBehaviour); if (component.CanReach(cell)) { BuddingTrunk component2 = kMonoBehaviour.GetComponent <BuddingTrunk>(); StorageLocker component3 = kMonoBehaviour.GetComponent <StorageLocker>(); if ((Object)component2 != (Object)null) { if (!component2.ExtraSeedAvailable) { continue; } } else { if (!((Object)component3 != (Object)null)) { continue; } Storage component4 = component3.GetComponent <Storage>(); if (!component4.allowItemRemoval || component4.IsEmpty()) { continue; } } pooledList2.Add(kMonoBehaviour); } } } if (pooledList2.Count > 0) { int index = Random.Range(0, pooledList2.Count); KMonoBehaviour kMonoBehaviour2 = pooledList2[index]; climbTarget = kMonoBehaviour2.gameObject; } pooledList.Recycle(); pooledList2.Recycle(); }
protected override void OnDeactivateTool(InterfaceTool new_tool) { active = false; GridCompositor.Instance.ToggleMajor(false); HideToolTip(); ResourceRemainingDisplayScreen.instance.DeactivateDisplay(); Object.Destroy(visualizer); KMonoBehaviour.PlaySound(GlobalAssets.GetSound(GetDeactivateSound(), false)); base.OnDeactivateTool(new_tool); }
public static bool IsInTheRoom(KMonoBehaviour item, string roomId) { CavityInfo info = Game.Instance.roomProber.GetCavityForCell(Grid.PosToCell(item)); if (info == null || info.room == null || info.room.roomType == null) { return(false); } return(info.room.roomType.Id == roomId); }
public override void OnKeyDown(KButtonEvent e) { if (e.TryConsume(Action.Escape)) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click_Close")); Show(show: false); e.Consumed = true; } base.OnKeyDown(e); }
private void UpdateOverlaySounds() { string soundName = currentModeInfo.mode.GetSoundName(); if (soundName != string.Empty) { soundName = GlobalAssets.GetSound(soundName, false); KMonoBehaviour.PlaySound(soundName); } }
public static void DeleteObject(this GameObject go) { KMonoBehaviour component = go.GetComponent <KMonoBehaviour>(); if ((Object)component != (Object)null) { component.Trigger(1502190696, go); } Object.Destroy(go); }
public static void SpawnComponent(Component cmp) { if ((UnityEngine.Object)cmp != (UnityEngine.Object)null) { KMonoBehaviour kMonoBehaviour = cmp as KMonoBehaviour; if ((UnityEngine.Object)kMonoBehaviour != (UnityEngine.Object)null) { kMonoBehaviour.Spawn(); } } }
public void DeselectAndClose() { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("Back", false)); SelectTool.Instance.Select(null, false); if (!((UnityEngine.Object)target == (UnityEngine.Object)null)) { target = null; DeactivateSideContent(); Show(false); } }
private void OnPriorityPress(ChoreGroup chore_group) { bool flag = consumer.IsPermittedByUser(chore_group) ? true : false; string name = "HUD_Click"; if (flag) { name = "HUD_Click_Deselect"; } KMonoBehaviour.PlaySound(GlobalAssets.GetSound(name, false)); consumer.SetPermittedByUser(chore_group, !consumer.IsPermittedByUser(chore_group)); }
private void UnregisterEvents() { if (areEventsRegistered) { areEventsRegistered = false; KMonoBehaviour kMonoBehaviour = identityObject as KMonoBehaviour; if (!((UnityEngine.Object)kMonoBehaviour == (UnityEngine.Object)null)) { kMonoBehaviour.Unsubscribe(540773776, OnRoleChanged); } } }