示例#1
0
 public LoopedParticle(string assetName, string particleName, Ped ped, PedBoneId bone, Vector3 offset, Rotator rotation, float scale)
 {
     AssetName    = assetName;
     ParticleName = particleName;
     LoadAsset();
     Handle = NativeFunction.Natives.StartParticleFxLoopedOnPedBone <uint>(particleName,
                                                                           ped,
                                                                           offset.X, offset.Y, offset.Z,
                                                                           rotation.Pitch, rotation.Roll, rotation.Yaw,
                                                                           ped.GetBoneIndex(bone),
                                                                           scale,
                                                                           false, false, false);
 }
        public void Run()
        {
            foreach (int i in _peds)
            {
                Ped ped = _peds.Components1[i].ThisPed;
                if (!ped.Exists())
                {
                    continue;
                }

                PedBoneId?[] history = _peds.Components2[i].LastDamagedBones;
                for (int historyIndex = 0; historyIndex < history.Length; historyIndex++)
                {
                    PedBoneId?boneId = history[historyIndex];
                    if (boneId == null || !ped.IsBoneValid(boneId.Value))
                    {
                        continue;
                    }

                    Color color;
                    float radius;
                    switch (historyIndex)
                    {
                    case 0:
                        color  = Color.DarkOrange;
                        radius = 0.15f;
                        break;

                    case 1:
                        color  = Color.Yellow;
                        radius = 0.14f;
                        break;

                    case 2:
                        color  = Color.ForestGreen;
                        radius = 0.13f;
                        break;

                    default:
                        continue;
                    }

                    PedBoneId bone     = boneId.Value;
                    Vector3   position = ped.GetBonePosition(bone);
                    Debug.DrawSphereDebug(position, radius, color);
                }
            }
        }
示例#3
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();
            }
        }
示例#4
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();
            }
        }
        public void Run()
        {
            if (_peds.IsEmpty())
            {
                _screenPositionList = null;
                _radiusList         = null;
                _colorList          = null;
                return;
            }

            Vector3 playerPosition     = Game.LocalPlayer.Character.Position;
            var     screenPositionList = new List <Vector2>();
            var     radiusList         = new List <float>();
            var     colorList          = new List <Color>();

            foreach (int i in _peds)
            {
                Ped ped = _peds.Components1[i].ThisPed;
                if (!ped.Exists())
                {
                    continue;
                }

                PedBoneId?[] history = _peds.Components2[i].LastDamagedBones;
                for (int historyIndex = 0; historyIndex < history.Length; historyIndex++)
                {
                    PedBoneId?boneId = history[historyIndex];
                    if (boneId == null || !ped.IsBoneValid(boneId.Value))
                    {
                        continue;
                    }

                    PedBoneId bone     = boneId.Value;
                    Vector3   position = ped.GetBonePosition(bone);
                    float     distance = Vector3.Distance(playerPosition, position);
                    if (distance >= MAXIMAL_RANGE)
                    {
                        continue;
                    }

                    Color color;
                    float radius;
                    switch (historyIndex)
                    {
                    case 0:
                        color  = Color.DarkOrange;
                        radius = 15f;
                        break;

                    case 1:
                        color  = Color.Yellow;
                        radius = 10f;
                        break;

                    case 2:
                        color  = Color.ForestGreen;
                        radius = 5f;
                        break;

                    default:
                        continue;
                    }

                    Vector2 screenPosition = World.ConvertWorldPositionToScreenPosition(position);
                    float   ratio          = 1 - distance / MAXIMAL_RANGE;
                    radius *= ratio;

                    screenPositionList.Add(screenPosition);
                    radiusList.Add(radius);
                    colorList.Add(color);
                }
            }

            _screenPositionList = screenPositionList;
            _radiusList         = radiusList;
            _colorList          = colorList;
        }