Exemplo n.º 1
0
        private void TryUseMapProp(MapProp mapProp)
        {
            bool pickup = mapProp.CanBePickedUp && EditMode;

            if (pickup || mapProp.Interactable)
            {
                if (pickup)
                {
                    Game.DisableControlThisFrame(2, GTA.Control.Context);
                }
                if (mapProp.Interactable)
                {
                    DisableAttackActions();
                }
                GameExtended.DisableWeaponWheel();
                UiExtended.DisplayHelpTextThisFrame(string.Format("{0}", pickup ? $"Press ~INPUT_CONTEXT~ to pickup the {mapProp.Id}.\n" : ((!EditMode) ? "You're not in edit mode.\n" : "")) + string.Format("{0}", mapProp.Interactable ? string.Format("Press ~INPUT_ATTACK~ to {0}.", mapProp.IsDoor ? "Lock/Unlock" : "interact") : ""), false);
                if (Game.IsDisabledControlJustPressed(2, GTA.Control.Attack) && mapProp.Interactable)
                {
                    PlayerMap.Interacted?.Invoke(mapProp, PlayerInventory.Instance.ItemFromName(mapProp.Id));
                }
                if (Game.IsDisabledControlJustPressed(2, GTA.Control.Context) && mapProp.CanBePickedUp && PlayerInventory.Instance.PickupItem(PlayerInventory.Instance.ItemFromName(mapProp.Id), ItemType.Item))
                {
                    mapProp.Delete();
                    _map.Remove(mapProp);
                    ZombieVehicleSpawner.Instance.SpawnBlocker.Remove(mapProp.Position);
                }
            }
        }
Exemplo n.º 2
0
 private void CreateItemPreview()
 {
     if (Entity.op_Equality((Entity)this._currentPreview, (Entity)null))
     {
         this.PreviewComplete = false;
         this._currentOffset  = Vector3.get_Zero();
         Prop prop = World.CreateProp(Model.op_Implicit(this._currnetPropHash), (Vector3)null, (Vector3)null, false, false);
         if (Entity.op_Equality((Entity)prop, (Entity)null))
         {
             UI.Notify(string.Format("Failed to load prop, even after request.\nProp Name: {0}", (object)this._currnetPropHash));
             this._resultProp     = (Prop)null;
             this._preview        = false;
             this.PreviewComplete = true;
         }
         else
         {
             ((Entity)prop).set_HasCollision(false);
             this._currentPreview = prop;
             ((Entity)this._currentPreview).set_Alpha(150);
             Database.PlayerPed.get_Weapons().Select((WeaponHash) - 1569615261, true);
             this._resultProp = (Prop)null;
         }
     }
     else
     {
         UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_AIM~ to cancel.\nPress ~INPUT_ATTACK~ to place the item.", true);
         Game.DisableControlThisFrame(2, (Control)25);
         Game.DisableControlThisFrame(2, (Control)24);
         Game.DisableControlThisFrame(2, (Control)257);
         Game.DisableControlThisFrame(2, (Control)152);
         Game.DisableControlThisFrame(2, (Control)153);
         Game.DisableControlThisFrame(2, (Control)44);
         Game.DisableControlThisFrame(2, (Control)27);
         Game.DisableControlThisFrame(2, (Control)172);
         Game.DisableControlThisFrame(2, (Control)173);
         Game.DisableControlThisFrame(2, (Control)21);
         GameExtended.DisableWeaponWheel();
         if (Game.IsDisabledControlPressed(2, (Control)25))
         {
             ((Entity)this._currentPreview).Delete();
             this._currentPreview = this._resultProp = (Prop)null;
             this._preview        = false;
             this.PreviewComplete = true;
             ScriptEventHandler.Instance.UnregisterScript(new EventHandler(this.OnTick));
         }
         else
         {
             Vector3       position      = GameplayCamera.get_Position();
             Vector3       direction     = GameplayCamera.get_Direction();
             RaycastResult raycastResult = World.Raycast(position, Vector3.op_Addition(position, Vector3.op_Multiply(direction, 15f)), (IntersectOptions) - 1, (Entity)Database.PlayerPed);
             Vector3       hitCoords     = ((RaycastResult) ref raycastResult).get_HitCoords();
             if (Vector3.op_Inequality(hitCoords, Vector3.get_Zero()) && (double)((Vector3) ref hitCoords).DistanceTo(Database.PlayerPosition) > 1.5)
             {
                 ItemPreview.DrawScaleForms();
                 float num = Game.IsControlPressed(2, (Control)21) ? 1.5f : 1f;
                 if (Game.IsControlPressed(2, (Control)152))
                 {
                     Vector3    rotation = ((Entity)this._currentPreview).get_Rotation();
                     ref __Null local    = ref rotation.Z;
Exemplo n.º 3
0
 private void CreateItemPreview()
 {
     if (_currentPreview == null)
     {
         PreviewComplete = false;
         _currentOffset  = Vector3.Zero;
         Prop newProp = World.CreateProp(_currnetPropHash, default(Vector3), default(Vector3), false, false);
         if (newProp == null)
         {
             UI.Notify($"Failed to load prop, even after request.\nProp Name: {_currnetPropHash}");
             _resultProp     = null;
             _preview        = false;
             PreviewComplete = true;
         }
         else
         {
             newProp.HasCollision  = false;
             _currentPreview       = newProp;
             _currentPreview.Alpha = 150;
             Database.PlayerPed.Weapons.Select(GTA.Native.WeaponHash.Unarmed, true);
             _resultProp = null;
         }
     }
     else
     {
         UiExtended.DisplayHelpTextThisFrame("Press ~INPUT_AIM~ to cancel.\nPress ~INPUT_ATTACK~ to place the item.", true);
         Game.DisableControlThisFrame(2, GTA.Control.Aim);
         Game.DisableControlThisFrame(2, GTA.Control.Attack);
         Game.DisableControlThisFrame(2, GTA.Control.Attack2);
         Game.DisableControlThisFrame(2, GTA.Control.ParachuteBrakeLeft);
         Game.DisableControlThisFrame(2, GTA.Control.ParachuteBrakeRight);
         Game.DisableControlThisFrame(2, GTA.Control.Cover);
         Game.DisableControlThisFrame(2, GTA.Control.Phone);
         Game.DisableControlThisFrame(2, GTA.Control.PhoneUp);
         Game.DisableControlThisFrame(2, GTA.Control.PhoneDown);
         Game.DisableControlThisFrame(2, GTA.Control.Sprint);
         GameExtended.DisableWeaponWheel();
         if (Game.IsDisabledControlPressed(2, GTA.Control.Aim))
         {
             _currentPreview.Delete();
             _currentPreview = (_resultProp = null);
             _preview        = false;
             PreviewComplete = true;
             ScriptEventHandler.Instance.UnregisterScript(OnTick);
         }
         else
         {
             Vector3       camPos = GameplayCamera.Position;
             Vector3       camDir = GameplayCamera.Direction;
             RaycastResult cast   = World.Raycast(camPos, camPos + camDir * 15f, -1, new IntersectOptions(), Database.PlayerPed);
             Vector3       coords = cast.HitCoords;
             if (coords != Vector3.Zero && coords.DistanceTo(Database.PlayerPosition) > 1.5f)
             {
                 DrawScaleForms();
                 float speed = Game.IsControlPressed(2, GTA.Control.Sprint) ? 1.5f : 1f;
                 if (Game.IsControlPressed(2, GTA.Control.ParachuteBrakeLeft))
                 {
                     Vector3 rotation2 = _currentPreview.Rotation;
                     rotation2.Z += Game.LastFrameTime * 50f * speed;
                     _currentPreview.Rotation = rotation2;
                 }
                 else if (Game.IsControlPressed(2, GTA.Control.ParachuteBrakeRight))
                 {
                     Vector3 rotation = _currentPreview.Rotation;
                     rotation.Z -= Game.LastFrameTime * 50f * speed;
                     _currentPreview.Rotation = rotation;
                 }
                 if (Game.IsControlPressed(2, GTA.Control.PhoneUp))
                 {
                     _currentOffset.Z += Game.LastFrameTime * speed;
                 }
                 else if (Game.IsControlPressed(2, GTA.Control.PhoneDown))
                 {
                     _currentOffset.Z -= Game.LastFrameTime * speed;
                 }
                 _currentPreview.Position  = coords + _currentOffset;
                 _currentPreview.IsVisible = true;
                 if (Game.IsDisabledControlJustPressed(2, GTA.Control.Attack))
                 {
                     _currentPreview.ResetAlpha();
                     _resultProp = _currentPreview;
                     _resultProp.HasCollision   = true;
                     _resultProp.FreezePosition = !_isDoor;
                     _preview         = false;
                     _currentPreview  = null;
                     _currnetPropHash = string.Empty;
                     PreviewComplete  = true;
                     ScriptEventHandler.Instance.UnregisterScript(OnTick);
                 }
             }
             else
             {
                 _currentPreview.IsVisible = false;
             }
         }
     }
 }