コード例 #1
0
ファイル: UnitSystem.cs プロジェクト: 583qq/rtslike_dots
        // Heal
        public void Repair(Entity unit, uint heal)
        {
            if (!isAttackable(unit))
            {
                return;
            }

            AttackableComponent component = GetAttackableComponent(unit);

            uint durabilityPoints;

            // if it's greater than uint.MaxValue than just SET IT to the maximum
            if (GameUtilities.CheckUintSumOverflow(component.current, heal))
            {
                durabilityPoints = component.durability;
            }
            else
            {
                durabilityPoints = component.current + heal; // Else Set As It Is.
            }
            // Validate & Set
            if (durabilityPoints > component.durability)
            {
                component.current = component.durability;
            }
            else
            {
                component.current = durabilityPoints;
            }
            //

            SetAttackableComponent(unit, component);
        }