Beispiel #1
0
        public void Run()
        {
            if (_bleedingStats.EntitiesCount <= 0)
            {
                throw new Exception("BleedingSystem was not init!");
            }
            PedBleedingStatsComponent stats = _bleedingStats.Components1[0];

            foreach (int i in _newHumans)
            {
                int  humanEntity = _newHumans.Entities[i];
                bool isPlayer    = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                var info = _ecsWorld.AddComponent <BleedingInfoComponent>(humanEntity);
                info.BleedingHealRate = isPlayer
                    ? stats.PlayerBleedingHealRate
                    : Random.NextMinMax(stats.PedBleedingHealRate);
            }

            if (_healthStats.EntitiesCount <= 0)
            {
                throw new Exception("HealthSystem was not init!");
            }
            PedHealthStatsComponent healthStats = _healthStats.Components1[0];

            foreach (int i in _newAnimals)
            {
                Ped ped          = _newAnimals.Components1[i].ThisPed;
                int animalEntity = _newAnimals.Entities[i];

                float healthPercent = ped.GetHealth() / healthStats.PedHealth.Max;
                var   info          = _ecsWorld.AddComponent <BleedingInfoComponent>(animalEntity);
                info.BleedingHealRate = healthPercent * stats.PedBleedingHealRate.Max;
            }
        }
Beispiel #2
0
        public void Run()
        {
            PedBleedingStatsComponent stats = _bleedingStats.Components1[0];

            foreach (int i in _newHumans)
            {
                EcsEntity humanEntity = _newHumans.Entities[i];
                bool      isPlayer    = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                var info = _ecsWorld.AddComponent <PedBleedingInfoComponent>(humanEntity);
                info.BleedingHealRate = isPlayer
                    ? stats.PlayerBleedingHealRate
                    : _random.NextMinMax(stats.PedBleedingHealRate);
                info.BleedingHealRate /= HEAL_RATE_SLOWER;
            }

            PedHealthStatsComponent healthStats = _healthStats.Components1[0];

            foreach (int i in _newAnimals)
            {
                Ped       ped          = _newAnimals.Components1[i].ThisPed;
                EcsEntity animalEntity = _newAnimals.Entities[i];

                float healthPercent = ped.GetHealth() / healthStats.PedHealth.Max;
                var   info          = _ecsWorld.AddComponent <PedBleedingInfoComponent>(animalEntity);
                info.BleedingHealRate  = healthPercent * stats.PedBleedingHealRate.Max * stats.AnimalMult;
                info.BleedingHealRate /= HEAL_RATE_SLOWER;
            }
        }
        public void Run()
        {
            PedPainStatsComponent stats = _painStats.Components1[0];

            foreach (int i in _newHumans)
            {
                EcsEntity humanEntity = _newHumans.Entities[i];
                bool      isPlayer    = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                var painInfo = _ecsWorld.AddComponent <PainInfoComponent>(humanEntity);
                painInfo.UnbearablePain = isPlayer
                    ? stats.PlayerUnbearablePain
                    : _random.NextMinMax(stats.PedUnbearablePain);
                painInfo.PainRecoverySpeed = isPlayer
                    ? stats.PlayerPainRecoverySpeed
                    : _random.NextMinMax(stats.PedPainRecoverySpeed);
                painInfo.PainRecoverySpeed /= PAIN_RECOVER_RATE_SLOWER;
            }

            PedHealthStatsComponent healthStats = _healthStats.Components1[0];

            foreach (int i in _newAnimals)
            {
                Ped       ped          = _newAnimals.Components1[i].ThisPed;
                EcsEntity animalEntity = _newAnimals.Entities[i];

                float healthPercent = ped.GetHealth() / healthStats.PedHealth.Max;
                var   painInfo      = _ecsWorld.AddComponent <PainInfoComponent>(animalEntity);
                painInfo.UnbearablePain     = healthPercent * stats.PedUnbearablePain.Max;
                painInfo.PainRecoverySpeed  = healthPercent * stats.PedPainRecoverySpeed.Max;
                painInfo.PainRecoverySpeed /= PAIN_RECOVER_RATE_SLOWER;
            }
        }
Beispiel #4
0
        public void Run()
        {
            if (_healthStats.EntitiesCount <= 0)
            {
                throw new Exception("HealthSystem was not init!");
            }
            PedHealthStatsComponent stats = _healthStats.Components1[0];

            foreach (int i in _newHumans)
            {
                Ped ped         = _newHumans.Components1[i].ThisPed;
                int humanEntity = _newHumans.Entities[i];

                bool isPlayer = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                float healthAmount = isPlayer
                    ? stats.PlayerHealth
                    : Random.NextMinMax(stats.PedHealth);

                var health = _ecsWorld.AddComponent <HealthComponent>(humanEntity);
                health.MinHealth = 0;
                health.Health    = health.MinHealth + healthAmount;
                health.MaxHealth = (float)Math.Floor(health.Health);

                ped.SetMaxHealth(health.MaxHealth);
                ped.SetHealth(health.Health);
            }

            foreach (int i in _newAnimals)
            {
                Ped ped          = _newAnimals.Components1[i].ThisPed;
                int animalEntity = _newAnimals.Entities[i];

                var health = _ecsWorld.AddComponent <HealthComponent>(animalEntity);
                health.MinHealth = 0;
                health.Health    = health.MinHealth + ped.GetHealth();
                health.MaxHealth = (float)Math.Floor(health.Health);

                ped.SetMaxHealth(health.MaxHealth);
                ped.SetHealth(health.Health);
            }
        }
Beispiel #5
0
        public void Run()
        {
            if (_painStats.EntitiesCount <= 0)
            {
                throw new Exception("PainSystem was not init!");
            }
            PedPainStatsComponent stats = _painStats.Components1[0];

            foreach (int i in _newHumans)
            {
                int humanEntity = _newHumans.Entities[i];

                bool isPlayer = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                var painInfo = _ecsWorld.AddComponent <PainInfoComponent>(humanEntity);
                painInfo.UnbearablePain = isPlayer
                    ? stats.PlayerUnbearablePain
                    : Random.NextMinMax(stats.PedUnbearablePain);
                painInfo.PainRecoverySpeed = isPlayer
                    ? stats.PlayerPainRecoverySpeed
                    : Random.NextMinMax(stats.PedPainRecoverySpeed);
            }

            if (_healthStats.EntitiesCount <= 0)
            {
                throw new Exception("HealthSystem was not init!");
            }
            PedHealthStatsComponent healthStats = _healthStats.Components1[0];

            foreach (int i in _newAnimals)
            {
                Ped ped          = _newAnimals.Components1[i].ThisPed;
                int animalEntity = _newAnimals.Entities[i];

                float healthPercent = ped.GetHealth() / healthStats.PedHealth.Max;
                var   painInfo      = _ecsWorld.AddComponent <PainInfoComponent>(animalEntity);
                painInfo.UnbearablePain    = healthPercent * stats.PedUnbearablePain.Max;
                painInfo.PainRecoverySpeed = healthPercent * stats.PedPainRecoverySpeed.Max;
            }
        }
Beispiel #6
0
        public void Run()
        {
            PedHealthStatsComponent stats = _healthStats.Components1[0];

            foreach (int i in _newHumans)
            {
                Ped       ped         = _newHumans.Components1[i].ThisPed;
                EcsEntity humanEntity = _newHumans.Entities[i];
                bool      isPlayer    = _ecsWorld.GetComponent <PlayerMarkComponent>(humanEntity) != null;

                float healthAmount = isPlayer
                    ? stats.PlayerHealth
                    : _random.NextMinMax(stats.PedHealth);

                var health = _ecsWorld.AddComponent <HealthComponent>(humanEntity);
                health.MinHealth = 0;
                health.Health    = health.MinHealth + healthAmount;
                health.MaxHealth = (float)Math.Floor(health.Health);

                ped.SetMaxHealth(health.MaxHealth);
                ped.SetHealth(health.Health);
            }

            foreach (int i in _newAnimals)
            {
                Ped       ped          = _newAnimals.Components1[i].ThisPed;
                EcsEntity animalEntity = _newAnimals.Entities[i];

                var health = _ecsWorld.AddComponent <HealthComponent>(animalEntity);
                health.MinHealth = 0;
                health.Health    = health.MinHealth + ped.GetHealth();
                health.Health   *= stats.AnimalMult;
                health.MaxHealth = (float)Math.Floor(health.Health);

                ped.SetMaxHealth(health.MaxHealth);
                ped.SetHealth(health.Health);
            }
        }