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;
            }
        }
Exemple #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;
            }
        }