private void DetectWeaponHash(Ped ped, EcsEntity pedEntity)
        {
            foreach (int i in _weapons)
            {
                HashesComponent hashesComponent = _weapons.Components1[i];
                foreach (uint hash in hashesComponent.Hashes)
                {
                    if (!NativeFunction.Natives.HAS_PED_BEEN_DAMAGED_BY_WEAPON <bool>(ped, hash, 0))
                    {
                        continue;
                    }

                    EcsEntity weaponEntity = _weapons.Entities[i];
#if DEBUG
                    _logger.MakeLog($"{pedEntity.GetEntityName()} was damaged by {weaponEntity.GetEntityName()}({hash})");
#endif

                    var damaged = _ecsWorld.AddComponent <DamagedByWeaponComponent>(pedEntity);
                    damaged.WeaponEntity = weaponEntity;
                    return;
                }
            }

            _logger.MakeLog($"!!!WARNING!!! Ped {pedEntity.GetEntityName()} was damaged by UNKNOWN weapon");
        }
Exemple #2
0
        private void DetectWeaponHash(Ped ped, int pedEntity)
        {
            foreach (int i in _weapons)
            {
                HashesComponent hashesComponent = _weapons.Components1[i];

                foreach (uint hash in hashesComponent.Hashes)
                {
                    if (!NativeFunction.Natives.HAS_PED_BEEN_DAMAGED_BY_WEAPON <bool>(ped, hash, 0))
                    {
                        continue;
                    }

                    int weaponEntity = _weapons.Entities[i];
                    int woundEntity  = _weapons.Components3[i].WoundRandomizer.NextWithReplacement();
#if DEBUG
                    string weaponName = weaponEntity.GetEntityName(_ecsWorld);
                    string woundName  = woundEntity.GetEntityName(_ecsWorld);
                    _logger.MakeLog($"Ped {ped.Name(pedEntity)} was damaged by {weaponName} with wound {woundName}");
#endif

                    var damaged = _ecsWorld.AddComponent <DamagedByWeaponComponent>(pedEntity);
                    damaged.WeaponEntity = weaponEntity;
                    damaged.WoundEntity  = woundEntity;

                    var wounded = _ecsWorld.EnsureComponent <WoundedComponent>(pedEntity, out _);
                    wounded.WoundEntities.Add(woundEntity);
                    return;
                }
            }

            _logger.MakeLog($"!!!Ped {ped.Name(pedEntity)} was damaged by UNKNOWN weapon");
        }
Exemple #3
0
 public void Initialize()
 {
     _ecsWorld.CreateEntityWith(out BoneToBodyPartDictComponent dictComponent);
     foreach (int i in _partsWithHashes)
     {
         HashesComponent hashesComponent = _partsWithHashes.Components1[i];
         EcsEntity       entity          = _partsWithHashes.Entities[i];
         foreach (uint hash in hashesComponent.Hashes)
         {
             dictComponent.BoneIdToBodyPartEntity.Add(hash, entity);
         }
     }
 }
Exemple #4
0
        public void Initialize()
        {
            var listComponent = _ecsWorld.CreateEntityWith <BoneToBodyPartDictComponent>();

            foreach (int i in _partsWithHashes)
            {
                HashesComponent hashesComponent = _partsWithHashes.Components1[i];
                int             entity          = _partsWithHashes.Entities[i];

                foreach (uint hash in hashesComponent.Hashes)
                {
                    listComponent.BoneIdToBodyPartEntity.Add(hash, entity);
                }
            }
        }