public StatesInstance(PeeChore master, GameObject worker) : base(master) { bladder = Db.Get().Amounts.Bladder.Lookup(worker); bodyTemperature = Db.Get().Amounts.Temperature.Lookup(worker); base.sm.worker.Set(worker, base.smi); }
protected override void OnPrefabInit() { base.OnPrefabInit(); Amounts amounts = base.gameObject.GetAmounts(); displayPressureAmount = amounts.Add(new AmountInstance(Db.Get().Amounts.AirPressure, base.gameObject)); }
protected override void OnPrefabInit() { base.OnPrefabInit(); if (addBaseTraits) { foreach (Klei.AI.Attribute resource in Db.Get().Attributes.resources) { if (attributes.Get(resource) == null) { attributes.Add(resource); } } Traits component = GetComponent <Traits>(); Trait trait = Db.Get().traits.Get(MinionConfig.MINION_BASE_TRAIT_ID); component.Add(trait); foreach (Disease resource2 in Db.Get().Diseases.resources) { AmountInstance amountInstance = AddAmount(resource2.amount); attributes.Add(resource2.cureSpeedBase); amountInstance.SetValue(0f); } ChoreConsumer component2 = GetComponent <ChoreConsumer>(); if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { component2.AddProvider(GlobalChoreProvider.Instance); base.gameObject.AddComponent <QualityOfLifeNeed>(); } } }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { scaleGrowth = Db.Get().Amounts.ScaleGrowth.Lookup(base.gameObject); scaleGrowth.value = scaleGrowth.GetMax(); scaleGrowthModifier = new AttributeModifier(scaleGrowth.amount.deltaAttribute.Id, def.defaultGrowthRate * 100f, CREATURES.MODIFIERS.SCALE_GROWTH_RATE.NAME, false, false, true); }
private void AddToolTipAmountPercentLine(ToolTip tooltip, AmountInstance amount, MinionIdentity id, bool selected) { string name = id.GetComponent <KSelectable>().GetName(); string str = name + ": " + Mathf.Round(amount.value).ToString() + "%"; AddToolTipLine(tooltip, str, selected); }
private HarvestDesignatable GetMostMatureBranch(out float max_maturity) { max_maturity = 0f; HarvestDesignatable result = null; Ref <HarvestDesignatable>[] array = buds; for (int i = 0; i < array.Length; i++) { HarvestDesignatable harvestDesignatable = array[i]?.Get(); if ((Object)harvestDesignatable != (Object)null) { AmountInstance amountInstance = Db.Get().Amounts.Maturity.Lookup(harvestDesignatable); if (amountInstance != null) { float num = amountInstance.value / amountInstance.GetMax(); if (num > max_maturity) { max_maturity = num; result = harvestDesignatable; } } } } return(result); }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { incubation = Db.Get().Amounts.Incubation.Lookup(base.gameObject); Action <object> handler = OnStore; master.Subscribe(856640610, handler); master.Subscribe(1309017699, handler); Action <object> handler2 = OnOperationalChanged; master.Subscribe(1628751838, handler2); master.Subscribe(960378201, handler2); wildness = Db.Get().Amounts.Wildness.Lookup(base.gameObject); wildness.value = wildness.GetMax(); viability = Db.Get().Amounts.Viability.Lookup(base.gameObject); viability.value = viability.GetMax(); float value = def.baseIncubationRate; if (GenericGameSettings.instance.acceleratedLifecycle) { value = 33.3333321f; } AttributeModifier modifier = new AttributeModifier(Db.Get().Amounts.Incubation.deltaAttribute.Id, value, CREATURES.MODIFIERS.BASE_INCUBATION_RATE.NAME, false, false, true); incubatingEffect = new Effect("Incubating", CREATURES.MODIFIERS.INCUBATING.NAME, CREATURES.MODIFIERS.INCUBATING.TOOLTIP, 0f, true, false, false, null, 0f, null); incubatingEffect.Add(modifier); }
public void ReleaseAstronaut(bool fill_bladder) { if (!releasingAstronaut) { releasingAstronaut = true; MinionStorage component = GetComponent <MinionStorage>(); List <MinionStorage.Info> storedMinionInfo = component.GetStoredMinionInfo(); for (int num = storedMinionInfo.Count - 1; num >= 0; num--) { MinionStorage.Info info = storedMinionInfo[num]; GameObject gameObject = component.DeserializeMinion(info.id, Grid.CellToPos(Grid.PosToCell(base.smi.master.transform.GetPosition()))); if (!((Object)gameObject == (Object)null)) { if (Grid.FakeFloor[Grid.OffsetCell(Grid.PosToCell(base.smi.master.gameObject), 0, -1)]) { gameObject.GetComponent <Navigator>().SetCurrentNavType(NavType.Floor); } if (fill_bladder) { AmountInstance amountInstance = Db.Get().Amounts.Bladder.Lookup(gameObject); if (amountInstance != null) { amountInstance.value = amountInstance.GetMax(); } } } } releasingAstronaut = false; } }
static void Postfix(ref string __result, AmountInstance instance) { if (instance.gameObject.GetSMI <DecorMonitor.Instance>() is DecorMonitor.Instance smi) { var format = smi.GetYesterdaysAverageDecor() > DecorMonitor.MAXIMUM_DECOR_VALUE ? UI.OVERLAYS.DECOR.MAXIMUM_DECOR : UI.OVERLAYS.DECOR.VALUE; __result = string.Format(STRINGS.DUPLICANTS.ATTRIBUTES.QUALITYOFLIFE.DESC_FORMAT, __result, string.Format(format, "", DecorMonitor.MAXIMUM_DECOR_VALUE)); } }
/// <summary> /// Applied before GetDescription runs. /// </summary> internal static bool Prefix(AsPercentAmountDisplayer __instance, Amount master, AmountInstance instance, ref string __result) { // The string builder was a push, but this sure beats string.Format! __result = master.Name + ": " + __instance.Formatter.GetFormattedValue( __instance.ToPercent(instance.value, instance), TimeSlice.None); return(false); }
public Instance(IStateMachineTarget master) : base(master) { breath = Db.Get().Amounts.Breath.Lookup(master.gameObject); query = new SafetyQuery(Game.Instance.safetyConditions.RecoverBreathChecker, GetComponent <KMonoBehaviour>(), 2147483647); navigator = GetComponent <Navigator>(); breather = GetComponent <OxygenBreather>(); }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { age = Db.Get().Amounts.Age.Lookup(base.gameObject); Subscribe(1119167081, delegate { RandomizeAge(); }); }
public void Refresh(AmountInstance value_src) { GameObject gameObject = value_src.gameObject; if (!((Object)gameObject == (Object)null)) { KAnimControllerBase component = gameObject.GetComponent <KAnimControllerBase>(); Vector3 a = (!((Object)component != (Object)null)) ? (gameObject.transform.GetPosition() + Vector3.down) : component.GetWorldPivot(); base.transform.SetPosition(a + offset); if (value_src != null) { progressFill.transform.parent.gameObject.SetActive(true); float num = value_src.value / value_src.GetMax(); Vector3 localScale = progressFill.rectTransform.localScale; localScale.y = num; progressFill.rectTransform.localScale = localScale; progressToolTip.toolTip = DUPLICANTS.ATTRIBUTES.IMMUNITY.NAME + " " + GameUtil.GetFormattedPercent(num * 100f, GameUtil.TimeSlice.None); } else { progressFill.transform.parent.gameObject.SetActive(false); } int num2 = 0; Amounts amounts = gameObject.GetComponent <Modifiers>().GetAmounts(); foreach (Disease resource in Db.Get().Diseases.resources) { float value = amounts.Get(resource.amount).value; if (value > 0f) { Image image = null; if (num2 < displayedDiseases.Count) { image = displayedDiseases[num2]; } else { GameObject gameObject2 = Util.KInstantiateUI(germsImage.gameObject, germsImage.transform.parent.gameObject, true); image = gameObject2.GetComponent <Image>(); displayedDiseases.Add(image); } image.color = resource.overlayColour; ToolTip component2 = image.GetComponent <ToolTip>(); component2.toolTip = resource.Name + " " + GameUtil.GetFormattedDiseaseAmount((int)value); num2++; } } for (int num3 = displayedDiseases.Count - 1; num3 >= num2; num3--) { Util.KDestroyGameObject(displayedDiseases[num3].gameObject); displayedDiseases.RemoveAt(num3); } diseasedImage.enabled = false; progressFill.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0); germsImage.transform.parent.gameObject.SetActive(displayedDiseases.Count > 0); } }
protected override void OnPrefabInit() { base.OnPrefabInit(); Components.Health.Add(this); amountInstance = Db.Get().Amounts.HitPoints.Lookup(base.gameObject); amountInstance.value = amountInstance.GetMax(); AmountInstance obj = amountInstance; obj.OnDelta = (Action <float>)Delegate.Combine(obj.OnDelta, new Action <float>(OnHealthChanged)); }
/// <summary> /// Applied before GetValueString runs. /// </summary> internal static bool Prefix(StandardAmountDisplayer __instance, Amount master, AmountInstance instance, ref string __result) { var text = CACHED_BUILDER; text.Clear(); GetValueString(text, __instance.Formatter, instance, master); __result = text.ToString(); return(false); }
public StatesInstance(PressureVulnerable master) : base(master) { AmountInstance amountInstance = Db.Get().Amounts.Maturity.Lookup(base.gameObject); if (amountInstance != null) { hasMaturity = true; } }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { calories = Db.Get().Amounts.Calories.Lookup(base.gameObject); calories.value = calories.GetMax() * 0.9f; stomach = new Stomach(def.diet, master.gameObject, def.minPoopSizeInCalories); metabolism = base.gameObject.GetAttributes().Add(Db.Get().CritterAttributes.Metabolism); deltaCalorieMetabolismModifier = new AttributeModifier(Db.Get().Amounts.Calories.deltaAttribute.Id, 1f, DUPLICANTS.MODIFIERS.METABOLISM_CALORIE_MODIFIER.NAME, true, false, false); calories.deltaAttribute.Add(deltaCalorieMetabolismModifier); }
public override string GetDescription(Amount master, AmountInstance instance) { Growing component = instance.gameObject.GetComponent <Growing>(); if ((Object)component != (Object)null && component.IsGrowing()) { return(string.Format(CREATURES.STATS.MATURITY.AMOUNT_DESC_FMT, master.Name, formatter.GetFormattedValue(ToPercent(instance.value, instance), GameUtil.TimeSlice.None, null), GameUtil.GetFormattedCycles(component.TimeUntilNextHarvest(), "F1"))); } return(base.GetDescription(master, instance)); }
public void RandomizeAge() { age.value = UnityEngine.Random.value * age.GetMax() * base.def.maxAgePercentOnSpawn; AmountInstance amountInstance = Db.Get().Amounts.Fertility.Lookup(base.gameObject); if (amountInstance != null) { amountInstance.value = age.value / age.GetMax() * amountInstance.GetMax() * 1.75f; amountInstance.value = Mathf.Min(amountInstance.value, amountInstance.GetMax() * 0.9f); } }
private static bool IsReadyToSpawnAdult(Instance smi) { AmountInstance amountInstance = Db.Get().Amounts.Age.Lookup(smi.gameObject); float num = 5f; if (GenericGameSettings.instance.acceleratedLifecycle) { num = 0.005f; } return(amountInstance.value > num); }
public Instance(IStateMachineTarget master) : base(master) { health = GetComponent <Health>(); occupyArea = GetComponent <OccupyArea>(); internalTemperatureMonitor = base.gameObject.GetSMI <TemperatureMonitor.Instance>(); internalTemperature = Db.Get().Amounts.Temperature.Lookup(base.gameObject); temperatureTransferer = base.gameObject.GetComponent <CreatureSimTemperatureTransfer>(); primaryElement = base.gameObject.GetComponent <PrimaryElement>(); attributes = base.gameObject.GetAttributes(); }
protected override bool OnWorkTick(Worker worker, float dt) { AmountInstance amountInstance = Db.Get().Amounts.Stress.Lookup(worker.gameObject); if (amountInstance.value <= stopStressingValue) { return(true); } base.OnWorkTick(worker, dt); return(false); }
protected override void OnSpawn() { airConsumptionRate = Db.Get().Attributes.AirConsumptionRate.Lookup(this); o2Accumulator = Game.Instance.accumulators.Add("O2", this); co2Accumulator = Game.Instance.accumulators.Add("CO2", this); KSelectable component = GetComponent <KSelectable>(); component.AddStatusItem(Db.Get().DuplicantStatusItems.BreathingO2, this); component.AddStatusItem(Db.Get().DuplicantStatusItems.EmittingCO2, this); temperature = Db.Get().Amounts.Temperature.Lookup(this); NameDisplayScreen.Instance.RegisterComponent(base.gameObject, this, false); }
public static bool Prefix(BabyMonitor.Instance smi, ref bool __result) { AmountInstance amountInstance = Db.Get().Amounts.Age.Lookup(smi.gameObject); float num = CustomizeCritterState.StateManager.State.babyGrowupTime_inDays; if (Klei.GenericGameSettings.instance.acceleratedLifecycle) { num = 0.005f; } __result = amountInstance.value > num; return(false); }
public float GetProgress() { float result = 0f; if ((bool)base.occupyingObject) { Amounts amounts = base.occupyingObject.GetAmounts(); AmountInstance amountInstance = amounts.Get(Db.Get().Amounts.Incubation); result = ((amountInstance == null) ? 1f : (amountInstance.value / amountInstance.GetMax())); } return(result); }
internal static void Postfix(AmountInstance ___rotAmountInstance, AttributeModifier ___refrigeratedModifier, AttributeModifier ___frozenModifier) { var delta = ___rotAmountInstance.deltaAttribute; if (delta.GetTotalValue() > 0.0f) { // Cannot allow food to gain freshness! delta.Remove(___refrigeratedModifier); delta.Remove(___frozenModifier); } }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { fertility = Db.Get().Amounts.Fertility.Lookup(base.gameObject); if (GenericGameSettings.instance.acceleratedLifecycle) { fertility.deltaAttribute.Add(new AttributeModifier(fertility.deltaAttribute.Id, 33.3333321f, "Accelerated Lifecycle", false, false, true)); } float value = 100f / (def.baseFertileCycles * 600f); fertileEffect = new Effect("Fertile", CREATURES.MODIFIERS.BASE_FERTILITY.NAME, CREATURES.MODIFIERS.BASE_FERTILITY.TOOLTIP, 0f, false, false, false, null, 0f, null); fertileEffect.Add(new AttributeModifier(Db.Get().Amounts.Fertility.deltaAttribute.Id, value, CREATURES.MODIFIERS.BASE_FERTILITY.NAME, false, false, true)); InitializeBreedingChances(); }
public virtual string GetTooltip(Amount master, AmountInstance instance) { string str = string.Format(master.description, formatter.GetFormattedValue(instance.value, GameUtil.TimeSlice.None, null)); str += "\n\n"; str = ((formatter.DeltaTimeSlice != GameUtil.TimeSlice.PerCycle) ? (str + string.Format(UI.CHANGEPERSECOND, formatter.GetFormattedValue(ToPercent(instance.deltaAttribute.GetTotalDisplayValue(), instance), GameUtil.TimeSlice.PerSecond, null))) : (str + string.Format(UI.CHANGEPERCYCLE, formatter.GetFormattedValue(ToPercent(instance.deltaAttribute.GetTotalDisplayValue(), instance), GameUtil.TimeSlice.PerCycle, null)))); for (int i = 0; i != instance.deltaAttribute.Modifiers.Count; i++) { AttributeModifier attributeModifier = instance.deltaAttribute.Modifiers[i]; float modifierContribution = instance.deltaAttribute.GetModifierContribution(attributeModifier); str = str + "\n" + string.Format(UI.MODIFIER_ITEM_TEMPLATE, attributeModifier.GetDescription(), formatter.GetFormattedValue(ToPercent(modifierContribution, instance), formatter.DeltaTimeSlice, null)); } return(str); }
protected override void OnPrefabInit() { Amounts amounts = base.gameObject.GetAmounts(); maturity = amounts.Add(new AmountInstance(Db.Get().Amounts.Maturity, base.gameObject)); baseMaturityMax = new AttributeModifier(maturity.maxAttribute.Id, growthTime / 600f, null, false, false, true); maturity.maxAttribute.Add(baseMaturityMax); oldAge = amounts.Add(new AmountInstance(Db.Get().Amounts.OldAge, base.gameObject)); oldAge.maxAttribute.ClearModifiers(); oldAge.maxAttribute.Add(new AttributeModifier(Db.Get().Amounts.OldAge.maxAttribute.Id, maxAge, null, false, false, true)); base.OnPrefabInit(); Subscribe(1119167081, OnNewGameSpawnDelegate); Subscribe(1272413801, ResetGrowthDelegate); }
public StatesInstance( DirtyVomitChore master, GameObject vomiter, StatusItem status_item, Notification notification, SimUtil.DiseaseInfo diseaseInfo) : base(master) { this.diseaseInfo = diseaseInfo; sm.vomiter.Set(vomiter, smi); bodyTemperature = Db.Get().Amounts.Temperature.Lookup(vomiter); statusItem = status_item; this.notification = notification; vomitCellQuery = new SafetyQuery(Game.Instance.safetyConditions.VomitCellChecker, GetComponent <KMonoBehaviour>(), 10); }