示例#1
0
 /// <summary>
 /// Transfers <see cref="Prop"/> to <paramref name="boneName"/> of <paramref name="entity"/>.
 /// </summary>
 /// <param name="entity">New <see cref="GTA.Entity"/> instance.</param>
 /// <param name="boneName">Bone's name.</param>
 public void TransferTo(Entity entity, string boneName)
 {
     Entity  = entity;
     _bone   = entity.Bones[boneName];
     _toBone = true;
     TransferTo(entity);
 }
示例#2
0
 /// <summary>
 /// Transfers <see cref="Prop"/> to <paramref name="entityBone"/> of <paramref name="entity"/>.
 /// </summary>
 /// <param name="entity">New <see cref="GTA.Entity"/> instance.</param>
 /// <param name="entityBone"><see cref="EntityBone"/> of <paramref name="entity"/>.</param>
 public void TransferTo(Entity entity, EntityBone entityBone)
 {
     Entity  = entity;
     _bone   = entityBone;
     _toBone = true;
     TransferTo(entity);
 }
示例#3
0
 public GTABone(EntityBone bone, int isVisible, RaycastResult res)
 {
     this.Pos       = new GTAVector(bone.Position);
     this.IsVisible = isVisible;
     this.DidHit    = res.DidHit;
     this.Material  = res.MaterialHash.ToString();
 }
示例#4
0
 public GTABone(EntityBone bone, int isVisible, bool didHit, string material)
 {
     this.Pos       = new GTAVector(bone.Position);
     this.IsVisible = isVisible;
     this.DidHit    = didHit;
     this.Material  = material;
 }
示例#5
0
        /// <summary>
        /// Creates a new <see cref="AnimateProp"/> instance.
        /// </summary>
        /// <param name="model"><see cref="CustomModel"/> of the <see cref="GTA.Prop"/>.</param>
        /// <param name="entity"><see cref="GTA.Entity"/> at which the <see cref="GTA.Prop"/> will be attached.</param>
        /// <param name="entityBone"><see cref="EntityBone"/> of <paramref name="entity"/>.</param>
        /// <param name="offset">Offset relative to <paramref name="entityBone"/>. Default <see cref="Vector3.Zero"/>.</param>
        /// <param name="rotation">Rotation relative to <paramref name="entityBone"/>. Default <see cref="Vector3.Zero"/>.</param>
        /// <param name="keepCollision">Whether keep collision when attached to <paramref name="entity"/>.</param>
        public AnimateProp(CustomModel model, Entity entity, EntityBone entityBone, Vector3 offset = default, Vector3 rotation = default, bool keepCollision = true)
        {
            Model         = model;
            Entity        = entity;
            _bone         = entityBone;
            Offset        = offset;
            Rotation      = rotation;
            _toBone       = true;
            KeepCollision = keepCollision;

            GlobalAnimatePropList.Add(this);
        }
示例#6
0
        // Get Closest Door To Remove
        private VehicleDoorIndex GetClosestDoorBone(Vehicle vehicle)
        {
            if (vehicle == null)
            {
                return((VehicleDoorIndex)(-1));
            }

            var FrontDriverDoorBone    = vehicle.Bones["door_dside_f"];
            var RearDriverDoorBone     = vehicle.Bones["door_dside_r"];
            var FrontPassengerDoorBone = vehicle.Bones["door_pside_f"];
            var RearPassengerDoorBone  = vehicle.Bones["door_pside_r"];
            var LocalPedPos            = LocalPlayer.Character.Position;

            VehicleDoorIndex ClosestDoorIndex = VehicleDoorIndex.FrontLeftDoor;
            EntityBone       ClosestBone      = FrontDriverDoorBone;

            // Checking For Closest Door
            if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, RearDriverDoorBone.Position))
            {
                ClosestBone      = RearDriverDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.BackLeftDoor;
            }
            else if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, FrontPassengerDoorBone.Position))
            {
                ClosestBone      = FrontPassengerDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.FrontRightDoor;
            }
            else if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, RearPassengerDoorBone.Position))
            {
                ClosestBone      = RearPassengerDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.BackRightDoor;
            }

            if (World.GetDistance(LocalPedPos, ClosestBone.Position) < 1.3f)
            {
                return(ClosestDoorIndex);
            }
            else
            {
                return((VehicleDoorIndex)(-1));
            }
        }
示例#7
0
        public virtual void SpawnProp(Vector3 offset, Vector3 rotation, bool deletePreviousProp = true)
        {
            _secondOffset   = offset;
            _secondRotation = rotation;

            // Delete the old prop
            if (deletePreviousProp)
            {
                DeleteProp();
            }

            if (!Model.IsValid || !Model.IsInCdImage)
            {
                Screen.ShowSubtitle(Model.ToString() + " not valid!");
            }

            // Request the model and wait for it to load
            ModelHandler.RequestModel(Model);

            // Spawn the new prop
            if (deletePreviousProp || Prop == null || !Prop.Exists())
            {
                Prop = World.CreateProp(Model, Vector3.Zero, false, false);
            }

            if (Bone == "")
            {
                Prop?.AttachTo(EntityAttachedTo, Offset + offset, Rotation + rotation);
            }
            else if (EntityAttachedTo.Bones.Contains(Bone))
            {
                EntityBone bone = EntityAttachedTo.Bones[Bone];
                Function.Call(Hash.ATTACH_ENTITY_TO_ENTITY, Prop.Handle, bone.Owner.Handle, bone.Index, offset.X, offset.Y, offset.Z, rotation.X, rotation.Y, rotation.Z, 0, 0, 0, 0, 2, 1);
            }

            Prop.IsPersistent = true;
            IsSpawned         = true;
        }
示例#8
0
 public GTABone(EntityBone bone)
 {
     this.Pos = new GTAVector(bone.Position);
 }
示例#9
0
 public MyBone(EntityBone bone)
 {
     Index      = bone.Index;
     Pose       = new MyVector3(bone.Pose);
     PoseMatrix = bone.PoseMatrix;
 }