Пример #1
0
    public void Update()
    {
        float currentTimeMinutes = MainLevel.Instance.GetCurrentTimeMinutes();

        if (Player.Get().IsInWater())
        {
            this.m_TimeToInfect -= Time.deltaTime * 5f;
        }
        if (this.m_Type == InjuryType.SmallWoundAbrassion || this.m_Type == InjuryType.SmallWoundScratch || this.m_Type == InjuryType.WormHole)
        {
            if (this.m_State == InjuryState.Open)
            {
                if (currentTimeMinutes < this.m_HealingStartTime)
                {
                    if (currentTimeMinutes - this.m_StartTimeInMinutes > this.m_TimeToInfect)
                    {
                        this.Infect();
                    }
                }
                else if (currentTimeMinutes - this.m_HealingStartTime > this.GetHealingDuration())
                {
                    PlayerInjuryModule.Get().HealInjury(this);
                }
            }
            else if (this.m_State == InjuryState.Infected && currentTimeMinutes - this.m_HealingStartTime > this.GetHealingDuration())
            {
                this.Disinfect();
            }
        }
        else if (this.m_Type == InjuryType.Leech)
        {
            if (currentTimeMinutes > this.m_HealingStartTime)
            {
                PlayerInjuryModule.Get().HealInjury(this);
            }
        }
        else if (this.m_Type == InjuryType.VenomBite || this.m_Type == InjuryType.SnakeBite)
        {
            if (currentTimeMinutes - this.m_StartTimeInMinutes > Injury.s_PoisonAutoDebufTime)
            {
                this.PoisonDebuff(1);
                this.m_StartTimeInMinutes = currentTimeMinutes;
            }
            if (this.m_PoisonLevel == 0)
            {
                this.RemoveBandage();
                this.m_HealingStartTime = float.MaxValue;
                PlayerInjuryModule.Get().HealInjury(this);
            }
            if (currentTimeMinutes - this.m_HealingStartTime > this.GetHealingDuration())
            {
                this.PoisonDebuff(this.m_Slot.m_PoisonDebuff);
                this.RemoveBandage();
                this.m_HealingStartTime = float.MaxValue;
                if (this.m_PoisonLevel == 0)
                {
                    PlayerInjuryModule.Get().HealInjury(this);
                }
            }
        }
        else if (this.m_Type == InjuryType.Laceration || this.m_Type == InjuryType.LacerationCat)
        {
            if (this.m_State == InjuryState.Bleeding)
            {
                if (!this.m_Healing)
                {
                    DamageInfo damageInfo = new DamageInfo();
                    float      num        = 1f;
                    if (SleepController.Get().IsActive())
                    {
                        num = PlayerInjuryModule.GetSleepTimeFactor();
                        damageInfo.m_Damage = num * 0.2f;
                    }
                    else
                    {
                        damageInfo.m_Damage = Time.deltaTime * 0.2f * num;
                    }
                    damageInfo.m_PlayDamageSound = false;
                    Player.Get().TakeDamage(damageInfo);
                }
                if (this.m_HealingResultInjuryState == InjuryState.Infected && currentTimeMinutes - this.m_HealingStartTime > 20f)
                {
                    this.Infect();
                }
            }
            else if (this.m_State == InjuryState.Open)
            {
                if (this.m_HealingResultInjuryState == InjuryState.None)
                {
                    if (currentTimeMinutes - this.m_HealingStartTime > 20f)
                    {
                        PlayerInjuryModule.Get().HealInjury(this);
                    }
                }
                else if (currentTimeMinutes < this.m_HealingStartTime && currentTimeMinutes - this.m_StartTimeInMinutes > this.m_TimeToInfect)
                {
                    this.Infect();
                }
            }
            else if (this.m_State == InjuryState.Infected)
            {
                if (currentTimeMinutes - this.m_HealingStartTime > Injury.s_HealingLacerationBleedingDurationInMinutes)
                {
                    this.Disinfect();
                }
            }
            else if (this.m_State == InjuryState.Closed && currentTimeMinutes - this.m_HealingStartTime > Injury.s_HealingLacerationBleedingDurationInMinutes)
            {
                PlayerInjuryModule.Get().HealInjury(this);
            }
            if (currentTimeMinutes - this.m_HealingStartTime > Injury.s_HealingLacerationBleedingDurationInMinutes)
            {
                if (this.m_HealingResultInjuryState == InjuryState.Open)
                {
                    this.OpenWound();
                }
            }
            else if (currentTimeMinutes - this.m_HealingStartTime > 0f && this.m_HealingResultInjuryState == InjuryState.Closed)
            {
                this.CloseWound();
            }
        }
        else if (this.m_Type == InjuryType.Rash)
        {
            if (currentTimeMinutes - this.m_StartTimeInMinutes > this.GetHealingDuration())
            {
                PlayerInjuryModule.Get().HealInjury(this);
            }
        }
        else if (this.m_Type == InjuryType.Worm && currentTimeMinutes - this.m_HealingStartTime > 0f)
        {
            PlayerInjuryModule.Get().OpenChildrenInjuries(this);
            PlayerInjuryModule.Get().HealInjury(this);
        }
        if (this.m_Type == InjuryType.Leech && Time.time > this.m_EffectLastTime + this.m_EffectCooldown)
        {
            this.m_EffectLastTime = Time.time;
        }
    }
Пример #2
0
    private void UpdateActiveInjuries()
    {
        this.m_SanityDictionary.Clear();
        PlayerSanityModule playerSanityModule = PlayerSanityModule.Get();

        for (int i = 0; i < this.m_Injuries.Count; i++)
        {
            Injury injury = this.m_Injuries[i];
            if (!injury.m_Healing)
            {
                this.m_DamageInfo.m_Damager = base.gameObject;
                float num = 1f;
                if (SleepController.Get().IsActive())
                {
                    num = PlayerInjuryModule.GetSleepTimeFactor();
                    this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * num;
                }
                else
                {
                    this.m_DamageInfo.m_Damage = injury.m_HealthDecreasePerSec * Time.deltaTime * num;
                }
                this.m_DamageInfo.m_PlayDamageSound = false;
                this.m_Player.TakeDamage(this.m_DamageInfo);
                int num2 = 0;
                if (this.m_SanityDictionary.TryGetValue((int)injury.m_Type, out num2))
                {
                    Dictionary <int, int> sanityDictionary;
                    int type;
                    (sanityDictionary = this.m_SanityDictionary)[type = (int)injury.m_Type] = sanityDictionary[type] + 1;
                }
                else
                {
                    this.m_SanityDictionary.Add((int)injury.m_Type, 1);
                }
            }
            injury.Update();
        }
        foreach (KeyValuePair <int, int> keyValuePair in this.m_SanityDictionary)
        {
            switch (keyValuePair.Key)
            {
            case 0:
            {
                PlayerSanityModule playerSanityModule2 = playerSanityModule;
                PlayerSanityModule.SanityEventType evn = PlayerSanityModule.SanityEventType.SmallWoundAbrassion;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair2 = enumerator.Current;
                playerSanityModule2.OnEvent(evn, keyValuePair2.Value);
                break;
            }

            case 1:
            {
                PlayerSanityModule playerSanityModule3  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn2 = PlayerSanityModule.SanityEventType.SmallWoundScratch;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair3 = enumerator.Current;
                playerSanityModule3.OnEvent(evn2, keyValuePair3.Value);
                break;
            }

            case 2:
            {
                PlayerSanityModule playerSanityModule4  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn3 = PlayerSanityModule.SanityEventType.Laceration;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair4 = enumerator.Current;
                playerSanityModule4.OnEvent(evn3, keyValuePair4.Value);
                break;
            }

            case 3:
            {
                PlayerSanityModule playerSanityModule5  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn4 = PlayerSanityModule.SanityEventType.LacerationCat;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair5 = enumerator.Current;
                playerSanityModule5.OnEvent(evn4, keyValuePair5.Value);
                break;
            }

            case 4:
            {
                PlayerSanityModule playerSanityModule6  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn5 = PlayerSanityModule.SanityEventType.Rash;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair6 = enumerator.Current;
                playerSanityModule6.OnEvent(evn5, keyValuePair6.Value);
                break;
            }

            case 5:
            {
                PlayerSanityModule playerSanityModule7  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn6 = PlayerSanityModule.SanityEventType.Worm;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair7 = enumerator.Current;
                playerSanityModule7.OnEvent(evn6, keyValuePair7.Value);
                break;
            }

            case 6:
            {
                PlayerSanityModule playerSanityModule8  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn7 = PlayerSanityModule.SanityEventType.WormHole;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair8 = enumerator.Current;
                playerSanityModule8.OnEvent(evn7, keyValuePair8.Value);
                break;
            }

            case 7:
            {
                PlayerSanityModule playerSanityModule9  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn8 = PlayerSanityModule.SanityEventType.Leech;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair9 = enumerator.Current;
                playerSanityModule9.OnEvent(evn8, keyValuePair9.Value);
                break;
            }

            case 8:
            {
                PlayerSanityModule playerSanityModule10 = playerSanityModule;
                PlayerSanityModule.SanityEventType evn9 = PlayerSanityModule.SanityEventType.LeechHole;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair10 = enumerator.Current;
                playerSanityModule10.OnEvent(evn9, keyValuePair10.Value);
                break;
            }

            case 9:
            {
                PlayerSanityModule playerSanityModule11  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn10 = PlayerSanityModule.SanityEventType.VenomBite;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair11 = enumerator.Current;
                playerSanityModule11.OnEvent(evn10, keyValuePair11.Value);
                break;
            }

            case 10:
            {
                PlayerSanityModule playerSanityModule12  = playerSanityModule;
                PlayerSanityModule.SanityEventType evn11 = PlayerSanityModule.SanityEventType.SnakeBite;
                Dictionary <int, int> .Enumerator  enumerator;
                KeyValuePair <int, int>            keyValuePair12 = enumerator.Current;
                playerSanityModule12.OnEvent(evn11, keyValuePair12.Value);
                break;
            }
            }
        }
    }