예제 #1
0
        public RoomTypeNurseryData()
        {
            Id                = RoomId;
            Name              = STRINGS.ROOMS.TYPES.NURSERY.NAME;
            Tooltip           = STRINGS.ROOMS.TYPES.NURSERY.TOOLTIP;
            Effect            = STRINGS.ROOMS.TYPES.NURSERY.EFFECT;
            Catergory         = Db.Get().RoomTypeCategories.Agricultural;
            ConstraintPrimary = new RoomConstraints.Constraint((Func <KPrefabID, bool>)(bc => bc.HasTag(RoomConstraintTags.NurseryPlanterBoxTag)),
                                                               (Func <Room, bool>)null,
                                                               name: STRINGS.ROOMS.CRITERIA.PLANTERBOX.NAME,
                                                               description: STRINGS.ROOMS.CRITERIA.PLANTERBOX.DESCRIPTION);

            ConstrantsAdditional = new RoomConstraints.Constraint[4] {
                new RoomConstraints.Constraint((Func <KPrefabID, bool>)null,
                                               (Func <Room, bool>)(room =>
                {
                    List <string> seedIds = new List <string>();
                    foreach (var plant in room.cavity.plants)
                    {
                        if (plant == null)
                        {
                            continue;
                        }
                        SeedProducer seedProd = plant.GetComponent <SeedProducer>();
                        WiltCondition wiltCon = plant.GetComponent <WiltCondition>();
                        if (seedProd == null)
                        {
                            continue;
                        }
                        if (!seedIds.Contains(seedProd.seedInfo.seedId) &&
                            seedProd.seedInfo.productionType == SeedProducer.ProductionType.Harvest)
                        {
                            seedIds.Add(seedProd.seedInfo.seedId);
                        }
                    }
                    return(seedIds.Count >= requiredNumberOfPlants);
                }),
                                               name: string.Format(STRINGS.ROOMS.CRITERIA.SEEDPLANTS.NAME, requiredNumberOfPlants),
                                               description: string.Format(STRINGS.ROOMS.CRITERIA.SEEDPLANTS.DESCRIPTION, requiredNumberOfPlants)),
                RoomConstraints.LIGHT,
                RoomConstraints.MINIMUM_SIZE_12,
                RoomConstraintTags.GetMaxSizeConstraint(Settings.Instance.Nursery.MaxSize)
            };

            RoomDetails = new RoomDetails.Detail[2]
            {
                new RoomDetails.Detail((Func <Room, string>)(room => string.Format((string)ROOMS.DETAILS.SIZE.NAME, (object)room.cavity.numCells))),
                new RoomDetails.Detail((Func <Room, string>)(room => string.Format((string)ROOMS.DETAILS.PLANT_COUNT.NAME, (object)room.plants.Count)))
            };

            Priority       = 0;
            Upgrades       = null;
            SingleAssignee = false;
            PriorityUse    = false;
            Effects        = null;
            SortKey        = SortingCounter.GetAndIncrement(SortingCounter.FarmSortKey - 1);
        }
            /// <summary>
            /// Applied after DoWilt runs.
            /// </summary>
            internal static void Postfix(WiltCondition __instance)
            {
                var obj = __instance.gameObject;

                if (obj != null)
                {
                    // Update rooms if plants grow/recover
                    Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(obj), true);
                }
            }
			/// <summary>
			/// Applied after DoRecover runs.
			/// </summary>
			internal static void Postfix(WiltCondition __instance) {
				var obj = __instance.gameObject;
				var prober = Game.Instance.roomProber;
				if (obj != null && prober != null) {
					var room = prober.GetRoomOfGameObject(obj)?.roomType;
					// Only need to re-evaluate, if the room is a miscellaneous room
					if (room == Db.Get().RoomTypes.Neutral)
						// Update that room
						Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(obj), true);
				}
			}
			/// <summary>
			/// Applied after DoWilt runs.
			/// </summary>
			internal static void Postfix(WiltCondition __instance) {
				var obj = __instance.gameObject;
				var prober = Game.Instance.roomProber;
				if (obj != null && prober != null) {
					var room = prober.GetRoomOfGameObject(obj)?.roomType;
					// Only need to re-evaluate, if the room is a park or a nature reserve
					var types = Db.Get().RoomTypes;
					if (room == types.Park || room == types.NatureReserve)
						// Update that room
						prober.SolidChangedEvent(Grid.PosToCell(obj), true);
				}
			}
 public override void InitializeStates(out BaseState default_state)
 {
     default_state     = exchanging;
     base.serializable = true;
     exchanging.Enter(delegate(StatesInstance smi)
     {
         WiltCondition component = smi.master.gameObject.GetComponent <WiltCondition>();
         if ((UnityEngine.Object)component != (UnityEngine.Object)null && component.IsWilting())
         {
             smi.GoTo(smi.sm.paused);
         }
     }).EventTransition(GameHashes.Wilt, paused, null).ToggleStatusItem(Db.Get().CreatureStatusItems.ExchangingElementConsume, (object)null)
     .ToggleStatusItem(Db.Get().CreatureStatusItems.ExchangingElementOutput, (object)null)
     .Update("EntityElementExchanger", delegate(StatesInstance smi, float dt)
     {
         HandleVector <Game.ComplexCallbackInfo <Sim.MassConsumedCallback> > .Handle handle = Game.Instance.massConsumedCallbackManager.Add(OnSimConsumeCallback, smi.master, "EntityElementExchanger");
         SimMessages.ConsumeMass(Grid.PosToCell(smi.master.gameObject), smi.master.consumedElement, smi.master.consumeRate * dt, 3, handle.index);
     }, UpdateRate.SIM_1000ms, false);
     paused.EventTransition(GameHashes.WiltRecover, exchanging, null);
 }
예제 #6
0
    private void SetPanels(GameObject target)
    {
        MinionIdentity            component  = target.GetComponent <MinionIdentity>();
        Amounts                   amounts    = target.GetAmounts();
        PrimaryElement            component2 = target.GetComponent <PrimaryElement>();
        BuildingComplete          component3 = target.GetComponent <BuildingComplete>();
        BuildingUnderConstruction component4 = target.GetComponent <BuildingUnderConstruction>();
        CellSelectionObject       component5 = target.GetComponent <CellSelectionObject>();
        InfoDescription           component6 = target.GetComponent <InfoDescription>();
        Edible component7 = target.GetComponent <Edible>();

        attributeLabels.ForEach(delegate(LocText x)
        {
            UnityEngine.Object.Destroy(x.gameObject);
        });
        attributeLabels.Clear();
        vitalsPanel.gameObject.SetActive(amounts != null);
        string text  = string.Empty;
        string text2 = string.Empty;

        if (amounts != null)
        {
            vitalsContainer.selectedEntity = selectedTarget;
            Uprootable component8 = selectedTarget.gameObject.GetComponent <Uprootable>();
            if ((UnityEngine.Object)component8 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive((UnityEngine.Object)component8.GetPlanterStorage != (UnityEngine.Object)null);
            }
            WiltCondition component9 = selectedTarget.gameObject.GetComponent <WiltCondition>();
            if ((UnityEngine.Object)component9 != (UnityEngine.Object)null)
            {
                vitalsPanel.gameObject.SetActive(true);
            }
        }
        if ((bool)component)
        {
            text = string.Empty;
        }
        else if ((bool)component6)
        {
            text = component6.description;
        }
        else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            text  = component3.Def.Effect;
            text2 = component3.Def.Desc;
        }
        else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
        {
            text  = component4.Def.Effect;
            text2 = component4.Def.Desc;
        }
        else if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
        {
            EdiblesManager.FoodInfo foodInfo = component7.FoodInfo;
            text += string.Format(UI.GAMEOBJECTEFFECTS.CALORIES, GameUtil.GetFormattedCalories(foodInfo.CaloriesPerUnit, GameUtil.TimeSlice.None, true));
        }
        else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
        {
            text = component5.element.FullDescription(false);
        }
        else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            Element element = ElementLoader.FindElementByHash(component2.ElementID);
            text = ((element == null) ? string.Empty : element.FullDescription(false));
        }
        List <Descriptor> gameObjectEffects = GameUtil.GetGameObjectEffects(target, true);
        bool flag = gameObjectEffects.Count > 0;

        descriptionContainer.gameObject.SetActive(flag);
        descriptionContainer.descriptors.gameObject.SetActive(flag);
        if (flag)
        {
            descriptionContainer.descriptors.SetDescriptors(gameObjectEffects);
        }
        descriptionContainer.description.text = text;
        descriptionContainer.flavour.text     = text2;
        infoPanel.gameObject.SetActive((UnityEngine.Object)component == (UnityEngine.Object)null);
        descriptionContainer.gameObject.SetActive(infoPanel.activeSelf);
        descriptionContainer.flavour.gameObject.SetActive(text2 != string.Empty && text2 != "\n");
        if (vitalsPanel.gameObject.activeSelf && amounts.Count == 0)
        {
            vitalsPanel.gameObject.SetActive(false);
        }
    }
 public void Refresh()
 {
     if (!((UnityEngine.Object)selectedEntity == (UnityEngine.Object)null) && !((UnityEngine.Object)selectedEntity.gameObject == (UnityEngine.Object)null))
     {
         Amounts    amounts    = selectedEntity.GetAmounts();
         Attributes attributes = selectedEntity.GetAttributes();
         if (amounts != null && attributes != null)
         {
             WiltCondition component = selectedEntity.GetComponent <WiltCondition>();
             if ((UnityEngine.Object)component == (UnityEngine.Object)null)
             {
                 conditionsContainerNormal.gameObject.SetActive(false);
                 conditionsContainerAdditional.gameObject.SetActive(false);
                 foreach (AmountLine amountsLine in amountsLines)
                 {
                     AmountLine current = amountsLine;
                     bool       flag    = current.TryUpdate(amounts);
                     if (current.go.activeSelf != flag)
                     {
                         current.go.SetActive(flag);
                     }
                 }
                 foreach (AttributeLine attributesLine in attributesLines)
                 {
                     AttributeLine current2 = attributesLine;
                     bool          flag2    = current2.TryUpdate(attributes);
                     if (current2.go.activeSelf != flag2)
                     {
                         current2.go.SetActive(flag2);
                     }
                 }
             }
             bool flag3 = false;
             for (int i = 0; i < checkboxLines.Count; i++)
             {
                 CheckboxLine            checkboxLine            = checkboxLines[i];
                 CheckboxLineDisplayType checkboxLineDisplayType = CheckboxLineDisplayType.Hidden;
                 CheckboxLine            checkboxLine2           = checkboxLines[i];
                 if (checkboxLine2.amount != null)
                 {
                     for (int j = 0; j < amounts.Count; j++)
                     {
                         AmountInstance amountInstance = amounts[j];
                         if (checkboxLine.amount == amountInstance.amount)
                         {
                             checkboxLineDisplayType = checkboxLine.display_condition(selectedEntity.gameObject);
                             break;
                         }
                     }
                 }
                 else
                 {
                     checkboxLineDisplayType = checkboxLine.display_condition(selectedEntity.gameObject);
                 }
                 if (checkboxLineDisplayType != CheckboxLineDisplayType.Hidden)
                 {
                     checkboxLine.locText.SetText(checkboxLine.label_text_func(selectedEntity.gameObject));
                     if (!checkboxLine.go.activeSelf)
                     {
                         checkboxLine.go.SetActive(true);
                     }
                     GameObject gameObject = checkboxLine.go.GetComponent <HierarchyReferences>().GetReference("Check").gameObject;
                     gameObject.SetActive(checkboxLine.get_value(selectedEntity.gameObject));
                     if ((UnityEngine.Object)checkboxLine.go.transform.parent != (UnityEngine.Object)checkboxLine.parentContainer)
                     {
                         checkboxLine.go.transform.SetParent(checkboxLine.parentContainer);
                         checkboxLine.go.transform.localScale = Vector3.one;
                     }
                     if ((UnityEngine.Object)checkboxLine.parentContainer == (UnityEngine.Object)conditionsContainerAdditional)
                     {
                         flag3 = true;
                     }
                     if (checkboxLineDisplayType == CheckboxLineDisplayType.Normal)
                     {
                         if (checkboxLine.get_value(selectedEntity.gameObject))
                         {
                             checkboxLine.locText.color = Color.black;
                             gameObject.transform.parent.GetComponent <Image>().color = Color.black;
                         }
                         else
                         {
                             Color color = new Color(0.992156863f, 0f, 0.101960786f);
                             checkboxLine.locText.color = color;
                             gameObject.transform.parent.GetComponent <Image>().color = color;
                         }
                     }
                     else
                     {
                         checkboxLine.locText.color = Color.grey;
                         gameObject.transform.parent.GetComponent <Image>().color = Color.grey;
                     }
                 }
                 else if (checkboxLine.go.activeSelf)
                 {
                     checkboxLine.go.SetActive(false);
                 }
             }
             if ((UnityEngine.Object)component != (UnityEngine.Object)null)
             {
                 Growing component2 = component.GetComponent <Growing>();
                 bool    flag4      = component.HasTag(GameTags.Decoration);
                 conditionsContainerNormal.gameObject.SetActive(true);
                 conditionsContainerAdditional.gameObject.SetActive(!flag4);
                 if ((UnityEngine.Object)component2 == (UnityEngine.Object)null)
                 {
                     float   num       = 1f;
                     LocText reference = conditionsContainerNormal.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.text = string.Empty;
                     reference.text = ((!flag4) ? string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_INSTANT.BASE, Util.FormatTwoDecimalPlace(num * 0.25f * 100f)) : string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_DECOR.BASE));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD_INSTANT.TOOLTIP));
                     reference       = conditionsContainerAdditional.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.color = ((!selectedEntity.GetComponent <ReceptacleMonitor>().Replanted) ? Color.grey : Color.black);
                     reference.text  = string.Empty;
                     reference.text  = string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC_INSTANT.BASE, Util.FormatTwoDecimalPlace(num * 100f));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC_INSTANT.TOOLTIP));
                 }
                 else
                 {
                     LocText reference = conditionsContainerNormal.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.text = string.Empty;
                     reference.text = string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().WildGrowthTime(), "F1"));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.WILD.TOOLTIP, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().WildGrowthTime(), "F1")));
                     reference       = conditionsContainerAdditional.GetComponent <HierarchyReferences>().GetReference <LocText>("Label");
                     reference.color = ((!selectedEntity.GetComponent <ReceptacleMonitor>().Replanted) ? Color.grey : Color.black);
                     reference.text  = string.Empty;
                     reference.text  = ((!flag3) ? string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.DOMESTIC.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")) : string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC.BASE, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")));
                     reference.GetComponent <ToolTip>().SetSimpleTooltip(string.Format(UI.VITALSSCREEN.CONDITIONS_GROWING.ADDITIONAL_DOMESTIC.TOOLTIP, GameUtil.GetFormattedCycles(component.GetComponent <Growing>().DomesticGrowthTime(), "F1")));
                 }
                 foreach (AmountLine amountsLine2 in amountsLines)
                 {
                     AmountLine current3 = amountsLine2;
                     current3.go.SetActive(false);
                 }
                 foreach (AttributeLine attributesLine2 in attributesLines)
                 {
                     AttributeLine current4 = attributesLine2;
                     current4.go.SetActive(false);
                 }
             }
         }
     }
 }
예제 #8
0
    public void Refresh(HarvestDesignatable target_harvestable)
    {
        Image          image          = bar.GetComponent <HierarchyReferences>().GetReference("Fill") as Image;
        AmountInstance amountInstance = Db.Get().Amounts.Maturity.Lookup(target_harvestable);

        if (amountInstance != null)
        {
            float         num           = amountInstance.value / amountInstance.GetMax();
            RectTransform rectTransform = image.rectTransform;
            Vector2       offsetMin     = image.rectTransform.offsetMin;
            rectTransform.offsetMin = new Vector2(offsetMin.x, 3f);
            if (bar.activeSelf != !target_harvestable.CanBeHarvested())
            {
                bar.SetActive(!target_harvestable.CanBeHarvested());
            }
            float         num2           = (!target_harvestable.CanBeHarvested()) ? (19f - 19f * num + 3f) : 3f;
            RectTransform rectTransform2 = image.rectTransform;
            Vector2       offsetMax      = image.rectTransform.offsetMax;
            rectTransform2.offsetMax = new Vector2(offsetMax.x, 0f - num2);
        }
        else if (bar.activeSelf)
        {
            bar.SetActive(false);
        }
        WiltCondition component = target_harvestable.GetComponent <WiltCondition>();

        if ((Object)component != (Object)null)
        {
            for (int i = 0; i < horizontal_containers.Length; i++)
            {
                horizontal_containers[i].SetActive(false);
            }
            foreach (KeyValuePair <WiltCondition.Condition, GameObject> condition_icon in condition_icons)
            {
                condition_icon.Value.SetActive(false);
            }
            if (component.IsWilting())
            {
                vertical_container.SetActive(true);
                image.color = wilting_color;
                List <WiltCondition.Condition> list = component.CurrentWiltSources();
                if (list.Count > 0)
                {
                    for (int j = 0; j < list.Count; j++)
                    {
                        if (condition_icons.ContainsKey(list[j]))
                        {
                            condition_icons[list[j]].SetActive(true);
                            horizontal_containers[j / 2].SetActive(true);
                            condition_icons[list[j]].transform.SetParent(horizontal_containers[j / 2].transform);
                        }
                    }
                }
            }
            else
            {
                vertical_container.SetActive(false);
                image.color = growing_color;
            }
        }
        else
        {
            image.color = growing_color;
            vertical_container.SetActive(false);
        }
    }