/// <summary>
			/// Applied before Update runs.
			/// </summary>
			internal static bool Prefix(DecorMonitor.Instance __instance, float dt,
					Klei.AI.AmountInstance ___amount, Klei.AI.AttributeModifier ___modifier,
					ref float ___cycleTotalDecor) {
				bool cont = true;
				ChoreDriver driver;
				// If no chore driver, allow stock implementation
				if ((driver = __instance.GetComponent<ChoreDriver>()) != null) {
					var chore = driver.GetCurrentChore();
					cont = false;
					// Slew to half decor if sleeping
					float decorAtCell = GameUtil.GetDecorAtCell(Grid.PosToCell(__instance));
					if (chore != null && chore.choreType == Db.Get().ChoreTypes.Sleep)
						decorAtCell *= DecorTuning.DECOR_FRACTION_SLEEP;
					___cycleTotalDecor += decorAtCell * dt;
					// Constants are the same as the base game
					float value = 0.0f, curDecor = ___amount.value;
					if (Mathf.Abs(decorAtCell - curDecor) > 0.5f) {
						if (decorAtCell > curDecor)
							value = 3.0f * SLEW;
						else if (decorAtCell < curDecor)
							value = -SLEW;
					} else
						___amount.value = decorAtCell;
					___modifier.SetValue(value);
				}
				return cont;
			}
Ejemplo n.º 2
0
        public override object OnInfect(GameObject go, SicknessInstance diseaseInstance)
        {
            Attributes attributes = go.GetAttributes();

            for (int i = 0; i < attributeModifiers.Length; i++)
            {
                AttributeModifier modifier = attributeModifiers[i];
                attributes.Add(modifier);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public void Apply(AttributeLevels levels)
        {
            Attributes attributes = levels.GetAttributes();

            if (modifier != null)
            {
                attributes.Remove(modifier);
                modifier = null;
            }
            modifier = new AttributeModifier(attribute.Id, (float)GetLevel(), DUPLICANTS.MODIFIERS.SKILLLEVEL.NAME, false, false, true);
            attributes.Add(modifier);
        }
Ejemplo n.º 4
0
        public float GetModifierContribution(AttributeModifier testModifier)
        {
            if (!testModifier.IsMultiplier)
            {
                return(testModifier.Value);
            }
            float num = Attribute.BaseValue;

            for (int i = 0; i != Modifiers.Count; i++)
            {
                AttributeModifier attributeModifier = Modifiers[i];
                if (!attributeModifier.IsMultiplier)
                {
                    num += attributeModifier.Value;
                }
            }
            return(num * testModifier.Value);
        }
Ejemplo n.º 5
0
        public void Remove(AttributeModifier modifier)
        {
            int num = 0;

            while (true)
            {
                if (num >= Modifiers.Count)
                {
                    return;
                }
                if (Modifiers[num] == modifier)
                {
                    break;
                }
                num++;
            }
            Modifiers.RemoveAt(num);
            if (OnDirty != null)
            {
                OnDirty();
            }
        }
Ejemplo n.º 6
0
        public float GetTotalDisplayValue()
        {
            float num  = Attribute.BaseValue;
            float num2 = 0f;

            for (int i = 0; i != Modifiers.Count; i++)
            {
                AttributeModifier attributeModifier = Modifiers[i];
                if (!attributeModifier.IsMultiplier)
                {
                    num += attributeModifier.Value;
                }
                else
                {
                    num2 += attributeModifier.Value;
                }
            }
            if (num2 != 0f)
            {
                num += Mathf.Abs(num) * num2;
            }
            return(num);
        }
Ejemplo n.º 7
0
 public void RemovePrefabAttribute(AttributeModifier modifier)
 {
     descriptors.Remove(modifier);
 }
Ejemplo n.º 8
0
 public void AddAttributeDescriptor(AttributeModifier modifier)
 {
     descriptors.Add(modifier);
 }
Ejemplo n.º 9
0
 public void Add(AttributeModifier modifier)
 {
     Get(modifier.AttributeId)?.Add(modifier);
 }