Esempio n. 1
0
        private static async Task <int> SpawnInFrontOfPed(int ped, uint model)
        {
            var pedModel   = (uint)API.GetEntityModel(ped);
            var pos        = API.GetEntityCoords(ped, true);
            var heading    = API.GetEntityHeading(ped);
            var headingRad = (Math.PI / 180) * heading;

            await Common.RequestModel(model);

            var prop = API.CreateObject((int)model, pos.X - (float)Math.Sin(headingRad), pos.Y + (float)Math.Cos(headingRad), pos.Z - 1.0f, true, false, true);

            _props.Add(prop);

            API.SetEntityHeading(prop, -heading);
            API.SetEntityCollision(prop, true, true);
            API.ActivatePhysics(prop);
            API.DecorSetBool(prop, PropDecor, true);
            return(prop);
        }
Esempio n. 2
0
        private static async Task <int> SpawnOnEntity(int entity, uint model)
        {
            var subentity = API.GetEntityAttachedTo(entity);

            if (subentity > 0)
            {
                return(await SpawnOnEntity(subentity, model));
            }

            var     pos         = API.GetEntityCoords(entity, API.IsEntityAPed(entity));
            var     entityModel = (uint)API.GetEntityModel(entity);
            Vector3 entityMin   = Vector3.Zero;
            Vector3 entityMax   = Vector3.Zero;

            API.GetModelDimensions(entityModel, ref entityMin, ref entityMax);

            Vector3 propMin = Vector3.Zero;
            Vector3 propMax = Vector3.Zero;

            API.GetModelDimensions(model, ref propMin, ref propMax);

            await Common.RequestModel(model);

            var prop = API.CreateObject((int)model, pos.X, pos.Y, pos.Z + entityMax.Z - propMin.Z, true, false, true);

            _props.Add(prop);

            if (!API.DoesEntityHavePhysics(prop) || propMax.Z - propMin.Z > 3.0f) // large objects glitch too much
            {
                API.AttachEntityToEntity(prop, entity, 0, 0.0f, 0.0f, -propMin.Z, 0.0f, 0.0f, 0.0f, false, false, false, false, 0, true);
            }
            else
            {
                API.AttachEntityToEntityPhysically(prop, entity, 0, 0, 0.0f, 0.0f, entityMax.Z, 0.0f, 0.0f, propMin.Z, 0.0f, 0.0f, 0.0f, 100.0f, true, false, true, true, 2);
            }

            API.ActivatePhysics(prop);
            API.DecorSetBool(prop, PropDecor, true);
            return(prop);
        }
Esempio n. 3
0
 public void ActivatePhysics()
 {
     API.ActivatePhysics(Handle);
 }