Beispiel #1
0
        public void OnTick(object sender, EventArgs e)
        {
            // Load maps from "AutoloadMaps"
            if (!_hasLoaded)
            {
                AutoloadMaps();
                _hasLoaded = true;
            }
            _menuPool.ProcessMenus();
            PropStreamer.Tick();

            if (PropStreamer.EntityCount > 0 || PropStreamer.RemovedObjects.Count > 0 || PropStreamer.Markers.Count > 0 || PropStreamer.Pickups.Count > 0)
            {
                _currentEntitiesItem.Enabled = true;
                _currentEntitiesItem.Description = "";
            }
            else
            {
                _currentEntitiesItem.Enabled = false;
                _currentEntitiesItem.Description = Translation.Translate("There are no current entities.");
            }

            if (Game.IsControlPressed(0, Control.LookBehind) && Game.IsControlJustPressed(0, Control.FrontendLb) && !_menuPool.IsAnyMenuOpen() && _settings.Gamepad)
            {
                _mainMenu.Visible = !_mainMenu.Visible;
            }

            if (_settings.AutosaveInterval != -1 && DateTime.Now.Subtract(_lastAutosave).Minutes >= _settings.AutosaveInterval && PropStreamer.EntityCount > 0 && _changesMade > 0 && PropStreamer.EntityCount != _loadedEntities)
            {
                SaveMap("Autosave.xml", MapSerializer.Format.NormalXml);
                _lastAutosave = DateTime.Now;
            }

            if (_currentObjectsMenu.Visible)
            {
                if (Game.IsControlJustPressed(0, Control.PhoneLeft))
                {
                    if (_currentObjectsMenu.CurrentSelection <= 100)
                    {
                        _currentObjectsMenu.CurrentSelection = 0;
                    }
                    else
                    {
                        _currentObjectsMenu.CurrentSelection -= 100;
                    }
                }

                if (Game.IsControlJustPressed(0, Control.PhoneRight))
                {
                    if (_currentObjectsMenu.CurrentSelection >= _currentObjectsMenu.Size - 101)
                    {
                        _currentObjectsMenu.CurrentSelection = _currentObjectsMenu.Size - 1;
                    }
                    else
                    {
                        _currentObjectsMenu.CurrentSelection += 100;
                    }
                }
            }

            //
            // BELOW ONLY WHEN MAP EDITOR IS ACTIVE
            //

            if (!IsInFreecam) return;
            if(_settings.InstructionalButtons && !_objectsMenu.Visible)
                Function.Call(Hash._0x0DF606929C105BE1, _scaleform.Handle, 255, 255, 255, 255, 0);

            Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.CharacterWheel);
            Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.SelectWeapon);
            Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.FrontendPause);
            Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.NextCamera);
            Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.Phone);
            Function.Call(Hash.HIDE_HUD_AND_RADAR_THIS_FRAME);

            if (Game.IsControlJustPressed(0, Control.Enter) && !_isChoosingObject)
            {
                var oldType = _currentObjectType;
                _currentObjectType = ObjectTypes.Prop;
                if(oldType != _currentObjectType)
                    RedrawObjectsMenu(type: _currentObjectType);

                _isChoosingObject = true;
                _snappedProp = null;
                _selectedProp = null;
                _menuPool.CloseAllMenus();

                if (_quitWithSearchVisible && oldType == _currentObjectType)
                {
                    _searchMenu.Visible = true;
                    OnIndexChange(_searchMenu, _searchMenu.CurrentSelection);
                }
                else
                {
                    _objectsMenu.Visible = true;
                    OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                }

                _objectsMenu.Subtitle.Caption = "~b~" + Translation.Translate("PLACE") + " " + _currentObjectType.ToString().ToUpper();
            }

            if (Game.IsControlJustPressed(0, Control.NextCamera) && !_isChoosingObject)
            {
                var oldType = _currentObjectType;
                _currentObjectType = ObjectTypes.Vehicle;
                if (oldType != _currentObjectType)
                    RedrawObjectsMenu(type: _currentObjectType);
                _isChoosingObject = true;
                _snappedProp = null;
                _selectedProp = null;
                _menuPool.CloseAllMenus();

                if (_quitWithSearchVisible && oldType == _currentObjectType)
                {
                    _searchMenu.Visible = true;
                    OnIndexChange(_searchMenu, _searchMenu.CurrentSelection);
                }
                else
                {
                    _objectsMenu.Visible = true;
                    OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                }
                _objectsMenu.Subtitle.Caption = "~b~" + Translation.Translate("PLACE") + " " + _currentObjectType.ToString().ToUpper();
            }

            if (Game.IsControlJustPressed(0, Control.FrontendPause) && !_isChoosingObject)
            {
                var oldType = _currentObjectType;
                _currentObjectType = ObjectTypes.Ped;
                if (oldType != _currentObjectType)
                    RedrawObjectsMenu(type: _currentObjectType);
                _isChoosingObject = true;
                _snappedProp = null;
                _selectedProp = null;
                _menuPool.CloseAllMenus();

                if (_quitWithSearchVisible && oldType == _currentObjectType)
                {
                    _searchMenu.Visible = true;
                    OnIndexChange(_searchMenu, _searchMenu.CurrentSelection);
                }
                else
                {
                    _objectsMenu.Visible = true;
                    OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                }
                _objectsMenu.Subtitle.Caption = "~b~" + Translation.Translate("PLACE") + " " + _currentObjectType.ToString().ToUpper();
            }

            if (Game.IsControlJustPressed(0, Control.Phone) && !_isChoosingObject && !_menuPool.IsAnyMenuOpen())
            {
                _snappedProp = null;
                _selectedProp = null;
                _snappedMarker = null;
                _selectedMarker = null;

                var tmpMark = new Marker()
                {
                    Red = Color.Yellow.R,
                    Green = Color.Yellow.G,
                    Blue = Color.Yellow.B,
                    Alpha = Color.Yellow.A,
                    Scale = new Vector3(0.75f, 0.75f, 0.75f),
                    Type =  MarkerType.UpsideDownCone,
                    Position = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character),
                    Id = _markerCounter,
                };
                PropStreamer.Markers.Add(tmpMark);
                _snappedMarker = tmpMark;
                _markerCounter++;
                _changesMade++;
                AddItemToEntityMenu(_snappedMarker);
            }

            if (Game.IsControlJustPressed(0, Control.ThrowGrenade) && !_isChoosingObject && !_menuPool.IsAnyMenuOpen())
            {
                _snappedProp = null;
                _selectedProp = null;
                _snappedMarker = null;
                _selectedMarker = null;

                var pickup = PropStreamer.CreatePickup(new Model((int) ObjectDatabase.PickupHash.Parachute),
                    VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation,
                        Game.Player.Character), 0f, 100, false);

                _changesMade++;
                AddItemToEntityMenu(pickup);
                _snappedProp = new Prop(pickup.ObjectHandle);
            }

            if (_isChoosingObject)
            {
                if (_previewProp != null)
                {
                    _previewProp.Rotation = _previewProp.Rotation + (_zAxis ? new Vector3(0f, 0f, 2.5f) : new Vector3(2.5f, 0f, 0f));
                    if (_zAxis && IsPed(_previewProp))
                        _previewProp.Heading = _previewProp.Rotation.Z;
                    DrawEntityBox(_previewProp, Color.White);
                }

                if (Game.IsControlJustPressed(0, Control.SelectWeapon))
                    _zAxis = !_zAxis;

                if (_objectPreviewCamera == null)
                {
                    _objectPreviewCamera = World.CreateCamera(new Vector3(1200.016f, 4000.998f, 86.05062f), new Vector3(0f, 0f, 0f), 60f);
                    _objectPreviewCamera.PointAt(_objectPreviewPos);
                }

                if (Game.IsControlPressed(0, Control.MoveDownOnly))
                {
                    _objectPreviewCamera.Position -= new Vector3(0f, 0.5f, 0f);
                }

                if (Game.IsControlPressed(0, Control.MoveUpOnly))
                {
                    _objectPreviewCamera.Position += new Vector3(0f, 0.5f, 0f);
                }

                if (Game.IsControlJustPressed(0, Control.PhoneLeft))
                {
                    if (_objectsMenu.CurrentSelection <= 100)
                    {
                        _objectsMenu.CurrentSelection = 0;
                        OnIndexChange(_objectsMenu, 0);
                    }
                    else
                    {
                        _objectsMenu.CurrentSelection -= 100;
                        OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                    }
                }

                if (Game.IsControlJustPressed(0, Control.PhoneRight))
                {
                    if (_objectsMenu.CurrentSelection >= _objectsMenu.Size - 101)
                    {
                        _objectsMenu.CurrentSelection = _objectsMenu.Size - 1;
                        OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                    }
                    else
                    {
                        _objectsMenu.CurrentSelection += 100;
                        OnIndexChange(_objectsMenu, _objectsMenu.CurrentSelection);
                    }
                }

                World.RenderingCamera = _objectPreviewCamera;

                if (Game.IsControlJustPressed(0, Control.PhoneCancel) && !_searchResultsOn)
                {
                    _isChoosingObject = false;
                    _objectsMenu.Visible = false;
                    _previewProp?.Delete();
                }

                if (Game.IsControlJustPressed(0, Control.PhoneCancel) && _searchResultsOn)
                {
                    //RedrawObjectsMenu(type: _currentObjectType);
                    _searchMenu.Visible = false;
                    _objectsMenu.Visible = true;
                    OnIndexChange(_objectsMenu, 0);
                    _searchResultsOn = false;
                    _objectsMenu.Subtitle.Caption = "~b~" + Translation.Translate("PLACE") + " " + _currentObjectType.ToString().ToUpper();
                }

                if (Game.IsControlJustPressed(0, Control.Jump))
                {
                    string query = Game.GetUserInput(255);
                    if(String.IsNullOrWhiteSpace(query)) return;
                    if (query[0] == ' ')
                        query = query.Remove(0, 1);
                    _objectsMenu.Visible = false;
                    RedrawSearchMenu(query, _currentObjectType);
                    if(_searchMenu.Size != 0)
                        OnIndexChange(_searchMenu, 0);
                    _searchMenu.Subtitle.Caption = "~b~" + Translation.Translate("SEARCH RESULTS FOR") + " \"" + query.ToUpper() + "\"";
                    _searchMenu.Visible = true;
                    _searchResultsOn = true;
                }
                return;
            }
            World.RenderingCamera = _mainCamera;

            var res = UIMenu.GetScreenResolutionMantainRatio();
            var safe = UIMenu.GetSafezoneBounds();

            if (_settings.PropCounterDisplay)
            {
                const int interval = 45;

                new UIResText(Translation.Translate("PICKUPS"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - (90 + (5 * interval))), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.Pickups.Count.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - (102 + (5 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - (100 + (5 * interval))), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();

                new UIResText(Translation.Translate("MARKERS"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - (90 + (4 * interval))), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.Markers.Count.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - (102 + (4 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - (100 + (4 * interval))), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();

                new UIResText(Translation.Translate("WORLD"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - (90 + (3 * interval))), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.RemovedObjects.Count.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - (102 + (3 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - (100 + (3 * interval))), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();

                new UIResText(Translation.Translate("PROPS"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - (90 + (2*interval))), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.PropCount.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - (102 + (2 * interval))), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - (100 + (2 * interval))), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();

                new UIResText(Translation.Translate("VEHICLES"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - (90 + interval)), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.Vehicles.Count.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - (102 + interval)), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - (100 + interval)), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();

                new UIResText(Translation.Translate("PEDS"), new Point((int)(res.Width) - safe.X - 90, (int)(res.Height) - safe.Y - 90), 0.3f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new UIResText(PropStreamer.Peds.Count.ToString(), new Point((int)(res.Width) - safe.X - 20, (int)(res.Height) - safe.Y - 102), 0.5f, Color.White, Font.ChaletLondon, UIResText.Alignment.Right).Draw();
                new Sprite("timerbars", "all_black_bg", new Point((int)(res.Width) - safe.X - 248, (int)(res.Height) - safe.Y - 100), new Size(250, 37), 0f, Color.FromArgb(180, 255, 255, 255)).Draw();
            }

            int wi = (int)(res.Width*0.5);
            int he = (int)(res.Height * 0.5);

            Entity hitEnt = VectorExtensions.RaycastEntity(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation);

            if (_settings.CrosshairType == CrosshairType.Crosshair)
            {
                var crossColor = _crosshairPath;
                if (hitEnt != null && hitEnt.Handle != 0 && !PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                    crossColor = _crosshairBluePath;
                else if (hitEnt != null && hitEnt.Handle != 0 && PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                    crossColor = _crosshairYellowPath;
                Sprite.DrawTexture(crossColor, new Point(wi - 15, he - 15), new Size(30, 30));
            }

            //Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.CharacterWheel);
            //Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.SelectWeapon);
            //Function.Call(Hash.DISABLE_CONTROL_ACTION, 0, (int)Control.FrontendPause);
            Function.Call(Hash.DISABLE_ALL_CONTROL_ACTIONS, 0);
            Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)Control.LookLeftRight);
            Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)Control.LookUpDown);
            Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)Control.CursorX);
            Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)Control.CursorY);
            Function.Call(Hash.ENABLE_CONTROL_ACTION, 0, (int)Control.FrontendPauseAlternate);

            var mouseX = Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.LookLeftRight);
            var mouseY = Function.Call<float>(Hash.GET_CONTROL_NORMAL, 0, (int)Control.LookUpDown);

            mouseX *= -1;
            mouseY *= -1;

            switch (Game.CurrentInputMode)
            {
                case InputMode.MouseAndKeyboard:
                    mouseX *= _settings.CameraSensivity;
                    mouseY *= _settings.CameraSensivity;
                    break;
                case InputMode.GamePad:
                    mouseX *= _settings.GamepadCameraSensitivity;
                    mouseY *= _settings.GamepadCameraSensitivity;
                    break;
            }

            float movementModifier = 1f;
            if (Game.IsControlPressed(0, Control.Sprint))
                movementModifier = 5f;
            else if (Game.IsControlPressed(0, Control.CharacterWheel))
                movementModifier = 0.3f;

            switch (Game.CurrentInputMode)
            {
                case InputMode.MouseAndKeyboard:
                    float baseSpeed = _settings.KeyboardMovementSensitivity / 30f; // 1 - 60, baseSpeed = 0.03 - 2
                    movementModifier *= baseSpeed;
                    break;
                case InputMode.GamePad:
                    float gamepadSpeed = _settings.GamepadMovementSensitivity / 30f; // 1 - 60, baseSpeed = 0.03 - 2
                    movementModifier *= gamepadSpeed;
                    break;
            }

            float modifier = 1f;
            if (Game.IsControlPressed(0, Control.Sprint))
                modifier = 5f;
            else if (Game.IsControlPressed(0, Control.CharacterWheel))
                modifier = 0.3f;

            if (_selectedProp == null && _selectedMarker == null)
            {
                if(!_menuPool.IsAnyMenuOpen() || Game.CurrentInputMode == InputMode.GamePad)
                    _mainCamera.Rotation = new Vector3(_mainCamera.Rotation.X + mouseY, _mainCamera.Rotation.Y, _mainCamera.Rotation.Z + mouseX);

                var dir = VectorExtensions.RotationToDirection(_mainCamera.Rotation);
                var rotLeft = _mainCamera.Rotation + new Vector3(0, 0, -10);
                var rotRight = _mainCamera.Rotation + new Vector3(0, 0, 10);
                var right = VectorExtensions.RotationToDirection(rotRight) - VectorExtensions.RotationToDirection(rotLeft);

                var newPos = _mainCamera.Position;
                if (Game.IsControlPressed(0, Control.MoveUpOnly))
                {
                    newPos += dir* movementModifier;
                }
                if (Game.IsControlPressed(0, Control.MoveDownOnly))
                {
                    newPos -= dir* movementModifier;
                }
                if (Game.IsControlPressed(0, Control.MoveLeftOnly))
                {
                    newPos += right* movementModifier;
                }
                if (Game.IsControlPressed(0, Control.MoveRightOnly))
                {
                    newPos -= right* movementModifier;
                }
                _mainCamera.Position = newPos;
                Game.Player.Character.PositionNoOffset = _mainCamera.Position - dir*8f;

                if (_snappedProp != null)
                {
                    if (!IsProp(_snappedProp))
                        _snappedProp.Position = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, _snappedProp);
                    else
                        _snappedProp.PositionNoOffset = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, _snappedProp);
                    if (Game.IsControlPressed(0, Control.CursorScrollUp) || Game.IsControlPressed(0, Control.FrontendRb))
                    {
                        _snappedProp.Rotation = _snappedProp.Rotation - new Vector3(0f, 0f, modifier);
                        if (IsPed(_snappedProp))
                            _snappedProp.Heading = _snappedProp.Rotation.Z;
                    }

                    if (Game.IsControlPressed(0, Control.CursorScrollDown) || Game.IsControlPressed(0, Control.FrontendLb))
                    {
                        _snappedProp.Rotation = _snappedProp.Rotation + new Vector3(0f, 0f, modifier);
                        if (IsPed(_snappedProp))
                            _snappedProp.Heading = _snappedProp.Rotation.Z;
                    }

                    if (Game.IsControlJustPressed(0, Control.CreatorDelete))
                    {
                        RemoveItemFromEntityMenu(_snappedProp);
                        if (PropStreamer.IsPickup(_snappedProp.Handle))
                        {
                            PropStreamer.RemovePickup(_snappedProp.Handle);
                        }
                        else
                        {
                            PropStreamer.RemoveEntity(_snappedProp.Handle);
                            if (PropStreamer.Identifications.ContainsKey(_snappedProp.Handle))
                                PropStreamer.Identifications.Remove(_snappedProp.Handle);
                        }
                        _snappedProp = null;
                        _changesMade++;
                    }

                    if (Game.IsControlJustPressed(0, Control.Attack))
                    {
                        if (PropStreamer.IsPickup(_snappedProp.Handle))
                        {
                            PropStreamer.GetPickup(_snappedProp.Handle).UpdatePos();
                        }
                        _snappedProp = null;
                        _changesMade++;
                    }
                    InstructionalButtonsStart();
                    InstructionalButtonsSnapped();
                    InstructionalButtonsEnd();
                }
                else if (_snappedMarker != null)
                {
                    _snappedMarker.Position = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                    if (Game.IsControlPressed(0, Control.CursorScrollUp) || Game.IsControlPressed(0, Control.FrontendRb))
                    {
                        _snappedMarker.Rotation = _snappedMarker.Rotation - new Vector3(0f, 0f, modifier);
                    }

                    if (Game.IsControlPressed(0, Control.CursorScrollDown) || Game.IsControlPressed(0, Control.FrontendLb))
                    {
                        _snappedMarker.Rotation = _snappedMarker.Rotation + new Vector3(0f, 0f, modifier);
                    }

                    if (Game.IsControlJustPressed(0, Control.CreatorDelete))
                    {
                        RemoveMarkerFromEntityMenu(_snappedMarker.Id);
                        PropStreamer.Markers.Remove(_snappedMarker);
                        _snappedMarker = null;
                        _changesMade++;
                    }

                    if (Game.IsControlJustPressed(0, Control.Attack))
                    {
                        _snappedMarker = null;
                        _changesMade++;
                    }

                    InstructionalButtonsStart();
                    InstructionalButtonsSnapped();
                    InstructionalButtonsEnd();
                }
                else if(_snappedProp == null && _snappedMarker == null)
                {
                    if (_settings.CrosshairType == CrosshairType.Orb)
                    {
                        var pos = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                        var color = Color.FromArgb(255, 200, 20, 20);
                        if (hitEnt != null && hitEnt.Handle != 0 && !PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                            color = Color.FromArgb(255, 20, 20, 255);
                        else if (hitEnt != null && hitEnt.Handle != 0 && PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                            color = Color.FromArgb(255, 200, 200, 20);
                        Function.Call(Hash.DRAW_MARKER, 28, pos.X, pos.Y, pos.Z, 0f, 0f, 0f, 0f, 0f, 0f, 0.20f, 0.20f, 0.20f, color.R, color.G, color.B, color.A, false, true, 2, false, false, false, false);
                    }

                    if (Game.IsControlJustPressed(0, Control.Aim))
                    {
                        if (hitEnt != null && PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                        {
                            if (PropStreamer.IsPickup(hitEnt.Handle))
                                _snappedProp = new Prop(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, hitEnt.Handle))
                                _snappedProp = new Prop(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_VEHICLE, hitEnt.Handle))
                                _snappedProp = new Vehicle(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, hitEnt.Handle))
                                _snappedProp = new Ped(hitEnt.Handle);
                            _changesMade++;
                        }
                        else
                        {
                            var pos = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                            Marker mark = PropStreamer.Markers.FirstOrDefault(m => (m.Position - pos).Length() < 2f);
                            if (mark != null)
                            {
                                _snappedMarker = mark;
                                _changesMade++;
                            }
                        }
                    }

                    if (Game.IsControlJustPressed(0, Control.Attack))
                    {
                        if (hitEnt != null && PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                        {
                            if (PropStreamer.IsPickup(hitEnt.Handle))
                                _selectedProp = new Prop(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, hitEnt.Handle))
                                _selectedProp = new Prop(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_VEHICLE, hitEnt.Handle))
                                _selectedProp = new Vehicle(hitEnt.Handle);
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, hitEnt.Handle))
                                _selectedProp = new Ped(hitEnt.Handle);
                            RedrawObjectInfoMenu(_selectedProp, true);
                            _menuPool.CloseAllMenus();
                            _objectInfoMenu.Visible = true;
                            if(_settings.SnapCameraToSelectedObject)
                                _mainCamera.PointAt(_selectedProp);
                            _changesMade++;
                        }
                        else
                        {
                            var pos = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                            Marker mark = PropStreamer.Markers.FirstOrDefault(m => (m.Position - pos).Length() < 2f);
                            if (mark != null)
                            {
                                _selectedMarker = mark;
                                RedrawObjectInfoMenu(_selectedMarker, true);
                                _menuPool.CloseAllMenus();
                                _objectInfoMenu.Visible = true;
                                _changesMade++;
                            }
                        }
                    }

                    if (Game.IsControlJustReleased(0, Control.LookBehind))
                    {
                        if (hitEnt != null)
                        {
                            if (PropStreamer.IsPickup(hitEnt.Handle))
                            {
                                var oldPickup = PropStreamer.GetPickup(hitEnt.Handle);
                                var newPickup = PropStreamer.CreatePickup(new Model(oldPickup.PickupHash), oldPickup.Position,
                                    new Prop(oldPickup.ObjectHandle).Rotation.Z, oldPickup.Amount, oldPickup.Dynamic);
                                AddItemToEntityMenu(newPickup);
                                _snappedProp = new Prop(newPickup.ObjectHandle);
                            }
                            else if (Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, hitEnt.Handle))
                            {
                                var isDoor = PropStreamer.Doors.Contains(hitEnt.Handle);
                                AddItemToEntityMenu(_snappedProp = PropStreamer.CreateProp(hitEnt.Model, hitEnt.Position, hitEnt.Rotation, (!PropStreamer.StaticProps.Contains(hitEnt.Handle) && !isDoor), q: Quaternion.GetEntityQuaternion(hitEnt), force: true, drawDistance: _settings.DrawDistance));
                                if (isDoor)
                                {
                                    _snappedProp.FreezePosition = false;
                                    PropStreamer.Doors.Add(_snappedProp.Handle);
                                }
                            }
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_VEHICLE, hitEnt.Handle))
                                AddItemToEntityMenu(_snappedProp = PropStreamer.CreateVehicle(hitEnt.Model, hitEnt.Position, hitEnt.Rotation.Z, !PropStreamer.StaticProps.Contains(hitEnt.Handle), drawDistance: _settings.DrawDistance));
                            else if (Function.Call<bool>(Hash.IS_ENTITY_A_PED, hitEnt.Handle))
                            {
                                AddItemToEntityMenu(_snappedProp = Function.Call<Ped>(Hash.CLONE_PED, ((Ped)hitEnt).Handle, hitEnt.Rotation.Z, 1, 1));
                                if(_snappedProp != null)
                                    PropStreamer.Peds.Add(_snappedProp.Handle);

                                if (_settings.DrawDistance != -1)
                                    _snappedProp.LodDistance = _settings.DrawDistance;

                                if (PropStreamer.StaticProps.Contains(hitEnt.Handle))
                                {
                                    _snappedProp.FreezePosition = true;
                                    PropStreamer.StaticProps.Add(_snappedProp.Handle);
                                }

                                if(!PropStreamer.ActiveScenarios.ContainsKey(_snappedProp.Handle))
                                    PropStreamer.ActiveScenarios.Add(_snappedProp.Handle, "None");

                                if(PropStreamer.ActiveRelationships.ContainsKey(hitEnt.Handle))
                                    PropStreamer.ActiveRelationships.Add(_snappedProp.Handle, PropStreamer.ActiveRelationships[hitEnt.Handle]);
                                else if (!PropStreamer.ActiveRelationships.ContainsKey(_snappedProp.Handle))
                                    PropStreamer.ActiveRelationships.Add(_snappedProp.Handle, DefaultRelationship.ToString());

                                if(PropStreamer.ActiveWeapons.ContainsKey(hitEnt.Handle))
                                    PropStreamer.ActiveWeapons.Add(_snappedProp.Handle, PropStreamer.ActiveWeapons[hitEnt.Handle]);
                                else if(!PropStreamer.ActiveWeapons.ContainsKey(_snappedProp.Handle))
                                    PropStreamer.ActiveWeapons.Add(_snappedProp.Handle, WeaponHash.Unarmed);
                            }
                            _changesMade++;
                        }
                        else
                        {
                            var pos = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                            Marker mark = PropStreamer.Markers.FirstOrDefault(m => (m.Position - pos).Length() < 2f);
                            if (mark != null)
                            {
                                var tmpMark = new Marker()
                                {
                                    BobUpAndDown = mark.BobUpAndDown,
                                    Red = mark.Red,
                                    Green = mark.Green,
                                    Blue = mark.Blue,
                                    Alpha = mark.Alpha,
                                    Position = mark.Position,
                                    RotateToCamera = mark.RotateToCamera,
                                    Rotation = mark.Rotation,
                                    Scale = mark.Scale,
                                    Type = mark.Type,
                                    Id = _markerCounter,
                                };
                                _markerCounter++;
                                AddItemToEntityMenu(tmpMark);
                                PropStreamer.Markers.Add(tmpMark);
                                _snappedMarker = tmpMark;
                                _changesMade++;
                            }
                        }
                    }

                    if (Game.IsControlJustPressed(0, Control.CreatorDelete))
                    {
                        if (hitEnt != null && PropStreamer.GetAllHandles().Contains(hitEnt.Handle))
                        {
                            RemoveItemFromEntityMenu(hitEnt);
                            if (PropStreamer.Identifications.ContainsKey(hitEnt.Handle))
                                PropStreamer.Identifications.Remove(hitEnt.Handle);
                            if (PropStreamer.ActiveScenarios.ContainsKey(hitEnt.Handle))
                                PropStreamer.ActiveScenarios.Remove(hitEnt.Handle);
                            if (PropStreamer.ActiveRelationships.ContainsKey(hitEnt.Handle))
                                PropStreamer.ActiveRelationships.Remove(hitEnt.Handle);
                            if (PropStreamer.ActiveWeapons.ContainsKey(hitEnt.Handle))
                                PropStreamer.ActiveWeapons.Remove(hitEnt.Handle);
                            PropStreamer.RemoveEntity(hitEnt.Handle);
                            _changesMade++;
                        }
                        else if(hitEnt != null && !PropStreamer.GetAllHandles().Contains(hitEnt.Handle) && Function.Call<bool>(Hash.IS_ENTITY_AN_OBJECT, hitEnt.Handle))
                        {
                            MapObject tmpObj = new MapObject()
                            {
                                Hash = hitEnt.Model.Hash,
                                Position = hitEnt.Position,
                                Rotation = hitEnt.Rotation,
                                Quaternion = Quaternion.GetEntityQuaternion(hitEnt),
                                Type = ObjectTypes.Prop,
                                Id = _mapObjCounter.ToString(),
                            };
                            _mapObjCounter++;
                            PropStreamer.RemovedObjects.Add(tmpObj);
                            AddItemToEntityMenu(tmpObj);
                            hitEnt.Delete();
                            _changesMade++;
                        }
                        else
                        {
                            var pos = VectorExtensions.RaycastEverything(new Vector2(0f, 0f), _mainCamera.Position, _mainCamera.Rotation, Game.Player.Character);
                            Marker mark = PropStreamer.Markers.FirstOrDefault(m => (m.Position - pos).Length() < 2f);
                            if (mark != null)
                            {
                                PropStreamer.Markers.Remove(mark);
                                RemoveMarkerFromEntityMenu(mark.Id);
                                _changesMade++;
                            }
                        }
                    }
                    InstructionalButtonsStart();
                    InstructionalButtonsFreelook();
                    InstructionalButtonsEnd();
                }
            }
            else if(_selectedProp != null)//_selectedProp isnt null
            {
                var tmp = _controlsRotate ? Color.FromArgb(200, 200, 20, 20) : Color.FromArgb(200, 200, 200, 10);
                var modelDims = _selectedProp.Model.GetDimensions();
                Function.Call(Hash.DRAW_MARKER, 0, _selectedProp.Position.X, _selectedProp.Position.Y, _selectedProp.Position.Z + modelDims.Z + 2f, 0f, 0f, 0f, 0f, 0f, 0f, 2f, 2f, 2f, tmp.R, tmp.G, tmp.B, tmp.A, 1, 0, 2, 2, 0, 0, 0);

                DrawEntityBox(_selectedProp, tmp);

                if (Game.IsControlJustReleased(0, Control.Duck))
                {
                    _controlsRotate = !_controlsRotate;
                }
                if (Game.IsControlPressed(0, Control.FrontendRb))
                {
                    float pedMod = 0f;
                    if (_selectedProp is Ped)
                        pedMod = -1f;
                    if (!_controlsRotate)
                    {
                        if (!IsProp(_selectedProp))
                            _selectedProp.Position = _selectedProp.Position + new Vector3(0f, 0f, (modifier / 4) + pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position + new Vector3(0f, 0f, (modifier/4) + pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X, _selectedProp.Rotation.Y, _selectedProp.Rotation.Z - (modifier / 4)).ToQuaternion();
                        if (IsPed(_selectedProp))
                            _selectedProp.Heading = _selectedProp.Rotation.Z;
                    }

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                    _changesMade++;
                }
                if (Game.IsControlPressed(0, Control.FrontendLb))
                {
                    float pedMod = 0f;
                    if (_selectedProp is Ped)
                        pedMod = 1f;
                    if (!_controlsRotate)
                    {
                        if (!IsProp(_selectedProp))
                            _selectedProp.Position = _selectedProp.Position - new Vector3(0f, 0f, (modifier/4) + pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position - new Vector3(0f, 0f, (modifier / 4) + pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X, _selectedProp.Rotation.Y, _selectedProp.Rotation.Z + (modifier / 4)).ToQuaternion();
                        if (IsPed(_selectedProp))
                            _selectedProp.Heading = _selectedProp.Rotation.Z;
                    }
                    _changesMade++;

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                }

                if (Game.IsControlPressed(0, Control.MoveUpOnly))
                {
                    float pedMod = 0f;
                    if (IsPed(_selectedProp))
                        pedMod = -1f;
                    if (!_controlsRotate)
                    {
                        var dir = VectorExtensions.RotationToDirection(_mainCamera.Rotation)*(modifier/4);

                        if (!IsProp(_selectedProp) )
                            _selectedProp.Position = _selectedProp.Position + new Vector3(dir.X, dir.Y, pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position + new Vector3(dir.X, dir.Y, pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X + (modifier / 4), _selectedProp.Rotation.Y, _selectedProp.Rotation.Z).ToQuaternion();
                    }
                    _changesMade++;

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                }
                if (Game.IsControlPressed(0, Control.MoveDownOnly))
                {
                    float pedMod = 0f;
                    if (_selectedProp is Ped)
                        pedMod = 1f;
                    if (!_controlsRotate)
                    {
                        var dir = VectorExtensions.RotationToDirection(_mainCamera.Rotation)*(modifier/4);
                        if (!IsProp(_selectedProp) )
                            _selectedProp.Position = _selectedProp.Position - new Vector3(dir.X, dir.Y, pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position - new Vector3(dir.X, dir.Y, pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X - (modifier / 4), _selectedProp.Rotation.Y, _selectedProp.Rotation.Z).ToQuaternion();
                    }
                    _changesMade++;

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                }

                if (Game.IsControlPressed(0, Control.MoveLeftOnly))
                {
                    float pedMod = 0f;
                    if (_selectedProp is Ped)
                        pedMod = -1f;
                    if (!_controlsRotate)
                    {
                        var rotLeft = _mainCamera.Rotation + new Vector3(0, 0, -10);
                        var rotRight = _mainCamera.Rotation + new Vector3(0, 0, 10);
                        var right = (VectorExtensions.RotationToDirection(rotRight) -
                                     VectorExtensions.RotationToDirection(rotLeft))*(modifier/2);
                        if (!IsProp(_selectedProp) )
                            _selectedProp.Position = _selectedProp.Position + new Vector3(right.X, right.Y, pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position + new Vector3(right.X, right.Y, pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X, _selectedProp.Rotation.Y + (modifier / 4), _selectedProp.Rotation.Z).ToQuaternion();
                    }
                    _changesMade++;

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                }
                if (Game.IsControlPressed(0, Control.MoveRightOnly))
                {
                    float pedMod = 0f;
                    if (_selectedProp is Ped)
                        pedMod = 1f;
                    if (!_controlsRotate)
                    {
                        var rotLeft = _mainCamera.Rotation + new Vector3(0, 0, -10);
                        var rotRight = _mainCamera.Rotation + new Vector3(0, 0, 10);
                        var right = (VectorExtensions.RotationToDirection(rotRight) -
                                     VectorExtensions.RotationToDirection(rotLeft))*(modifier/2);
                        if (!IsProp(_selectedProp) )
                            _selectedProp.Position = _selectedProp.Position - new Vector3(right.X, right.Y, pedMod);
                        else
                            _selectedProp.PositionNoOffset = _selectedProp.Position - new Vector3(right.X, right.Y, pedMod);
                    }
                    else
                    {
                        _selectedProp.Quaternion = new Vector3(_selectedProp.Rotation.X, _selectedProp.Rotation.Y - (modifier / 4), _selectedProp.Rotation.Z).ToQuaternion();
                    }
                    _changesMade++;

                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }
                }

                if (Game.IsControlJustReleased(0, Control.MoveLeftOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveRightOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveUpOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveDownOnly) ||
                    Game.IsControlJustReleased(0, Control.FrontendLb) ||
                    Game.IsControlJustReleased(0, Control.FrontendRb))
                {
                    RedrawObjectInfoMenu(_selectedProp, false);
                }

                if (Game.IsControlJustReleased(0, Control.LookBehind))
                {
                    Entity mainProp = new Prop(0);
                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        var oldPickup = PropStreamer.GetPickup(_selectedProp.Handle);
                        var newPickup = PropStreamer.CreatePickup(new Model(oldPickup.PickupHash), oldPickup.Position,
                            new Prop(oldPickup.ObjectHandle).Rotation.Z, oldPickup.Amount, oldPickup.Dynamic);
                        AddItemToEntityMenu(newPickup);
                        mainProp = new Prop(newPickup.ObjectHandle);
                    }
                    else if (_selectedProp is Prop)
                    {
                        var isDoor = PropStreamer.Doors.Contains(_selectedProp.Handle);
                        AddItemToEntityMenu(mainProp = PropStreamer.CreateProp(_selectedProp.Model, _selectedProp.Position, _selectedProp.Rotation, (!PropStreamer.StaticProps.Contains(_selectedProp.Handle) && !isDoor), force: true, q: Quaternion.GetEntityQuaternion(_selectedProp), drawDistance: _settings.DrawDistance));
                        if (isDoor)
                        {
                            mainProp.FreezePosition = false;
                            PropStreamer.Doors.Add(mainProp.Handle);
                        }
                    }
                    else if (_selectedProp is Vehicle)
                        AddItemToEntityMenu(mainProp = PropStreamer.CreateVehicle(_selectedProp.Model, _selectedProp.Position, _selectedProp.Rotation.Z, !PropStreamer.StaticProps.Contains(_selectedProp.Handle), drawDistance: _settings.DrawDistance));
                    else if (_selectedProp is Ped)
                    {
                        AddItemToEntityMenu(mainProp = Function.Call<Ped>(Hash.CLONE_PED, ((Ped) _selectedProp).Handle, _selectedProp.Rotation.Z, 1, 1));
                        PropStreamer.Peds.Add(mainProp.Handle);
                        if(!PropStreamer.ActiveScenarios.ContainsKey(mainProp.Handle))
                            PropStreamer.ActiveScenarios.Add(mainProp.Handle, "None");

                        if (_settings.DrawDistance != -1)
                            mainProp.LodDistance = _settings.DrawDistance;

                        if (PropStreamer.ActiveRelationships.ContainsKey(_selectedProp.Handle))
                            PropStreamer.ActiveRelationships.Add(mainProp.Handle, PropStreamer.ActiveRelationships[_selectedProp.Handle]);
                        else if (!PropStreamer.ActiveRelationships.ContainsKey(mainProp.Handle))
                            PropStreamer.ActiveRelationships.Add(mainProp.Handle, DefaultRelationship.ToString());

                        if(PropStreamer.ActiveWeapons.ContainsKey(_selectedProp.Handle))
                            PropStreamer.ActiveWeapons.Add(mainProp.Handle, PropStreamer.ActiveWeapons[_selectedProp.Handle]);
                        else if(!PropStreamer.ActiveRelationships.ContainsKey(mainProp.Handle))
                            PropStreamer.ActiveWeapons.Add(mainProp.Handle, WeaponHash.Unarmed);
                    }

                    _changesMade++;
                    _selectedProp = mainProp;
                    if(_settings.SnapCameraToSelectedObject)
                        _mainCamera.PointAt(_selectedProp);
                    if(_selectedProp != null) RedrawObjectInfoMenu(_selectedProp, true);
                }

                if (Game.IsControlJustPressed(0, Control.CreatorDelete))
                {
                    if (PropStreamer.Identifications.ContainsKey(_selectedProp.Handle))
                        PropStreamer.Identifications.Remove(_selectedProp.Handle);
                    if (PropStreamer.ActiveScenarios.ContainsKey(_selectedProp.Handle))
                        PropStreamer.ActiveScenarios.Remove(_selectedProp.Handle);
                    if (PropStreamer.ActiveRelationships.ContainsKey(_selectedProp.Handle))
                        PropStreamer.ActiveRelationships.Remove(_selectedProp.Handle);
                    if (PropStreamer.ActiveWeapons.ContainsKey(_selectedProp.Handle))
                        PropStreamer.ActiveWeapons.Remove(_selectedProp.Handle);
                    RemoveItemFromEntityMenu(_selectedProp);
                    PropStreamer.RemoveEntity(_selectedProp.Handle);
                    _selectedProp = null;
                    _objectInfoMenu.Visible = false;
                    _mainCamera.StopPointing();
                    _changesMade++;
                }

                if (Game.IsControlJustPressed(0, Control.PhoneCancel) || Game.IsControlJustPressed(0, Control.Attack))
                {
                    if (PropStreamer.IsPickup(_selectedProp.Handle))
                    {
                        PropStreamer.GetPickup(_selectedProp.Handle).UpdatePos();
                    }

                    _selectedProp = null;
                    _objectInfoMenu.Visible = false;
                    _mainCamera.StopPointing();
                    _changesMade++;
                }
                InstructionalButtonsStart();
                InstructionalButtonsSelected();
                InstructionalButtonsEnd();
            }
            else if (_selectedMarker != null) // marker isn't null
            {
                if (Game.IsControlJustReleased(0, Control.Duck))
                {
                    _controlsRotate = !_controlsRotate;
                }
                if (Game.IsControlPressed(0, Control.FrontendRb))
                {
                    if (!_controlsRotate)
                        _selectedMarker.Position += new Vector3(0f, 0f, (modifier / 4));
                    else
                        _selectedMarker.Rotation += new Vector3(0f, 0f, modifier);
                    _changesMade++;
                }
                if (Game.IsControlPressed(0, Control.FrontendLb))
                {
                    if (!_controlsRotate)
                        _selectedMarker.Position -= new Vector3(0f, 0f, (modifier / 4));
                    else
                        _selectedMarker.Rotation -= new Vector3(0f, 0f, modifier);
                    _changesMade++;
                }

                if (Game.IsControlPressed(0, Control.MoveUpOnly))
                {
                    if (!_controlsRotate)
                    {
                        var dir = VectorExtensions.RotationToDirection(_mainCamera.Rotation) * (modifier / 4);
                        _selectedMarker.Position += new Vector3(dir.X, dir.Y, 0f);
                    }
                    else
                        _selectedMarker.Rotation += new Vector3(modifier, 0f, 0f);
                    _changesMade++;
                }
                if (Game.IsControlPressed(0, Control.MoveDownOnly))
                {
                    if (!_controlsRotate)
                    {
                        var dir = VectorExtensions.RotationToDirection(_mainCamera.Rotation) * (modifier / 4);
                        _selectedMarker.Position -= new Vector3(dir.X, dir.Y, 0f);
                    }
                    else
                        _selectedMarker.Rotation -= new Vector3(modifier, 0f, 0f);
                    _changesMade++;
                }

                if (Game.IsControlPressed(0, Control.MoveLeftOnly))
                {
                    if (!_controlsRotate)
                    {
                        var rotLeft = _mainCamera.Rotation + new Vector3(0, 0, -10);
                        var rotRight = _mainCamera.Rotation + new Vector3(0, 0, 10);
                        var right = (VectorExtensions.RotationToDirection(rotRight) - VectorExtensions.RotationToDirection(rotLeft)) * (modifier / 2);
                        _selectedMarker.Position += new Vector3(right.X, right.Y, 0f);
                    }
                    else
                        _selectedMarker.Rotation += new Vector3(0f, modifier, 0f);
                    _changesMade++;
                }
                if (Game.IsControlPressed(0, Control.MoveRightOnly))
                {
                    if (!_controlsRotate)
                    {
                        var rotLeft = _mainCamera.Rotation + new Vector3(0, 0, -10);
                        var rotRight = _mainCamera.Rotation + new Vector3(0, 0, 10);
                        var right = (VectorExtensions.RotationToDirection(rotRight) - VectorExtensions.RotationToDirection(rotLeft)) * (modifier / 2);
                        _selectedMarker.Position -= new Vector3(right.X, right.Y, 0f);
                    }
                    else
                        _selectedMarker.Rotation -= new Vector3(0f, modifier, 0f);
                    _changesMade++;
                }

                if (Game.IsControlJustReleased(0, Control.MoveLeftOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveRightOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveUpOnly) ||
                    Game.IsControlJustReleased(0, Control.MoveDownOnly) ||
                    Game.IsControlJustReleased(0, Control.FrontendLb) ||
                    Game.IsControlJustReleased(0, Control.FrontendRb))
                {
                    RedrawObjectInfoMenu(_selectedMarker, false);
                }

                if (Game.IsControlJustReleased(0, Control.LookBehind))
                {
                    var tmpMark = new Marker()
                    {
                        BobUpAndDown = _selectedMarker.BobUpAndDown,
                        Red = _selectedMarker.Red,
                        Green = _selectedMarker.Green,
                        Blue = _selectedMarker.Blue,
                        Alpha =  _selectedMarker.Alpha,
                        Position = _selectedMarker.Position,
                        RotateToCamera = _selectedMarker.RotateToCamera,
                        Rotation = _selectedMarker.Rotation,
                        Scale = _selectedMarker.Scale,
                        Type = _selectedMarker.Type,
                        Id = _markerCounter,
                    };
                    _markerCounter++;
                    PropStreamer.Markers.Add(tmpMark);
                    AddItemToEntityMenu(tmpMark);
                    _selectedMarker = tmpMark;
                    RedrawObjectInfoMenu(_selectedMarker, true);
                    _changesMade++;
                }

                if (Game.IsControlJustPressed(0, Control.CreatorDelete))
                {
                    PropStreamer.Markers.Remove(_selectedMarker);
                    RemoveMarkerFromEntityMenu(_selectedMarker.Id);
                    _selectedMarker = null;
                    _objectInfoMenu.Visible = false;
                    _mainCamera.StopPointing();
                    _changesMade++;
                }

                if (Game.IsControlJustPressed(0, Control.PhoneCancel) || Game.IsControlJustPressed(0, Control.Attack))
                {
                    _selectedMarker = null;
                    _objectInfoMenu.Visible = false;
                    _mainCamera.StopPointing();
                    _changesMade++;
                }
                InstructionalButtonsStart();
                InstructionalButtonsSelected();
                InstructionalButtonsEnd();
            }
        }
Beispiel #2
0
        public void OnEntityTeleport(UIMenu menu, UIMenuItem item, int index)
        {
            if (!IsInFreecam) return;
            if (item.Text.StartsWith("~h~[PICKUP]~h~"))
            {
                var uid = int.Parse(item.Description.Substring(7));
                var pickup = PropStreamer.GetPickupByUID(uid);
                if (_settings.SnapCameraToSelectedObject)
                {
                    _mainCamera.Position = pickup.RealPosition + new Vector3(5f, 5f, 10f);
                    _mainCamera.PointAt(pickup.RealPosition);
                }
                _menuPool.CloseAllMenus();
                Script.Wait(300);
                _selectedProp = new Prop(pickup.ObjectHandle);
                RedrawObjectInfoMenu(_selectedProp, true);
                _objectInfoMenu.Visible = true;
                return;
            }

            if (item.Text.StartsWith("~h~[WORLD]~h~ "))
            {
                var mapObj = PropStreamer.RemovedObjects.FirstOrDefault(obj => obj.Id == item.Description);
                if(mapObj == null) return;
                var t = World.CreateProp(mapObj.Hash, mapObj.Position, mapObj.Rotation, true, false);
                t.PositionNoOffset = mapObj.Position;
                _menuPool.CloseAllMenus();
                RemoveItemFromEntityMenu(mapObj.Id);
                PropStreamer.RemovedObjects.Remove(mapObj);
                return;
            }
            if (item.Text.StartsWith("~h~[MARK]~h~ "))
            {
                Marker tmpM = PropStreamer.Markers.FirstOrDefault(m => item.Description == "marker-" + m.Id);
                if(tmpM == null) return;
                _mainCamera.Position = tmpM.Position + new Vector3(5f, 5f, 10f);
                if(_settings.SnapCameraToSelectedObject)
                    _mainCamera.PointAt(tmpM.Position);
                _menuPool.CloseAllMenus();
                _selectedMarker = tmpM;
                RedrawObjectInfoMenu(_selectedMarker, true);
                _objectInfoMenu.Visible = true;
                return;
            }
            var prop = new Prop(int.Parse(item.Description, CultureInfo.InvariantCulture));
            if(!prop.Exists()) return;
            if (_settings.SnapCameraToSelectedObject)
            {
                _mainCamera.Position = prop.Position + new Vector3(5f, 5f, 10f);
                _mainCamera.PointAt(prop);
            }
            _menuPool.CloseAllMenus();
            _selectedProp = prop;
            RedrawObjectInfoMenu(_selectedProp, true);
            _objectInfoMenu.Visible = true;
        }
Beispiel #3
0
 public void AddItemToEntityMenu(Marker mark)
 {
     if (mark == null) return;
     var name = mark.Type.ToString();
     _currentObjectsMenu.AddItem(new UIMenuItem("~h~[MARK]~h~ " + name, "marker-" + mark.Id));
     _currentObjectsMenu.RefreshIndex();
 }
Beispiel #4
0
        private void RedrawObjectInfoMenu(Marker ent, bool refreshIndex)
        {
            if (ent == null) return;
            string name = ent.Type.ToString() + " #" + ent.Id;

            _objectInfoMenu.Subtitle.Caption = "~b~" + name;
            _objectInfoMenu.Clear();

            List<dynamic> possbileScale = new List<dynamic>();
            for (int i = 0; i <= 1000; i++)
            {
                possbileScale.Add(i * 0.01);
            }

            List<dynamic> possibleColors = new List<dynamic>();
            for (int i = 0; i <= 255; i++)
            {
                possibleColors.Add(i);
            }

            var posXitem = new UIMenuListItem(Translation.Translate("Position X"), _possiblePositions, (int)(Math.Round((ent.Position.X * 100) + _possibleRange)));
            var posYitem = new UIMenuListItem(Translation.Translate("Position Y"), _possiblePositions, (int)(Math.Round((ent.Position.Y * 100) + _possibleRange)));
            var posZitem = new UIMenuListItem(Translation.Translate("Position Z"), _possiblePositions, (int)(Math.Round((ent.Position.Z * 100) + _possibleRange)));

            var rotXitem = new UIMenuListItem(Translation.Translate("Rotation X"), _possiblePositions, (int)(Math.Round((ent.Rotation.X * 100) + _possibleRange)));
            var rotYitem = new UIMenuListItem(Translation.Translate("Rotation Y"), _possiblePositions, (int)(Math.Round((ent.Rotation.Y * 100) + _possibleRange)));
            var rotZitem = new UIMenuListItem(Translation.Translate("Rotation Z"), _possiblePositions, (int)(Math.Round((ent.Rotation.Z * 100) + _possibleRange)));

            var dynamic = new UIMenuCheckboxItem(Translation.Translate("Bop Up And Down"), ent.BobUpAndDown);
            dynamic.CheckboxEvent += (ite, checkd) =>
            {
                ent.BobUpAndDown = checkd;
            };

            var faceCam = new UIMenuCheckboxItem(Translation.Translate("Face Camera"), ent.RotateToCamera);
            dynamic.CheckboxEvent += (ite, checkd) =>
            {
                ent.RotateToCamera = checkd;
            };

            var type = new UIMenuListItem(Translation.Translate("Type"), new List<dynamic>(_markersTypes), _markersTypes.ToList().IndexOf(ent.Type.ToString()));
            type.OnListChanged += (ite, index) =>
            {
                MarkerType hash;
                Enum.TryParse(ite.IndexToItem(index), out hash);
                ent.Type = hash;
            };

            var scaleXitem = new UIMenuListItem(Translation.Translate("Scale X"), possbileScale, (int)(Math.Round((ent.Scale.X * 100))));
            var scaleYitem = new UIMenuListItem(Translation.Translate("Scale Y"), possbileScale, (int)(Math.Round((ent.Scale.Y * 100))));
            var scaleZitem = new UIMenuListItem(Translation.Translate("Scale Z"), possbileScale, (int)(Math.Round((ent.Scale.Z * 100))));

            var colorR = new UIMenuListItem(Translation.Translate("Red Color"), possibleColors, ent.Red);
            var colorG = new UIMenuListItem(Translation.Translate("Green Color"), possibleColors, ent.Green);
            var colorB = new UIMenuListItem(Translation.Translate("Blue Color"), possibleColors, ent.Blue);
            var colorA = new UIMenuListItem(Translation.Translate("Transparency"), possibleColors, ent.Alpha);

            var targetId = 0;

            if (ent.TeleportTarget.HasValue)
            {
                var ourMarkers =
                    PropStreamer.Markers.Where(m => (m.Position - ent.TeleportTarget.Value).Length() < 1f)
                        .OrderBy(m => (m.Position - ent.TeleportTarget.Value).Length());
                if (ourMarkers.Any())
                    targetId = ourMarkers.First().Id + 1;
            }

            var targetPos = new UIMenuListItem(Translation.Translate("Teleport Marker Target"),
                Enumerable.Range(-1, _markerCounter + 1).Select(n => (dynamic) n).ToList(), targetId);
            targetPos.OnListChanged += (sender, index) =>
            {
                if (index == 0)
                {
                    ent.TeleportTarget = null;
                    return;
                }

                ent.TeleportTarget = PropStreamer.Markers.FirstOrDefault(n => n.Id == index-1)?.Position;
            };

            var loadPointItem = new UIMenuCheckboxItem(Translation.Translate("Mark as Loading Point"),
                PropStreamer.CurrentMapMetadata.LoadingPoint.HasValue &&
                (PropStreamer.CurrentMapMetadata.LoadingPoint.Value - ent.Position).Length() < 1f, Translation.Translate("Player will be teleported here BEFORE starting to load the map."));
            loadPointItem.CheckboxEvent += (sender, @checked) =>
            {
                if (@checked)
                {
                    PropStreamer.CurrentMapMetadata.LoadingPoint = ent.Position;
                }
                else
                {
                    PropStreamer.CurrentMapMetadata.LoadingPoint = null;
                }
            };

            var loadTeleportItem = new UIMenuCheckboxItem(Translation.Translate("Mark as Starting Point"),
                PropStreamer.CurrentMapMetadata.TeleportPoint.HasValue &&
                (PropStreamer.CurrentMapMetadata.TeleportPoint.Value - ent.Position).Length() < 1f, Translation.Translate("Player will be teleported here AFTER starting to load the map."));
            loadTeleportItem.CheckboxEvent += (sender, @checked) =>
            {
                if (@checked)
                {
                    PropStreamer.CurrentMapMetadata.TeleportPoint = ent.Position;
                }
                else
                {
                    PropStreamer.CurrentMapMetadata.TeleportPoint = null;
                }
            };

            var visiblityItem = new UIMenuCheckboxItem(Translation.Translate("Only Visible In Editor"), ent.OnlyVisibleInEditor);
            visiblityItem.CheckboxEvent += (sender, @checked) =>
            {
                ent.OnlyVisibleInEditor = @checked;
            };

            _objectInfoMenu.AddItem(type);
            _objectInfoMenu.AddItem(posXitem);
            _objectInfoMenu.AddItem(posYitem);
            _objectInfoMenu.AddItem(posZitem);
            _objectInfoMenu.AddItem(rotXitem);
            _objectInfoMenu.AddItem(rotYitem);
            _objectInfoMenu.AddItem(rotZitem);
            _objectInfoMenu.AddItem(scaleXitem);
            _objectInfoMenu.AddItem(scaleYitem);
            _objectInfoMenu.AddItem(scaleZitem);
            _objectInfoMenu.AddItem(colorR);
            _objectInfoMenu.AddItem(colorG);
            _objectInfoMenu.AddItem(colorB);
            _objectInfoMenu.AddItem(colorA);
            _objectInfoMenu.AddItem(dynamic);
            _objectInfoMenu.AddItem(faceCam);
            _objectInfoMenu.AddItem(targetPos);
            _objectInfoMenu.AddItem(loadPointItem);
            _objectInfoMenu.AddItem(loadTeleportItem);
            _objectInfoMenu.AddItem(visiblityItem);

            posXitem.OnListChanged += (item, index) => ent.Position = new Vector3((float)item.IndexToItem(index), ent.Position.Y, ent.Position.Z);
            posYitem.OnListChanged += (item, index) => ent.Position = new Vector3(ent.Position.X, (float)item.IndexToItem(index), ent.Position.Z);
            posZitem.OnListChanged += (item, index) => ent.Position = new Vector3(ent.Position.X, ent.Position.Y, (float)item.IndexToItem(index));

            posXitem.Activated +=
                (sender, item) =>
                    SetMarkerVector(ent, GetSafeFloat(Game.GetUserInput(ent.Position.X.ToString(CultureInfo.InvariantCulture), 10), ent.Position.X), ent.Position.Y, ent.Position.Z);
            posYitem.Activated +=
                (sender, item) =>
                    SetMarkerVector(ent, ent.Position.X, GetSafeFloat(Game.GetUserInput(ent.Position.Y.ToString(CultureInfo.InvariantCulture), 10), ent.Position.Y), ent.Position.Z);
            posZitem.Activated +=
                (sender, item) =>
                    SetMarkerVector(ent, ent.Position.X, ent.Position.Y, GetSafeFloat(Game.GetUserInput(ent.Position.Z.ToString(CultureInfo.InvariantCulture), 10), ent.Position.Z));

            rotXitem.OnListChanged += (item, index) => ent.Rotation = new Vector3((float)item.IndexToItem(index), ent.Rotation.Y, ent.Rotation.Z);
            rotYitem.OnListChanged += (item, index) => ent.Rotation = new Vector3(ent.Rotation.X, (float)item.IndexToItem(index), ent.Rotation.Z);
            rotZitem.OnListChanged += (item, index) => ent.Rotation = new Vector3(ent.Rotation.X, ent.Rotation.Y, (float)item.IndexToItem(index));

            rotXitem.Activated +=
                (sender, item) =>
                    SetMarkerRotation(ent, GetSafeFloat(Game.GetUserInput(ent.Rotation.X.ToString(CultureInfo.InvariantCulture), 10), ent.Rotation.X), ent.Rotation.Y, ent.Rotation.Z);
            rotYitem.Activated +=
                (sender, item) =>
                    SetMarkerRotation(ent, ent.Rotation.X, GetSafeFloat(Game.GetUserInput(ent.Rotation.Y.ToString(CultureInfo.InvariantCulture), 10), ent.Rotation.Y), ent.Rotation.Z);
            rotZitem.Activated +=
                (sender, item) =>
                    SetMarkerRotation(ent, ent.Rotation.X, ent.Rotation.Y, GetSafeFloat(Game.GetUserInput(ent.Rotation.Z.ToString(CultureInfo.InvariantCulture), 10), ent.Rotation.Z));

            scaleXitem.OnListChanged += (item, index) => ent.Scale = new Vector3((float)item.IndexToItem(index), ent.Scale.Y, ent.Scale.Z);
            scaleYitem.OnListChanged += (item, index) => ent.Scale = new Vector3(ent.Scale.X, (float)item.IndexToItem(index), ent.Scale.Z);
            scaleZitem.OnListChanged += (item, index) => ent.Scale = new Vector3(ent.Scale.X, ent.Scale.Y, (float)item.IndexToItem(index));

            scaleXitem.Activated +=
                (sender, item) =>
                    SetMarkerScale(ent, GetSafeFloat(Game.GetUserInput(ent.Scale.X.ToString(CultureInfo.InvariantCulture), 10), ent.Scale.X), ent.Scale.Y, ent.Scale.Z);
            scaleYitem.Activated +=
                (sender, item) =>
                    SetMarkerScale(ent, ent.Scale.X, GetSafeFloat(Game.GetUserInput(ent.Scale.Y.ToString(CultureInfo.InvariantCulture), 10), ent.Scale.Y), ent.Scale.Z);
            scaleZitem.Activated +=
                (sender, item) =>
                    SetMarkerScale(ent, ent.Scale.X, ent.Scale.Y, GetSafeFloat(Game.GetUserInput(ent.Scale.Z.ToString(CultureInfo.InvariantCulture), 10), ent.Scale.Z));

            colorR.OnListChanged += (item, index) => ent.Red = index;
            colorG.OnListChanged += (item, index) => ent.Green = index;
            colorB.OnListChanged += (item, index) => ent.Blue = index;
            colorA.OnListChanged += (item, index) => ent.Alpha = index;

            if (refreshIndex)
                _objectInfoMenu.RefreshIndex();
        }
Beispiel #5
0
 public void SetMarkerVector(Marker ent, float x, float y, float z)
 {
     ent.Position = new Vector3(x, y, z);
     RedrawObjectInfoMenu(ent, false);
 }
Beispiel #6
0
 public void SetMarkerScale(Marker ent, float x, float y, float z)
 {
     ent.Scale = new Vector3(x, y, z);
     RedrawObjectInfoMenu(ent, false);
 }