Ejemplo n.º 1
0
        /// <summary>
        /// Checks if the character is drowning.
        /// </summary>
        private static void DrowningCheck(Pawn Daniel, TerrainDef BoX)
        {
            if (BoX.IsDeep())
            {
                var level = Daniel?.skills?.GetSkill(DefDatabase <SkillDef> .GetNamed("Swimming"))?.Level;
                if (level == null)
                {
                    return;
                }
                var math = (20 - level.Value) * 0.00001f;
                if (Daniel.apparel.GetDirectlyHeldThings().FirstOrDefault(x => x.TryGetComp <OxygenTank>() != null) is
                    ThingWithComps myTank)
                {
                    var nope = myTank.TryGetComp <OxygenTank>();
                    if (nope?.Air > 0)
                    {
                        if (Find.TickManager.TicksGame % 200 == 0)
                        {
                            nope.Air--;
                        }

                        return;
                    }
                }

                HealthUtility.AdjustSeverity(Daniel, HediffDef.Named("LZG_Drowning"), math);
            }

            else
            {
                HealthUtility.AdjustSeverity(Daniel, HediffDef.Named("LZG_Drowning"), -0.001f);
            }
        }