Пример #1
0
        public void Run()
        {
            foreach (int i in _damagedPeds)
            {
                Ped ped = _damagedPeds.Components1[i].ThisPed;
                if (!ped.Exists())
                {
                    continue;
                }

                int pedEntity      = _damagedPeds.Entities[i];
                int bodyPartEntity = GetDamagedBodyPart(ped);
                if (bodyPartEntity < 0)
                {
                    continue;
                }

#if DEBUG
                PedBoneId lastBone = ped.LastDamageBone;
                var       partName = bodyPartEntity.GetEntityName(_ecsWorld);
                _logger.MakeLog($"Ped {ped.Name(pedEntity)} has damaged {partName} with boneId {(uint) lastBone}");

                var          history = _ecsWorld.EnsureComponent <BodyHitHistoryComponent>(pedEntity, out bool newBodyHitHistory);
                PedBoneId?[] bones   = history.LastDamagedBones;
                if (newBodyHitHistory)
                {
                    bones[0] = lastBone;
                    bones[1] = null;
                    bones[2] = null;
                }
                else
                {
                    bones[2] = bones[1];
                    bones[1] = bones[0];
                    bones[2] = lastBone;
                }
#endif

                _ecsWorld.AddComponent <DamagedBodyPartComponent>(pedEntity).DamagedBodyPartEntity = bodyPartEntity;
                ped.ClearLastDamageBone();
            }
        }
Пример #2
0
        public void Run()
        {
            foreach (int i in _damagedPeds)
            {
                Ped ped = _damagedPeds.Components1[i].ThisPed;
                if (!ped.Exists())
                {
                    continue;
                }

                EcsEntity pedEntity      = _damagedPeds.Entities[i];
                PedBoneId lastBone       = ped.LastDamageBone;
                EcsEntity bodyPartEntity = GetDamagedBodyPart(ped);

#if DEBUG
                string partName = bodyPartEntity.GetEntityName();
                _logger.MakeLog($"{pedEntity.GetEntityName()} has damaged {partName} with boneId {(uint) lastBone}");

                var          history = _ecsWorld.EnsureComponent <DamagedBoneHistoryComponent>(pedEntity, out bool isNew);
                PedBoneId?[] bones   = history.LastDamagedBones;
                if (isNew)
                {
                    bones[0] = lastBone;
                    bones[1] = null;
                    bones[2] = null;
                }
                else
                {
                    bones[2] = bones[1];
                    bones[1] = bones[0];
                    bones[0] = lastBone;
                }
#endif

                var damagedBodyPart = _ecsWorld.AddComponent <DamagedBodyPartComponent>(pedEntity);
                damagedBodyPart.DamagedBodyPartEntity = bodyPartEntity;
                damagedBodyPart.DamagedBoneId         = (uint)lastBone;
                ped.ClearLastDamageBone();
            }
        }