Exemple #1
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);
    }
Exemple #2
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);
        }
Exemple #3
0
 protected override void OnPrefabInit()
 {
     base.OnPrefabInit();
     decor       = this.GetAttributes().Add(Db.Get().BuildingAttributes.Decor);
     decorRadius = this.GetAttributes().Add(Db.Get().BuildingAttributes.DecorRadius);
     UpdateBaseDecorModifiers();
 }
Exemple #4
0
    protected override void OnPrefabInit()
    {
        base.OnPrefabInit();
        Attributes attributes = base.gameObject.GetAttributes();

        generatorOutputAttribute = attributes.Add(Db.Get().Attributes.GeneratorOutput);
    }
Exemple #5
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);
    }
Exemple #6
0
        public override void StopSM(string reason)
        {
            AttributeInstance attributeInstance  = Db.Get().Attributes.Sneezyness.Lookup(base.master.gameObject);
            AttributeInstance attributeInstance2 = attributeInstance;

            attributeInstance2.OnDirty = (System.Action)Delegate.Remove(attributeInstance2.OnDirty, new System.Action(OnSneezyChange));
            base.StopSM(reason);
        }
Exemple #7
0
 public void Duplicate(AttributeInstance Original)
 {
     Flags       = Original.Flags;
     PlayCount   = Original.PlayCount;
     RateTime    = Original.RateTime;
     OffsetStart = Original.OffsetStart;
     OffsetEnd   = Original.OffsetEnd;
     LabelStart  = string.Copy(Original.LabelStart);
     LabelEnd    = string.Copy(Original.LabelEnd);
 }
Exemple #8
0
        public Instance(IStateMachineTarget master)
            : base(master)
        {
            AttributeInstance attributeInstance = Db.Get().Attributes.Sneezyness.Lookup(master.gameObject);

            OnSneezyChange();
            AttributeInstance attributeInstance2 = attributeInstance;

            attributeInstance2.OnDirty = (System.Action)Delegate.Combine(attributeInstance2.OnDirty, new System.Action(OnSneezyChange));
        }
Exemple #9
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));
        }
Exemple #10
0
 protected override void OnCleanUp()
 {
     base.OnCleanUp();
     if (base.isSpawned)
     {
         AttributeInstance attributeInstance = decor;
         attributeInstance.OnDirty = (System.Action)Delegate.Remove(attributeInstance.OnDirty, refreshCallback);
         AttributeInstance attributeInstance2 = decorRadius;
         attributeInstance2.OnDirty = (System.Action)Delegate.Remove(attributeInstance2.OnDirty, refreshCallback);
         Singleton <CellChangeMonitor> .Instance.UnregisterCellChangedHandler(base.transform, OnCellChange);
     }
     splat.Clear();
 }
        private void ChangeBatteryDelta()
        {
            Modifiers modifiers = this.GetComponent <Modifiers>();

            if (modifiers == null)
            {
                return;
            }

            AttributeInstance deltaMod = modifiers.attributes.Get(Db.Get().Amounts.InternalBattery.deltaAttribute.Id);

            deltaMod.modifier.BaseValue = -SweepyConfigChecker.BatteryDepletionRate * this.moveSpeed * SweepyConfigChecker.DrainSpeedMultiplier;
        }
 public bool SetAttribute(AttributeInstance attribute)
 {
     return false;
 }