Esempio n. 1
0
        private float GetModifierDelta(string id, float multiplier)
        {
            float base_value = this.customBase;

            if (this.usePercentage)
            {
                AttributeInstance i = this.gameObject.GetAttributes().Get(id);

                if (i == null)
                {
                    LogManager.LogException("Attribute id does not exist.", new ArgumentNullException("Attribute ID: " + id));
                }
                else if (i.GetTotalValue() > 0)
                {
                    base_value = i.GetTotalValue();
                }
                else
                {
                    base_value = 0;
                }
            }
            float delta = (Math.Abs(base_value) * multiplier);

#if DEBUG
            LogManager.LogDebug(this.name + " : " + (multiplier * 100) + "% : " + id + " : " + delta);
#endif
            return(delta);
        }
Esempio n. 2
0
 private string OnPriorityButtonTooltip(PriorityButton b)
 {
     b.tooltip.ClearMultiStringTooltip();
     if ((UnityEngine.Object)identity != (UnityEngine.Object)null)
     {
         Attributes attributes = identity.GetAttributes();
         if (attributes != null)
         {
             if (!consumer.IsPermittedByTraits(b.choreGroup))
             {
                 string newString = string.Format(UI.TOOLTIPS.JOBSSCREEN_CANNOTPERFORMTASK, consumer.GetComponent <MinionIdentity>().GetProperName());
                 b.tooltip.AddMultiStringTooltip(newString, TooltipTextStyle_AbilityNegativeModifier);
                 return(string.Empty);
             }
             b.tooltip.AddMultiStringTooltip(UI.TOOLTIPS.JOBSSCREEN_RELEVANT_ATTRIBUTES, TooltipTextStyle_Ability);
             Klei.AI.Attribute attribute         = b.choreGroup.attribute;
             AttributeInstance attributeInstance = attributes.Get(attribute);
             float             totalValue        = attributeInstance.GetTotalValue();
             TextStyleSetting  styleSetting      = TooltipTextStyle_Ability;
             if (totalValue > 0f)
             {
                 styleSetting = TooltipTextStyle_AbilityPositiveModifier;
             }
             else if (totalValue < 0f)
             {
                 styleSetting = TooltipTextStyle_AbilityNegativeModifier;
             }
             b.tooltip.AddMultiStringTooltip(attribute.Name + " " + attributeInstance.GetTotalValue(), styleSetting);
         }
     }
     return(string.Empty);
 }
Esempio n. 3
0
        public float NextSneezeInterval()
        {
            AttributeInstance attributeInstance = Db.Get().Attributes.Sneezyness.Lookup(base.master.gameObject);

            if (attributeInstance.GetTotalValue() <= 0f)
            {
                return(70f);
            }
            float num = 70f / attributeInstance.GetTotalValue();

            return(UnityEngine.Random.Range(num * 0.7f, num * 1.3f));
        }
Esempio n. 4
0
    public List <Descriptor> GetEffectDescriptions()
    {
        List <Descriptor> list = new List <Descriptor>();

        if (decor != null && decorRadius != null)
        {
            float  totalValue  = decor.GetTotalValue();
            float  totalValue2 = decorRadius.GetTotalValue();
            string arg         = (!(baseDecor > 0f)) ? "consumed" : "produced";
            string str         = (!(baseDecor > 0f)) ? UI.BUILDINGEFFECTS.TOOLTIPS.DECORDECREASED : UI.BUILDINGEFFECTS.TOOLTIPS.DECORPROVIDED;
            str = str + "\n\n" + decor.GetAttributeValueTooltip();
            string     text = GameUtil.AddPositiveSign(totalValue.ToString(), totalValue > 0f);
            Descriptor item = new Descriptor(string.Format(UI.BUILDINGEFFECTS.DECORPROVIDED, arg, text, totalValue2), string.Format(str, text, totalValue2), Descriptor.DescriptorType.Effect, false);
            list.Add(item);
        }
        else if (baseDecor != 0f)
        {
            string     arg2   = (!(baseDecor >= 0f)) ? "consumed" : "produced";
            string     format = (!(baseDecor >= 0f)) ? UI.BUILDINGEFFECTS.TOOLTIPS.DECORDECREASED : UI.BUILDINGEFFECTS.TOOLTIPS.DECORPROVIDED;
            string     text2  = GameUtil.AddPositiveSign(baseDecor.ToString(), baseDecor > 0f);
            Descriptor item2  = new Descriptor(string.Format(UI.BUILDINGEFFECTS.DECORPROVIDED, arg2, text2, baseRadius), string.Format(format, text2, baseRadius), Descriptor.DescriptorType.Effect, false);
            list.Add(item2);
        }
        return(list);
    }
Esempio n. 5
0
        public override bool Success()
        {
            bool        flag       = true;
            IEnumerator enumerator = Components.MinionAssignablesProxy.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    MinionAssignablesProxy minionAssignablesProxy = (MinionAssignablesProxy)enumerator.Current;
                    GameObject             targetGameObject       = minionAssignablesProxy.GetTargetGameObject();
                    if ((UnityEngine.Object)targetGameObject != (UnityEngine.Object)null && !targetGameObject.HasTag(GameTags.Dead))
                    {
                        AttributeInstance attributeInstance = Db.Get().Attributes.QualityOfLife.Lookup(targetGameObject.GetComponent <MinionModifiers>());
                        flag = (attributeInstance != null && attributeInstance.GetTotalValue() >= (float)minimumMorale && flag);
                    }
                }
                return(flag);
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }
Esempio n. 6
0
    private void SortByMorale()
    {
        SelectSortToggle(moraleSortingToggle);
        List <SkillMinionWidget> list = minionWidgets;

        list.Sort(delegate(SkillMinionWidget a, SkillMinionWidget b)
        {
            MinionIdentity minionIdentity  = a.minion as MinionIdentity;
            MinionIdentity minionIdentity2 = b.minion as MinionIdentity;
            if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null && (UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null)
            {
                return(0);
            }
            if ((UnityEngine.Object)minionIdentity == (UnityEngine.Object)null)
            {
                return(-1);
            }
            if ((UnityEngine.Object)minionIdentity2 == (UnityEngine.Object)null)
            {
                return(1);
            }
            MinionResume component               = minionIdentity.GetComponent <MinionResume>();
            MinionResume component2              = minionIdentity2.GetComponent <MinionResume>();
            AttributeInstance attributeInstance  = Db.Get().Attributes.QualityOfLife.Lookup(component);
            AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component);
            AttributeInstance attributeInstance3 = Db.Get().Attributes.QualityOfLife.Lookup(component2);
            AttributeInstance attributeInstance4 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component2);
            float num   = attributeInstance.GetTotalValue() / attributeInstance2.GetTotalValue();
            float value = attributeInstance3.GetTotalValue() / attributeInstance4.GetTotalValue();
            return(num.CompareTo(value));
        });
        ReorderEntries(list, sortReversed);
    }
Esempio n. 7
0
        public static bool Prefix(
            AttributeInstance ___qolAttribute,
            AttributeInstance ___expectationAttribute,
            ref bool __result)
        {
            var qav = ___qolAttribute.GetTotalValue();
            var eav = ___expectationAttribute.GetTotalValue();

            var val = MathUtil.ReRange(
                qav - eav,
                TRAITS.JOY_REACTIONS.MIN_MORALE_EXCESS,
                TRAITS.JOY_REACTIONS.MAX_MORALE_EXCESS,
                TRAITS.JOY_REACTIONS.MIN_REACTION_CHANCE,
                TRAITS.JOY_REACTIONS.MAX_REACTION_CHANCE
                );
            var rdm = Random.Range(0.0f, 100.0f);

            Debug.Log("val: " + val + " random:" + rdm);
            if (val < 50)
            {
                val = 50;
            }

            __result = rdm <= val;
            return(false);
        }
Esempio n. 8
0
    protected override bool OnWorkTick(Worker worker, float dt)
    {
        PrimaryElement component = GetComponent <PrimaryElement>();
        float          num       = Mathf.Sqrt(component.Mass);
        float          num2      = (!(expectedRepairTime < 0f)) ? expectedRepairTime : num;
        float          num3      = num2 * 0.1f;

        if (timeSpentRepairing >= num3)
        {
            timeSpentRepairing -= num3;
            int num4 = 0;
            if ((UnityEngine.Object)worker != (UnityEngine.Object)null)
            {
                AttributeInstance attributeInstance = Db.Get().Attributes.Machinery.Lookup(worker);
                num4 = (int)attributeInstance.GetTotalValue();
            }
            int num5          = 10 + Math.Max(0, num4 * 10);
            int repair_amount = Mathf.CeilToInt((float)num5 * 0.1f);
            hp.Repair(repair_amount);
            if (hp.HitPoints >= hp.MaxHitPoints)
            {
                return(true);
            }
        }
        timeSpentRepairing += dt;
        return(false);
    }
    protected override void OnCompleteWork(Worker worker)
    {
        AttributeInstance attributeInstance = Db.Get().Attributes.Machinery.Lookup(worker);
        int num           = (int)attributeInstance.GetTotalValue();
        int repair_amount = 10 + Math.Max(0, num * 10);

        Repair(repair_amount);
    }
    public void RefreshRegistration()
    {
        SimUnregister();
        Attributes        attributes        = base.gameObject.GetAttributes();
        AttributeInstance attributeInstance = attributes.Get("ThermalConductivityBarrier");

        thickness = attributeInstance.GetTotalValue();
        simHandle = -1;
        SimRegister();
    }
Esempio n. 11
0
    private void AddQualityEffects(Worker worker)
    {
        Attributes        attributes        = worker.GetAttributes();
        AttributeInstance attributeInstance = attributes.Add(Db.Get().Attributes.FoodExpectation);
        float             totalValue        = attributeInstance.GetTotalValue();
        int     num          = Mathf.RoundToInt(totalValue);
        int     qualityLevel = FoodInfo.Quality + num;
        Effects component    = worker.GetComponent <Effects>();

        component.Add(GetEffectForFoodQuality(qualityLevel), true);
    }
Esempio n. 12
0
    public void Refresh()
    {
        splat.Clear();
        splat = new Splat(this);
        KPrefabID component = GetComponent <KPrefabID>();
        bool      flag      = component.HasTag(RoomConstraints.ConstraintTags.Decor20);
        bool      flag2     = decor.GetTotalValue() >= 20f;

        if (flag != flag2)
        {
            if (flag2)
            {
                component.AddTag(RoomConstraints.ConstraintTags.Decor20, false);
            }
            else
            {
                component.RemoveTag(RoomConstraints.ConstraintTags.Decor20);
            }
            Game.Instance.roomProber.SolidChangedEvent(Grid.PosToCell(this), true);
        }
    }
 public void Sim200ms(float dt)
 {
     if (!base.gameObject.HasTag(GameTags.Dead))
     {
         float num  = airConsumptionRate.GetTotalValue() * dt;
         bool  flag = gasProvider.ConsumeGas(this, num);
         if (flag)
         {
             if (gasProvider.ShouldEmitCO2())
             {
                 float num2 = num * O2toCO2conversion;
                 Game.Instance.accumulators.Accumulate(co2Accumulator, num2);
                 accumulatedCO2 += num2;
                 if (accumulatedCO2 >= minCO2ToEmit)
                 {
                     accumulatedCO2 -= minCO2ToEmit;
                     Vector3 position = base.transform.GetPosition();
                     position.x += ((!facing.GetFacing()) ? mouthOffset.x : (0f - mouthOffset.x));
                     position.y += mouthOffset.y;
                     position.z -= 0.5f;
                     CO2Manager.instance.SpawnBreath(position, minCO2ToEmit, temperature.value);
                 }
             }
             else if (gasProvider.ShouldStoreCO2())
             {
                 Equippable equippable = GetComponent <SuitEquipper>().IsWearingAirtightSuit();
                 if ((UnityEngine.Object)equippable != (UnityEngine.Object)null)
                 {
                     float num3 = num * O2toCO2conversion;
                     Game.Instance.accumulators.Accumulate(co2Accumulator, num3);
                     accumulatedCO2 += num3;
                     if (accumulatedCO2 >= minCO2ToEmit)
                     {
                         accumulatedCO2 -= minCO2ToEmit;
                         equippable.GetComponent <Storage>().AddGasChunk(SimHashes.CarbonDioxide, minCO2ToEmit, temperature.value, byte.MaxValue, 0, false, true);
                     }
                 }
             }
         }
         if (flag != hasAir)
         {
             hasAirTimer.Start();
             if (hasAirTimer.TryStop(2f))
             {
                 hasAir = flag;
             }
         }
         else
         {
             hasAirTimer.Stop();
         }
     }
 }
        private void TriggerRoomEffects(object data)
        {
            if (!RoomTypes_AllModded.IsInTheRoom(this, RoomTypeMuseumData.RoomId))
            {
                return;
            }

            if (!Settings.Instance.Museum.Bonus.HasValue)
            {
                return;
            }

            GameObject      gameObject = (GameObject)data;
            MinionModifiers modifiers  = gameObject.GetComponent <MinionModifiers>();

            if (modifiers == null)
            {
                return;
            }

            AttributeInstance attributeInstance = modifiers.attributes.AttributeTable.Where(p => p.Name == "Creativity").FirstOrDefault();

            if (attributeInstance == null)
            {
                return;
            }

            float creativity  = attributeInstance.GetTotalValue();
            int   moraleBonus = (int)Math.Ceiling(creativity * Settings.Instance.Museum.Bonus.Value);

            if (moraleBonus < 1)
            {
                moraleBonus = 1;
            }
            if (moraleBonus > 10)
            {
                moraleBonus = 10;
            }

            Effect effect = new Effect(RoomTypeMuseumData.EffectId, STRINGS.ROOMS.EFFECTS.MUSEUM.NAME, STRINGS.ROOMS.EFFECTS.MUSEUM.DESCRIPTION, 240, false, true, false);

            effect.SelfModifiers = new System.Collections.Generic.List <AttributeModifier>();
            effect.SelfModifiers.Add(new AttributeModifier("QualityOfLife", moraleBonus, description: STRINGS.ROOMS.EFFECTS.MUSEUM.NAME));

            Effects effects = gameObject.GetComponent <Effects>();

            if (effects != null && !effects.HasEffect(RoomTypeMuseumData.EffectId))
            {
                effects.Add(effect, true);
            }
        }
    protected override void Refresh(Navigator navigator)
    {
        int cell = Grid.PosToCell(navigator);

        if (PathFinder.IsSubmerged(cell))
        {
            maxUnderwaterCost = 2147483647;
        }
        else
        {
            AttributeInstance attributeInstance = Db.Get().Attributes.MaxUnderwaterTravelCost.Lookup(navigator);
            maxUnderwaterCost = ((attributeInstance == null) ? 2147483647 : ((int)attributeInstance.GetTotalValue()));
        }
    }
Esempio n. 16
0
        public Splat(DecorProvider provider)
        {
            this = default(Splat);
            AttributeInstance decor = provider.decor;

            this.decor = 0f;
            if (decor != null)
            {
                this.decor = decor.GetTotalValue();
            }
            if (provider.HasTag(GameTags.Stored))
            {
                this.decor = 0f;
            }
            int num = Grid.PosToCell(provider.gameObject);

            if (Grid.IsValidCell(num))
            {
                if (!Grid.Transparent[num] && Grid.Solid[num] && (UnityEngine.Object)provider.simCellOccupier == (UnityEngine.Object)null)
                {
                    this.decor = 0f;
                }
                if (this.decor != 0f)
                {
                    provider.cellCount = 0;
                    this.provider      = provider;
                    int num2 = 5;
                    AttributeInstance decorRadius = provider.decorRadius;
                    if (decorRadius != null)
                    {
                        num2 = (int)decorRadius.GetTotalValue();
                    }
                    Orientation orientation = Orientation.Neutral;
                    if ((bool)provider.rotatable)
                    {
                        orientation = provider.rotatable.GetOrientation();
                    }
                    OccupyArea occupyArea = provider.occupyArea;
                    extents                      = occupyArea.GetExtents(orientation);
                    extents.x                    = Mathf.Max(extents.x - num2, 0);
                    extents.y                    = Mathf.Max(extents.y - num2, 0);
                    extents.width                = Mathf.Min(extents.width + num2 * 2, Grid.WidthInCells - 1);
                    extents.height               = Mathf.Min(extents.height + num2 * 2, Grid.HeightInCells - 1);
                    partitionerEntry             = GameScenePartitioner.Instance.Add("DecorProvider.SplatCollectDecorProviders", provider.gameObject, extents, GameScenePartitioner.Instance.decorProviderLayer, provider.onCollectDecorProvidersCallback);
                    solidChangedPartitionerEntry = GameScenePartitioner.Instance.Add("DecorProvider.SplatSolidCheck", provider.gameObject, extents, GameScenePartitioner.Instance.solidChangedLayer, provider.refreshPartionerCallback);
                    AddDecor();
                }
            }
        }
    private void ShowMinimumMoraleRequirement(bool success, ColonyAchievementRequirement req)
    {
        MinimumMorale minimumMorale = req as MinimumMorale;

        if (minimumMorale != null)
        {
            if (success)
            {
                ShowRequirement(success, req);
            }
            else
            {
                IEnumerator enumerator = Components.MinionAssignablesProxy.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        MinionAssignablesProxy minionAssignablesProxy = (MinionAssignablesProxy)enumerator.Current;
                        GameObject             targetGameObject       = minionAssignablesProxy.GetTargetGameObject();
                        if ((UnityEngine.Object)targetGameObject != (UnityEngine.Object)null && !targetGameObject.HasTag(GameTags.Dead))
                        {
                            AttributeInstance attributeInstance = Db.Get().Attributes.QualityOfLife.Lookup(targetGameObject.GetComponent <MinionModifiers>());
                            if (attributeInstance != null)
                            {
                                HierarchyReferences nextRequirementWidget = GetNextRequirementWidget();
                                if (attributeInstance.GetTotalValue() >= (float)minimumMorale.minimumMorale)
                                {
                                    SetIcon(statusSuccessIcon, Color.green, nextRequirementWidget);
                                }
                                else
                                {
                                    ShowIcon(false, nextRequirementWidget);
                                }
                                SetDescription(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.MORALE, targetGameObject.GetProperName(), attributeInstance.GetTotalDisplayValue()), nextRequirementWidget);
                            }
                        }
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
            }
        }
    }
Esempio n. 18
0
        public float GetResistanceToExposureType(ExposureType exposureType, float overrideExposureTier = -1f)
        {
            float num = overrideExposureTier;

            if (num == -1f)
            {
                num = GetExposureTier(exposureType.germ_id);
            }
            num = Mathf.Clamp(num, 1f, 3f);
            float             num2 = GERM_EXPOSURE.EXPOSURE_TIER_RESISTANCE_BONUSES[(int)num - 1];
            AttributeInstance attributeInstance = Db.Get().Attributes.GermResistance.Lookup(base.gameObject);
            float             totalValue        = attributeInstance.GetTotalValue();

            return((float)exposureType.base_resistance + totalValue + num2);
        }
 public void Sim4000ms(float dt)
 {
     if (!skipUpdate)
     {
         float        num = 0.004166667f;
         float        b   = 0.0416666679f;
         SettingLevel currentQualitySetting = CustomGameSettings.Instance.GetCurrentQualitySetting(CustomGameSettingConfigs.Morale);
         if (currentQualitySetting.id == "Disabled")
         {
             SetModifier(null);
         }
         else
         {
             if (currentQualitySetting.id == "Easy")
             {
                 num = 0.00333333341f;
                 b   = 0.0166666675f;
             }
             else if (currentQualitySetting.id == "Hard")
             {
                 num = 0.008333334f;
                 b   = 0.05f;
             }
             else if (currentQualitySetting.id == "VeryHard")
             {
                 num = 0.0166666675f;
                 b   = 0.0833333358f;
             }
             float totalValue  = qolAttribute.GetTotalValue();
             float totalValue2 = expectationAttribute.GetTotalValue();
             float num2        = totalValue2 - totalValue;
             if (totalValue < totalValue2)
             {
                 stressPenalty.modifier.SetValue(Mathf.Min(num2 * num, b));
                 SetModifier(stressPenalty);
             }
             else if (totalValue > totalValue2)
             {
                 stressBonus.modifier.SetValue(Mathf.Max((0f - num2) * -0.0166666675f, -0.0333333351f));
                 SetModifier(stressBonus);
             }
             else
             {
                 SetModifier(stressNeutral);
             }
         }
     }
 }
Esempio n. 20
0
 public void Refresh()
 {
     if (minion != null)
     {
         portrait.SetIdentityObject(minion, true);
         string         empty          = string.Empty;
         MinionIdentity minionIdentity = minion as MinionIdentity;
         hatDropDown.gameObject.SetActive(true);
         if ((Object)minionIdentity != (Object)null)
         {
             MinionResume component              = minionIdentity.GetComponent <MinionResume>();
             int          availableSkillpoints   = component.AvailableSkillpoints;
             int          totalSkillPointsGained = component.TotalSkillPointsGained;
             masteryPoints.text = ((availableSkillpoints <= 0) ? "0" : GameUtil.ApplyBoldString(GameUtil.ColourizeString(new Color(0.5f, 1f, 0.5f, 1f), availableSkillpoints.ToString())));
             AttributeInstance attributeInstance  = Db.Get().Attributes.QualityOfLife.Lookup(component);
             AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(component);
             morale.text = $"{attributeInstance.GetTotalValue()}/{attributeInstance2.GetTotalValue()}";
             RefreshToolTip(component);
             List <IListableOption> list = new List <IListableOption>();
             foreach (KeyValuePair <string, bool> item in component.MasteryBySkillID)
             {
                 if (item.Value)
                 {
                     list.Add(new SkillListable(item.Key));
                 }
             }
             hatDropDown.Initialize(list, OnHatDropEntryClick, hatDropDownSort, hatDropEntryRefreshAction, false, minion);
             empty = ((!string.IsNullOrEmpty(component.TargetHat)) ? component.TargetHat : component.CurrentHat);
         }
         else
         {
             StoredMinionIdentity storedMinionIdentity = minion as StoredMinionIdentity;
             ToolTip component2 = GetComponent <ToolTip>();
             component2.ClearMultiStringTooltip();
             component2.AddMultiStringTooltip(string.Format(UI.TABLESCREENS.INFORMATION_NOT_AVAILABLE_TOOLTIP, storedMinionIdentity.GetStorageReason(), minion.GetProperName()), null);
             empty = ((!string.IsNullOrEmpty(storedMinionIdentity.targetHat)) ? storedMinionIdentity.targetHat : storedMinionIdentity.currentHat);
             masteryPoints.text = UI.TABLESCREENS.NA;
             morale.text        = UI.TABLESCREENS.NA;
         }
         SetColor((skillsScreen.CurrentlySelectedMinion != minion) ? unselected_color : selected_color);
         HierarchyReferences component3 = GetComponent <HierarchyReferences>();
         RefreshHat(empty);
         component3.GetReference("openButton").gameObject.SetActive((Object)minionIdentity != (Object)null);
     }
 }
Esempio n. 21
0
    public List <Descriptor> GetEffectDescriptions()
    {
        List <Descriptor> list = new List <Descriptor>();

        if (dB != null && dBRadius != null)
        {
            float  totalValue  = dB.GetTotalValue();
            float  totalValue2 = dBRadius.GetTotalValue();
            string str         = (noise <= 0) ? UI.BUILDINGEFFECTS.TOOLTIPS.NOISE_POLLUTION_DECREASE : UI.BUILDINGEFFECTS.TOOLTIPS.NOISE_POLLUTION_INCREASE;
            str = str + "\n\n" + dB.GetAttributeValueTooltip();
            string     arg  = GameUtil.AddPositiveSign(totalValue.ToString(), totalValue > 0f);
            Descriptor item = new Descriptor(string.Format(UI.BUILDINGEFFECTS.NOISE_CREATED, arg, totalValue2), string.Format(str, arg, totalValue2), Descriptor.DescriptorType.Effect, false);
            list.Add(item);
        }
        else if (noise != 0)
        {
            string     format = (noise < 0) ? UI.BUILDINGEFFECTS.TOOLTIPS.NOISE_POLLUTION_DECREASE : UI.BUILDINGEFFECTS.TOOLTIPS.NOISE_POLLUTION_INCREASE;
            string     arg2   = GameUtil.AddPositiveSign(noise.ToString(), noise > 0);
            Descriptor item2  = new Descriptor(string.Format(UI.BUILDINGEFFECTS.NOISE_CREATED, arg2, radius), string.Format(format, arg2, radius), Descriptor.DescriptorType.Effect, false);
            list.Add(item2);
        }
        return(list);
    }
    private void on_tooltip_consumable_info(IAssignableIdentity minion, GameObject widget_go, ToolTip tooltip)
    {
        tooltip.ClearMultiStringTooltip();
        ConsumableInfoTableColumn consumableInfoTableColumn = GetWidgetColumn(widget_go) as ConsumableInfoTableColumn;
        TableRow widgetRow = GetWidgetRow(widget_go);

        EdiblesManager.FoodInfo foodInfo = consumableInfoTableColumn.consumable_info as EdiblesManager.FoodInfo;
        int num = 0;

        if (foodInfo != null)
        {
            int            num2           = foodInfo.Quality;
            MinionIdentity minionIdentity = minion as MinionIdentity;
            if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
            {
                AttributeInstance attributeInstance = minionIdentity.GetAttributes().Get(Db.Get().Attributes.FoodExpectation);
                num2 += Mathf.RoundToInt(attributeInstance.GetTotalValue());
            }
            string effectForFoodQuality = Edible.GetEffectForFoodQuality(num2);
            Effect effect = Db.Get().effects.Get(effectForFoodQuality);
            foreach (AttributeModifier selfModifier in effect.SelfModifiers)
            {
                if (selfModifier.AttributeId == Db.Get().Attributes.QualityOfLife.Id)
                {
                    num += Mathf.RoundToInt(selfModifier.Value);
                }
            }
        }
        switch (widgetRow.rowType)
        {
        case TableRow.RowType.Header:
            tooltip.AddMultiStringTooltip(consumableInfoTableColumn.consumable_info.ConsumableName, null);
            if (foodInfo != null)
            {
                tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_AVAILABLE, GameUtil.GetFormattedCalories(WorldInventory.Instance.GetAmount(consumableInfoTableColumn.consumable_info.ConsumableId.ToTag()) * foodInfo.CaloriesPerUnit, GameUtil.TimeSlice.None, true)), null);
                tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_QUALITY, GameUtil.AddPositiveSign(num.ToString(), num > 0)), null);
                tooltip.AddMultiStringTooltip("\n" + foodInfo.Description, null);
            }
            else
            {
                tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_AVAILABLE, GameUtil.GetFormattedUnits(WorldInventory.Instance.GetAmount(consumableInfoTableColumn.consumable_info.ConsumableId.ToTag()), GameUtil.TimeSlice.None, true)), null);
            }
            break;

        case TableRow.RowType.Default:
            if (consumableInfoTableColumn.get_value_action(minion, widget_go) == ResultValues.True)
            {
                tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.NEW_MINIONS_FOOD_PERMISSION_ON, consumableInfoTableColumn.consumable_info.ConsumableName), null);
            }
            else
            {
                tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.NEW_MINIONS_FOOD_PERMISSION_OFF, consumableInfoTableColumn.consumable_info.ConsumableName), null);
            }
            break;

        case TableRow.RowType.Minion:
        case TableRow.RowType.StoredMinon:
            if (minion != null)
            {
                if (consumableInfoTableColumn.get_value_action(minion, widget_go) == ResultValues.True)
                {
                    tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_PERMISSION_ON, minion.GetProperName(), consumableInfoTableColumn.consumable_info.ConsumableName), null);
                }
                else
                {
                    tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_PERMISSION_OFF, minion.GetProperName(), consumableInfoTableColumn.consumable_info.ConsumableName), null);
                }
                if (foodInfo != null && (UnityEngine.Object)(minion as MinionIdentity) != (UnityEngine.Object)null)
                {
                    tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.FOOD_QUALITY_VS_EXPECTATION, GameUtil.AddPositiveSign(num.ToString(), num > 0), minion.GetProperName()), null);
                }
                else if ((UnityEngine.Object)(minion as StoredMinionIdentity) != (UnityEngine.Object)null)
                {
                    tooltip.AddMultiStringTooltip(string.Format(UI.CONSUMABLESSCREEN.CANNOT_ADJUST_PERMISSIONS, (minion as StoredMinionIdentity).GetStorageReason()), null);
                }
            }
            break;
        }
    }
 public float GetMachinerySpeedMultiplier()
 {
     return(machinerySpeed.GetTotalValue());
 }
 public float GetCraftingSpeedMultiplier()
 {
     return(craftingSpeed.GetTotalValue());
 }
Esempio n. 25
0
 private Conversation.ModeType GetModeForAmount(MinionIdentity speaker, string target)
 {
     if (target == Db.Get().Amounts.Stress.Id)
     {
         AmountInstance amountInstance = Db.Get().Amounts.Stress.Lookup(speaker);
         float          num            = amountInstance.value / amountInstance.GetMax();
         if (num < 0.1f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num > 0.6f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     else if (target == Db.Get().Attributes.QualityOfLife.Id)
     {
         AttributeInstance attributeInstance  = Db.Get().Attributes.QualityOfLife.Lookup(speaker);
         AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(speaker);
         float             num2 = attributeInstance.GetTotalValue() - attributeInstance2.GetTotalValue();
         if (num2 > 0f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num2 < 0f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     else if (target == Db.Get().Amounts.HitPoints.Id)
     {
         AmountInstance amountInstance2 = Db.Get().Amounts.HitPoints.Lookup(speaker);
         float          num3            = amountInstance2.value / amountInstance2.GetMax();
         if (num3 >= 1f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num3 < 0.8f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     else if (target == Db.Get().Amounts.Calories.Id)
     {
         AmountInstance amountInstance3 = Db.Get().Amounts.Calories.Lookup(speaker);
         float          num4            = amountInstance3.value / amountInstance3.GetMax();
         if (num4 > 0.85f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num4 < 0.5f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     else if (target == Db.Get().Amounts.Stamina.Id)
     {
         AmountInstance amountInstance4 = Db.Get().Amounts.Stamina.Lookup(speaker);
         float          num5            = amountInstance4.value / amountInstance4.GetMax();
         if (num5 > 0.5f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num5 < 0.2f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     else if (target == Db.Get().Amounts.ImmuneLevel.Id)
     {
         AmountInstance amountInstance5 = Db.Get().Amounts.ImmuneLevel.Lookup(speaker);
         float          num6            = amountInstance5.value / amountInstance5.GetMax();
         if (num6 > 0.9f)
         {
             return(Conversation.ModeType.Satisfaction);
         }
         if (num6 < 0.5f)
         {
             return(Conversation.ModeType.Dissatisfaction);
         }
     }
     return(Conversation.ModeType.Nominal);
 }
Esempio n. 26
0
    private void Refresh(object data = null)
    {
        if ((UnityEngine.Object)identity == (UnityEngine.Object)null)
        {
            dirty = false;
        }
        else if (dirty)
        {
            Attributes attributes = identity.GetAttributes();
            foreach (PriorityButton priorityButton in PriorityButtons)
            {
                PriorityButton current = priorityButton;
                bool           flag    = consumer.IsPermittedByUser(current.choreGroup);
                if (current.ToggleIcon.activeSelf != flag)
                {
                    current.ToggleIcon.SetActive(flag);
                }
                float             num = 0f;
                AttributeInstance attributeInstance = attributes.Get(current.choreGroup.attribute);
                num = Mathf.Min(attributeInstance.GetTotalValue() / 10f, 1f);
                Color baseBorderColor = current.baseBorderColor;
                baseBorderColor.r = Mathf.Lerp(current.baseBorderColor.r, 0.721568644f, num);
                baseBorderColor.g = Mathf.Lerp(current.baseBorderColor.g, 0.443137258f, num);
                baseBorderColor.b = Mathf.Lerp(current.baseBorderColor.b, 0.5803922f, num);
                if (current.border.color != baseBorderColor)
                {
                    current.border.color = baseBorderColor;
                }
                Color color = current.baseBackgroundColor;
                color.a = Mathf.Lerp(0f, 1f, num);
                bool flag2 = consumer.IsPermittedByTraits(current.choreGroup);
                if (!flag2)
                {
                    color = Color.clear;
                    current.border.color = Color.clear;
                    current.ToggleIcon.SetActive(false);
                }
                current.button.interactable = flag2;
                if (current.background.color != color)
                {
                    current.background.color = color;
                }
            }
            int num2 = 0;
            int num3 = 0;
            foreach (ChoreGroup resource in Db.Get().ChoreGroups.resources)
            {
                if (consumer.IsPermittedByTraits(resource))
                {
                    num3++;
                    if (consumer.IsPermittedByUser(resource))
                    {
                        num2++;
                    }
                }
            }
            if (num2 == 0)
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.off;
            }
            else if (num2 < num3)
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.mixed;
            }
            else
            {
                rowToggleState = CrewJobsScreen.everyoneToggleState.on;
            }
            ImageToggleState component = AllTasksButton.ToggleIcon.GetComponent <ImageToggleState>();
            switch (rowToggleState)
            {
            case CrewJobsScreen.everyoneToggleState.mixed:
                component.SetInactive();
                break;

            case CrewJobsScreen.everyoneToggleState.on:
                component.SetActive();
                break;

            case CrewJobsScreen.everyoneToggleState.off:
                component.SetDisabled();
                break;
            }
            dirty = false;
        }
    }
 private float GetSpeedMultiplier()
 {
     return(machinerySpeedAttribute.GetTotalValue() * workSpeedMultiplier);
 }
Esempio n. 28
0
    private string HoverPersonalPriority(object widget_go_obj)
    {
        GameObject gameObject = widget_go_obj as GameObject;
        PrioritizationGroupTableColumn prioritizationGroupTableColumn = GetWidgetColumn(gameObject) as PrioritizationGroupTableColumn;
        ChoreGroup choreGroup = prioritizationGroupTableColumn.userData as ChoreGroup;
        string     text       = null;
        TableRow   widgetRow  = GetWidgetRow(gameObject);

        switch (widgetRow.rowType)
        {
        case TableRow.RowType.Header:
        {
            string text2 = UI.JOBSSCREEN.HEADER_TOOLTIP.ToString();
            text2 = text2.Replace("{Job}", choreGroup.Name);
            string text3 = UI.JOBSSCREEN.HEADER_DETAILS_TOOLTIP.ToString();
            text3 = text3.Replace("{Description}", choreGroup.description);
            HashSet <string> hashSet = new HashSet <string>();
            foreach (ChoreType choreType in choreGroup.choreTypes)
            {
                hashSet.Add(choreType.Name);
            }
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;
            foreach (string item in hashSet)
            {
                stringBuilder.Append(item);
                if (num < hashSet.Count - 1)
                {
                    stringBuilder.Append(", ");
                }
                num++;
            }
            text3 = text3.Replace("{ChoreList}", stringBuilder.ToString());
            return(text2.Replace("{Details}", text3));
        }

        case TableRow.RowType.Default:
            text = UI.JOBSSCREEN.NEW_MINION_ITEM_TOOLTIP.ToString();
            break;

        case TableRow.RowType.Minion:
        case TableRow.RowType.StoredMinon:
            text = UI.JOBSSCREEN.ITEM_TOOLTIP.ToString();
            text = text.Replace("{Name}", widgetRow.name);
            break;
        }
        ToolTip             componentInChildren = gameObject.GetComponentInChildren <ToolTip>();
        IAssignableIdentity identity            = widgetRow.GetIdentity();
        MinionIdentity      minionIdentity      = identity as MinionIdentity;

        if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
        {
            IPersonalPriorityManager priorityManager = GetPriorityManager(widgetRow);
            int    personalPriority = priorityManager.GetPersonalPriority(choreGroup);
            string newValue         = GetPriorityStr(personalPriority);
            string priorityValue    = GetPriorityValue(personalPriority);
            if (priorityManager.IsChoreGroupDisabled(choreGroup))
            {
                Trait  trait     = null;
                Traits component = minionIdentity.GetComponent <Traits>();
                foreach (Trait trait2 in component.TraitList)
                {
                    if (trait2.disabledChoreGroups != null)
                    {
                        ChoreGroup[] disabledChoreGroups = trait2.disabledChoreGroups;
                        foreach (ChoreGroup choreGroup2 in disabledChoreGroups)
                        {
                            if (choreGroup2.IdHash == choreGroup.IdHash)
                            {
                                trait = trait2;
                                break;
                            }
                        }
                        if (trait != null)
                        {
                            break;
                        }
                    }
                }
                text = UI.JOBSSCREEN.TRAIT_DISABLED.ToString();
                text = text.Replace("{Name}", minionIdentity.GetProperName());
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Trait}", trait.Name);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
            }
            else
            {
                text = text.Replace("{Job}", choreGroup.Name);
                text = text.Replace("{Priority}", newValue);
                text = text.Replace("{PriorityValue}", priorityValue);
                componentInChildren.ClearMultiStringTooltip();
                componentInChildren.AddMultiStringTooltip(text, null);
                if ((UnityEngine.Object)minionIdentity != (UnityEngine.Object)null)
                {
                    text = "\n" + UI.JOBSSCREEN.MINION_SKILL_TOOLTIP.ToString();
                    text = text.Replace("{Name}", minionIdentity.GetProperName());
                    text = text.Replace("{Attribute}", choreGroup.attribute.Name);
                    AttributeInstance attributeInstance        = minionIdentity.GetAttributes().Get(choreGroup.attribute);
                    float             totalValue               = attributeInstance.GetTotalValue();
                    TextStyleSetting  tooltipTextStyle_Ability = TooltipTextStyle_Ability;
                    text += GameUtil.ColourizeString(tooltipTextStyle_Ability.textColor, totalValue.ToString());
                    componentInChildren.AddMultiStringTooltip(text, null);
                }
                componentInChildren.AddMultiStringTooltip(UI.HORIZONTAL_RULE + "\n" + GetUsageString(), null);
            }
        }
        else if ((UnityEngine.Object)(identity as StoredMinionIdentity) != (UnityEngine.Object)null)
        {
            componentInChildren.AddMultiStringTooltip(string.Format(UI.JOBSSCREEN.CANNOT_ADJUST_PRIORITY, identity.GetProperName(), (identity as StoredMinionIdentity).GetStorageReason()), null);
        }
        return(string.Empty);
    }
Esempio n. 29
0
 private void RefreshToolTip(MinionResume resume)
 {
     if ((Object)resume != (Object)null)
     {
         AttributeInstance attributeInstance  = Db.Get().Attributes.QualityOfLife.Lookup(resume);
         AttributeInstance attributeInstance2 = Db.Get().Attributes.QualityOfLifeExpectation.Lookup(resume);
         ToolTip           component          = GetComponent <ToolTip>();
         component.ClearMultiStringTooltip();
         component.AddMultiStringTooltip(minion.GetProperName() + "\n\n", TooltipTextStyle_Header);
         component.AddMultiStringTooltip(string.Format(UI.SKILLS_SCREEN.CURRENT_MORALE, attributeInstance.GetTotalValue(), attributeInstance2.GetTotalValue()), null);
         component.AddMultiStringTooltip("\n" + UI.DETAILTABS.STATS.NAME + "\n\n", TooltipTextStyle_Header);
         foreach (AttributeInstance attribute in resume.GetAttributes())
         {
             if (attribute.Attribute.ShowInUI == Attribute.Display.Skill)
             {
                 string text = UIConstants.ColorPrefixWhite;
                 if (attribute.GetTotalValue() > 0f)
                 {
                     text = UIConstants.ColorPrefixGreen;
                 }
                 else if (attribute.GetTotalValue() < 0f)
                 {
                     text = UIConstants.ColorPrefixRed;
                 }
                 component.AddMultiStringTooltip("    • " + attribute.Name + ": " + text + attribute.GetTotalValue() + UIConstants.ColorSuffix, null);
             }
         }
     }
 }
Esempio n. 30
0
 internal static void Postfix(GameObject ___selectedTarget, CollapsibleDetailContentPanel ___immuneSystemPanel, bool __result)
 {
     if (__result)
     {
         AttributeInstance susceptibility = Db.Get().Attributes.Get(HeartAttackMonitor.ATTRIBUTE_ID).Lookup(___selectedTarget);
         if (susceptibility != null)
         {
             ___immuneSystemPanel.SetLabel(HeartAttackMonitor.ATTRIBUTE_ID, susceptibility.modifier.Name + ": " + GameUtil.GetFormattedPercent(100f * Mathf.Clamp01(susceptibility.GetTotalValue())), susceptibility.GetAttributeValueTooltip());
         }
     }
 }