Пример #1
0
        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;
            }
        }
Пример #2
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;
            }
        }