Beispiel #1
0
        private void CheckForPickup(Vector3 pos, bool entNull)
        {
            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && (PlacedWeaponHash != 0 || ObjectiveMarkerId.HasValue))
            {
                var threshold = 1.5f;
                if (!IsPlacingObjective && !ObjectiveMarkerId.HasValue)
                foreach (SerializablePickup pickup in CurrentMission.Pickups)
                {
                    if(pickup.GetEntity() == null || !pickup.GetEntity().IsValid()) continue;
                    if ((pickup.GetEntity().Position - pos).Length() > threshold) continue;
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = pickup.GetEntity();
                    return;
                }
                if(IsPlacingObjective && !ObjectiveMarkerId.HasValue)
                foreach (SerializablePickupObjective pickup in CurrentMission.Objectives.Where(obj => obj is SerializablePickupObjective))
                {
                    if (pickup.GetObject() == null || !pickup.GetObject().IsValid()) continue;
                    if ((pickup.GetObject().Position - pos).Length() > threshold) continue;
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _hoveringEntity = pickup.GetObject();
                    return;
                }

                
                if (IsPlacingObjective && ObjectiveMarkerId.HasValue)
                    foreach (var mark in CurrentMission.Objectives.OfType<SerializableMarker>())
                {
                    
                    if ((mark.Position - pos).Length() > threshold) continue;
                    MarkerData.RepresentedBy.Opacity = 0f;
                    MarkerData.HeadingOffset = 45f;
                    RingData.Color = Color.Red;
                    _selectedMarker = mark;
                    return;
                }


                MarkerData.RepresentedBy.Opacity = 1f;
                MarkerData.HeadingOffset = 0f;
                RingData.Color = Color.MediumPurple;
                _hoveringEntity = null;
                _selectedMarker = null;
            }
            else if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() && entNull)
            {
                MarkerData.RepresentedBy.Opacity = 1f;
                MarkerData.HeadingOffset = 0f;
                RingData.Color = Color.MediumPurple;
                _hoveringEntity = null;
                _selectedMarker = null;
            }
        }
Beispiel #2
0
        public void Tick(GraphicsEventArgs canvas)
        {
            if (menuDirty)
            {
                RebuildMissionMenu(CurrentMission);
                _propertiesMenu = null;
                menuDirty = false;
            }
            else
            {
                CheckMenusForAlerts();
                _cutsceneUi.Process();
                _menuPool.ProcessMenus();
                Children.ForEach(x => x.Process());

                if (_propertiesMenu != null)
                {
                    _propertiesMenu.Process();
                    ((UIMenu)_propertiesMenu).ProcessControl();
                    ((UIMenu)_propertiesMenu).ProcessMouse();
                    ((UIMenu)_propertiesMenu).Draw();
                }
            }
            if (IsInMainMenu)
            {
                NativeFunction.CallByName<uint>("HIDE_HUD_AND_RADAR_THIS_FRAME");
            }

            if (!IsInEditor) return;
            NativeFunction.CallByName<uint>("DISABLE_CONTROL_ACTION", 0, (int)GameControl.FrontendPauseAlternate);

            foreach (var objective in CurrentMission.Objectives)
            {
                //TODO: Get model size
                if (objective is SerializableActorObjective)
                {
                    var ped = ((SerializableActorObjective) objective).GetPed();
                    if (ped == null) continue;
                    Util.DrawMarker(0, ped.Position + new Vector3(0, 0, 2f),
                        new Vector3(ped.Rotation.Pitch, ped.Rotation.Roll, ped.Rotation.Yaw),
                        new Vector3(1f, 1f, 1f), Color.FromArgb(100, 255, 10, 10) );
                }
                else if (objective is SerializableVehicleObjective)
                {
                    var ped = ((SerializableVehicleObjective)objective).GetVehicle();
                    if (ped == null) continue;
                    Util.DrawMarker(0, ped.Position + new Vector3(0, 0, 2f),
                        new Vector3(ped.Rotation.Pitch, ped.Rotation.Roll, ped.Rotation.Yaw),
                        new Vector3(1f, 1f, 1f), Color.FromArgb(100, 255, 10, 10));
                }
                
                else if (objective is SerializablePickupObjective)
                {
                    var pickup = ((SerializablePickupObjective) objective).GetObject();
                    if (pickup == null) continue;
                    Util.DrawMarker(1, pickup.Position - new Vector3(0, 0, 1f),
                    new Vector3(pickup.Rotation.Pitch, pickup.Rotation.Roll, pickup.Rotation.Yaw),
                    new Vector3(1f, 1f, 1f), Color.FromArgb(100, 255, 10, 10));
                }

                else if (objective is SerializableMarker)
                {
                    var obj = ((SerializableMarker) objective);
                    Util.DrawMarker(obj.Type, obj.Position, new Vector3(), obj.Scale,
                        Color.FromArgb(obj.Alpha, (int)obj.Color.X, (int)obj.Color.Y, (int)obj.Color.Z));
                }
            }

            foreach (var pickup in CurrentMission.Pickups)
            {
                if(pickup.GetEntity() == null) continue;
                Util.DrawMarker(1, pickup.GetEntity().Position - new Vector3(0,0,1f),
                    new Vector3(pickup.GetEntity().Rotation.Pitch, pickup.GetEntity().Rotation.Roll, pickup.GetEntity().Rotation.Yaw),
                    new Vector3(1f, 1f, 1f), Color.FromArgb(100, 10, 100, 255));
            }

            if (IsInFreecam)
            {
                var markerPos = Util.RaycastEverything(new Vector2(0, 0), MainCamera, MarkerData.RepresentedBy ?? _mainObject);
                #region Camera Movement

                if (!DisableControlEnabling)
                {
                    NativeFunction.CallByName<uint>("DISABLE_ALL_CONTROL_ACTIONS", 0);
                    EnableControls();
                }

                if (EnableBasicMenuControls)
                {
                    EnableMenuControls();
                }
                MainCamera.Active = true;

                var mouseX = NativeFunction.CallByName<float>("GET_CONTROL_NORMAL", 0, (int) GameControl.LookLeftRight);
                var mouseY = NativeFunction.CallByName<float>("GET_CONTROL_NORMAL", 0, (int) GameControl.LookUpDown);

                mouseX *= -1; //Invert
                mouseY *= -1;


                float movMod = 0.1f;
                float entMod = 1;

                if (Util.IsDisabledControlPressed(GameControl.Sprint))
                {
                    movMod = 0.5f;
                    entMod = 0.5f;
                }
                else if (Util.IsDisabledControlPressed(GameControl.CharacterWheel))
                {
                    movMod = 0.02f;
                    entMod = 0.02f;
                }

                bool zoomIn = false;
                bool zoomOut = false;

                if (Util.IsGamepadEnabled)
                {
                    mouseX *= 2; //TODO: settings
                    mouseY *= 2;

                    movMod *= 5f;

                    zoomIn = Game.IsControlPressed(0, GameControl.CreatorRT);
                    zoomOut = Game.IsControlPressed(0, GameControl.CreatorLT);
                }
                else
                {
                    mouseX *= 20;
                    mouseY *= 20;

                    movMod *= 10f;

                    zoomIn = Game.IsControlPressed(0, GameControl.CursorScrollUp);
                    zoomOut = Game.IsControlPressed(0, GameControl.CursorScrollDown);
                }

                
                MainCamera.Rotation = new Rotator((MainCamera.Rotation.Pitch + mouseY).Clamp(CameraClampMin, CameraClampMax), 0f,
                    MainCamera.Rotation.Yaw + mouseX); 

                var dir = Util.RotationToDirection(new Vector3(MainCamera.Rotation.Pitch, MainCamera.Rotation.Roll,
                        MainCamera.Rotation.Yaw));
                var rotLeft = new Vector3(MainCamera.Rotation.Pitch, MainCamera.Rotation.Roll,
                    MainCamera.Rotation.Yaw - 10f);
                var rotRight = new Vector3(MainCamera.Rotation.Pitch, MainCamera.Rotation.Roll,
                    MainCamera.Rotation.Yaw + 10f);
                var right = Util.RotationToDirection(rotRight) - Util.RotationToDirection(rotLeft);

                Vector3 movementVector = new Vector3();

                if (zoomIn)
                {
                    var directionalVector = dir*movMod;
                    movementVector += directionalVector;
                }
                if (zoomOut)
                {
                    var directionalVector = dir*movMod;
                    movementVector -= directionalVector;
                }

                if (Game.IsControlPressed(0, GameControl.MoveUpOnly))
                {
                    var directionalVector = dir*movMod;
                    movementVector += new Vector3(directionalVector.X, directionalVector.Y, 0f);
                }
                if (Game.IsControlPressed(0, GameControl.MoveDownOnly))
                {
                    var directionalVector = dir*movMod;
                    movementVector -= new Vector3(directionalVector.X, directionalVector.Y, 0f);
                }
                if (Game.IsControlPressed(0, GameControl.MoveLeftOnly))
                {
                    movementVector += right*movMod;
                }
                if (Game.IsControlPressed(0, GameControl.MoveRightOnly))
                {
                    movementVector -= right*movMod;
                }
                MainCamera.Position += movementVector;
                Game.LocalPlayer.Character.Position = MainCamera.Position;

                var head = MainCamera.Rotation.Yaw;
                if (head < 0f)
                    head += 360f;
                Game.LocalPlayer.Character.Heading = head;

                #endregion
                
                var ent = Util.RaycastEntity(new Vector2(0, 0),
                    MainCamera.Position,
                    new Vector3(MainCamera.Rotation.Pitch, MainCamera.Rotation.Roll, MainCamera.Rotation.Yaw)
                    , null);

                if (!_isCopying)
                {
                    if (MarkerData.RepresentedBy == null || !MarkerData.RepresentedBy.IsValid())
                    {
                        CheckForProperty(ent);
                        CheckForPickupProperty(markerPos, ent == null);
                    }
                    else
                    {
                        CheckForIntersection(ent);
                        CheckForPickup(markerPos, ent == null);
                    }
                }
                WaypointEditor?.Process(markerPos, ent);
                CopyWatch(ent, markerPos);
                DisplayMarker(markerPos, dir);
            }
            else
            {
                var gameplayCoord = NativeFunction.CallByName<Vector3>("GET_GAMEPLAY_CAM_COORD");
                var gameplayRot = NativeFunction.CallByName<Vector3>("GET_GAMEPLAY_CAM_ROT", 2);
                var markerPos = Util.RaycastEverything(new Vector2(0, 0), gameplayCoord, gameplayRot, Game.LocalPlayer.Character);

                #region Controls
                Game.DisableControlAction(0, GameControl.Phone, true);
                if (!DisableControlEnabling)
                {
                    EnableControls();
                }
                if (EnableBasicMenuControls)
                {
                    EnableMenuControls();
                }

                #endregion

                var ent = Util.RaycastEntity(new Vector2(0, 0),
                    gameplayCoord,
                    gameplayRot, Game.LocalPlayer.Character);

                if (!_isCopying)
                {
                    if (MarkerData.RepresentedBy == null || !MarkerData.RepresentedBy.IsValid())
                    {
                        CheckForProperty(ent);
                        CheckForPickupProperty(markerPos, ent == null);
                    }
                    else
                    {
                        CheckForIntersection(ent);
                        CheckForPickup(markerPos, ent == null);
                    }
                }
                WaypointEditor?.Process(markerPos, ent);
                CopyWatch(ent, markerPos);
                DisplayMarker(markerPos, markerPos - NativeFunction.CallByName<Vector3>("GET_GAMEPLAY_CAM_COORD"));


                if (!_menuPool.IsAnyMenuOpen())
                {
                    Game.DisplayHelp("Press ~INPUT_PHONE~ to open menu.");
                    if (Util.IsDisabledControlJustPressed(GameControl.Phone))
                    {
                        _mainMenu.Visible = true;
                    }
                }
            }

            

            NativeFunction.CallByHash<uint>(0x231C8F89D0539D8F, BigMinimap, false);
            if(Util.IsGamepadEnabled)
                Game.SetRadarZoomLevelThisFrame(Game.IsControlPressed(0, GameControl.Duck) ? 300 : 100);
            else
                Game.SetRadarZoomLevelThisFrame(Game.IsControlPressed(0, GameControl.HUDSpecial) ? 300 : 100);

            if (Game.IsControlJustPressed(0, GameControl.FrontendPause) && IsInFreecam)
            {
                GameFiber.StartNew(delegate
                {
                    Game.FadeScreenOut(800, true);
                    Game.LocalPlayer.Character.Position -= new Vector3(0, 0, Game.LocalPlayer.Character.HeightAboveGround - 1f);
                    IsInFreecam = false;
                    MainCamera.Active = false;
                    Game.LocalPlayer.Character.Opacity = 1f;
                    _missionMenu.SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0);
                    _mainMenu.SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0);
                    Game.FadeScreenIn(800);
                });
            }
            else if (Game.IsControlJustPressed(0, GameControl.FrontendPause) && !IsInFreecam)
            {
                GameFiber.StartNew(delegate
                {
                    Game.FadeScreenOut(800, true);
                    IsInFreecam = true;
                    MainCamera.Active = true;
                    Game.LocalPlayer.Character.Opacity = 0f;
                    _missionMenu.ResetKey(Common.MenuControls.Back);
                    _mainMenu.ResetKey(Common.MenuControls.Back);
                    _menuPool.CloseAllMenus();
                    Children.ForEach(x => x.Children.ForEach(n => n.Visible = false));
                    _missionMenu.Visible = true;
                    Game.FadeScreenIn(800);
                });
            }
            #region Marker Spawning/Deletion

            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() &&
                (_hoveringEntity == null || !_hoveringEntity.IsValid()) &&
                Game.IsControlPressed(0, GameControl.FrontendLb))
            {
                MarkerData.RepresentedBy.Rotation = new Rotator(MarkerData.RepresentedBy.Rotation.Pitch,
                                                                MarkerData.RepresentedBy.Rotation.Roll,
                                                                MarkerData.RepresentedBy.Rotation.Yaw + 3f);
                RingData.Heading += 3f;
            }

            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() &&
                (_hoveringEntity == null || !_hoveringEntity.IsValid()) &&
                Game.IsControlPressed(0, GameControl.FrontendRb))
            {
                MarkerData.RepresentedBy.Rotation = new Rotator(MarkerData.RepresentedBy.Rotation.Pitch,
                                                                MarkerData.RepresentedBy.Rotation.Roll,
                                                                MarkerData.RepresentedBy.Rotation.Yaw - 3f);
                RingData.Heading -= 3f;
            }

            if (_cutsceneUi.IsInCutsceneEditor)
            {
                _cutsceneUi.Tick();
                return;
            }

            if (WaypointEditor != null && WaypointEditor.IsInEditor)
                return;

            if (_isCopying && MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
            {
                if (Game.IsControlJustPressed(0, GameControl.Attack))
                {
                    MarkerData.RepresentedBy = null;
                    _isCopying = false;
                }
                return;
            }

            if (_isCopying && _attachedMarker != null)
            {
                if (Game.IsControlJustPressed(0, GameControl.Attack))
                {
                    _attachedMarker = null;
                    _isCopying = false;
                }
                return;
            }

            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() &&
                Game.IsControlJustPressed(0, GameControl.CellphoneSelect) &&
                (_hoveringEntity == null || !_hoveringEntity.IsValid()))
            {
                if (MarkerData.RepresentedBy is Vehicle && !IsPlacingObjective)
                {
                    CreateVehicle(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position,
                                    MarkerData.RepresentedBy.Rotation,
                                    ((Vehicle)MarkerData.RepresentedBy).PrimaryColor,
                                    ((Vehicle)MarkerData.RepresentedBy).SecondaryColor);
                }

                else if (MarkerData.RepresentedBy is Vehicle && IsPlacingObjective)
                {
                    CreateVehicleObjective(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position,
                                    MarkerData.RepresentedBy.Rotation,
                                    ((Vehicle)MarkerData.RepresentedBy).PrimaryColor,
                                    ((Vehicle)MarkerData.RepresentedBy).SecondaryColor);
                }

                else if (MarkerData.RepresentedBy is Ped && !PlayerSpawnOpen && !IsPlacingObjective)
                {
                    CreatePed(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position - new Vector3(0, 0, 1f), MarkerData.RepresentedBy.Heading);
                }

                else if (MarkerData.RepresentedBy is Ped && PlayerSpawnOpen && !IsPlacingObjective)
                {
                    CreateSpawnpoint(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position - new Vector3(0, 0, 1f), MarkerData.RepresentedBy.Heading);
                }

                else if (MarkerData.RepresentedBy is Ped && !PlayerSpawnOpen && IsPlacingObjective)
                {
                    CreatePedObjective(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position - new Vector3(0, 0, 1f), MarkerData.RepresentedBy.Heading);
                }

                else if (MarkerData.RepresentedBy is Object && PlacedWeaponHash == 0 && !IsPlacingObjective && !ObjectiveMarkerId.HasValue)
                {
                    CreateObject(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position,
                        MarkerData.RepresentedBy.Rotation);
                }

                else if (MarkerData.RepresentedBy is Object && PlacedWeaponHash != 0 && !IsPlacingObjective && !ObjectiveMarkerId.HasValue)
                {
                    CreatePickup(PlacedWeaponHash, MarkerData.RepresentedBy.Position,
                        MarkerData.RepresentedBy.Rotation);
                }

                else if (MarkerData.RepresentedBy is Object && PlacedWeaponHash != 0 && IsPlacingObjective && !ObjectiveMarkerId.HasValue)
                {
                    CreatePickupObjective(PlacedWeaponHash, MarkerData.RepresentedBy.Position,
                        MarkerData.RepresentedBy.Rotation);
                }

                else if (MarkerData.RepresentedBy is Object && PlacedWeaponHash == 0 && IsPlacingObjective && ObjectiveMarkerId.HasValue && _selectedMarker == null)
                {
                    CreateCheckpoint(MarkerData.RepresentedBy.Position + new Vector3(0,0,MarkerData.HeightOffset),
                        Color.FromArgb(100, Color.Yellow.R, Color.Yellow.G, Color.Yellow.B), new Vector3(1, 1, 1));
                }
            }
            else if (_hoveringEntity != null && _hoveringEntity.IsValid() &&
                     Game.IsControlJustPressed(0, GameControl.Attack) && 
                     (MarkerData.RepresentedBy == null || !MarkerData.RepresentedBy.IsValid()) &&
                     _propertiesMenu == null)
            {
                var type = GetEntityType(_hoveringEntity);
                // TODO: Properties
                if (type == EntityType.NormalActor)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new ActorPropertiesMenu();
                    var actor = CurrentMission.Actors.FirstOrDefault(o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };


                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.Spawnpoint)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new SpawnpointPropertiesMenu();
                    var actor = CurrentMission.Spawnpoints.FirstOrDefault(o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };


                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.ObjectiveActor)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new ActorObjectivePropertiesMenu();
                    var actor = CurrentMission.Objectives.FirstOrDefault(o =>
                    {
                        var act = o as SerializableActorObjective;
                        return act?.GetPed().Handle.Value == _hoveringEntity.Handle.Value;
                    });
                    newMenu.BuildFor((SerializableActorObjective)actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if(type == EntityType.NormalVehicle)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new VehiclePropertiesMenu();
                    var actor = CurrentMission.Vehicles.FirstOrDefault(o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.ObjectiveVehicle)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new VehicleObjectivePropertiesMenu();
                    var actor = CurrentMission.Objectives.OfType<SerializableVehicleObjective>()
                        .FirstOrDefault(o => o.GetVehicle().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.NormalObject)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new ObjectPropertiesMenu();
                    var actor = CurrentMission.Objects.FirstOrDefault(o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.NormalPickup)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new PickupPropertiesMenu();
                    var actor = CurrentMission.Pickups.FirstOrDefault(o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
                else if (type == EntityType.ObjectivePickup)
                {
                    CloseAllMenus();

                    DisableControlEnabling = true;
                    EnableBasicMenuControls = true;
                    var newMenu = new PickupObjectivePropertiesMenu();
                    var actor = CurrentMission.Objectives.OfType<SerializablePickupObjective>()
                        .FirstOrDefault(o => o.GetObject().Handle.Value == _hoveringEntity.Handle.Value);
                    newMenu.BuildFor(actor);

                    newMenu.OnMenuClose += sender =>
                    {
                        _missionMenu.Visible = true;
                        menuDirty = true;
                        RingData.Color = Color.Gray;
                        DisableControlEnabling = false;
                        EnableBasicMenuControls = false;
                    };

                    newMenu.Visible = true;
                    _propertiesMenu = newMenu;
                }
            }
            else if (_selectedMarker != null &&
                     Game.IsControlJustPressed(0, GameControl.Attack) &&
                     (MarkerData.RepresentedBy == null || !MarkerData.RepresentedBy.IsValid()) &&
                     _propertiesMenu == null)
            {
                CloseAllMenus();

                DisableControlEnabling = true;
                EnableBasicMenuControls = true;
                var newMenu = new MarkerPropertiesMenu();
                newMenu.BuildFor(_selectedMarker);

                newMenu.OnMenuClose += sender =>
                {
                    _missionMenu.Visible = true;
                    menuDirty = true;
                    RingData.Color = Color.Gray;
                    DisableControlEnabling = false;
                    EnableBasicMenuControls = false;
                };

                newMenu.Visible = true;
                _propertiesMenu = newMenu;
            }
            else if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() &&
                     _hoveringEntity != null && _hoveringEntity.IsValid() &&
                     Game.IsControlJustPressed(0, GameControl.CellphoneSelect))
            {
                var type = GetEntityType(_hoveringEntity);
                if (_hoveringEntity.IsVehicle() && MarkerData.RepresentedBy.IsVehicle())
                {
                    foreach (var ped in ((Vehicle) _hoveringEntity).Occupants)
                    {
                        var pedType = GetEntityType(ped);
                        if (pedType == EntityType.NormalActor)
                        {
                            CurrentMission.Actors.First(o => o.GetEntity().Handle.Value == ped.Handle.Value)
                                .SpawnInVehicle = false;
                        }
                        else if (pedType == EntityType.Spawnpoint)
                        {
                            CurrentMission.Spawnpoints.First(o => o.GetEntity().Handle.Value == ped.Handle.Value)
                                .SpawnInVehicle = false;
                        }
                        else if (pedType == EntityType.ObjectiveActor)
                        {
                            ((SerializableActorObjective) CurrentMission.Objectives.First(o =>
                            {
                                var p = o as SerializableActorObjective;
                                return p?.GetPed().Handle.Value == ped.Handle.Value;
                            })).SpawnInVehicle = false;
                        }
                    }

                    if (type == EntityType.NormalVehicle)
                    {
                        CurrentMission.Vehicles.Remove(
                            CurrentMission.Vehicles.FirstOrDefault(
                                o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value));
                    }
                    else if (type == EntityType.ObjectiveVehicle)
                    {
                        var myVeh = ((SerializableVehicleObjective) CurrentMission.Objectives.First(o =>
                        {
                            var p = o as SerializableVehicleObjective;
                            return p?.GetVehicle().Handle.Value == _hoveringEntity.Handle.Value;
                        }));
                        CurrentMission.Objectives.Remove(myVeh);
                    }
                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (_hoveringEntity.IsVehicle() && MarkerData.RepresentedBy.IsPed())
                {
                    int? possibleSeat = ((Vehicle) _hoveringEntity).GetFreeSeatIndex();
                    if (possibleSeat.HasValue)
                    {
                        var newPed = CreatePed(MarkerData.RepresentedBy.Model, MarkerData.RepresentedBy.Position,
                            MarkerData.RepresentedBy.Heading);
                        ((Ped) newPed.GetEntity()).WarpIntoVehicle((Vehicle) _hoveringEntity, possibleSeat.Value);
                        newPed.SpawnInVehicle = true;
                        newPed.VehicleSeat = possibleSeat.Value;
                    }
                }
                else if (MarkerData.RepresentedBy.IsPed() && type == EntityType.NormalActor)
                {
                    CurrentMission.Actors.Remove(
                        CurrentMission.Actors.FirstOrDefault(
                            o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (MarkerData.RepresentedBy.IsPed() && type == EntityType.Spawnpoint)
                {
                    CurrentMission.Spawnpoints.Remove(
                        CurrentMission.Spawnpoints.FirstOrDefault(
                            o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (_hoveringEntity.IsPed() && MarkerData.RepresentedBy.IsPed() && type == EntityType.ObjectiveActor)
                {
                    CurrentMission.Objectives.Remove(
                        CurrentMission.Objectives.FirstOrDefault(m =>
                        {
                            var o = m as SerializableActorObjective;
                            return o?.GetPed().Handle.Value == _hoveringEntity.Handle.Value;
                        }));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (_hoveringEntity.IsObject() && MarkerData.RepresentedBy.IsObject() && PlacedWeaponHash == 0 &&
                         !IsPlacingObjective)
                {
                    CurrentMission.Objects.Remove(
                        CurrentMission.Objects.FirstOrDefault(
                            o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (_hoveringEntity.IsObject() && MarkerData.RepresentedBy.IsObject() &&
                         PlacedWeaponHash != 0 && !IsPlacingObjective)
                {
                    CurrentMission.Pickups.Remove(
                        CurrentMission.Pickups.FirstOrDefault(
                            o => o.GetEntity().Handle.Value == _hoveringEntity.Handle.Value));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
                else if (_hoveringEntity.IsObject() && MarkerData.RepresentedBy.IsObject() &&
                         PlacedWeaponHash != 0 && IsPlacingObjective)
                {
                    CurrentMission.Objectives.Remove(
                        CurrentMission.Objectives.FirstOrDefault(o =>
                        {
                            var d = o as SerializablePickupObjective;
                            return d?.GetObject().Handle.Value == _hoveringEntity.Handle.Value;
                        }));

                    _hoveringEntity.Delete();
                    if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid())
                        MarkerData.RepresentedBy.Opacity = 1f;
                    MarkerData.HeadingOffset = 0f;
                    RingData.Color = Color.MediumPurple;
                    _hoveringEntity = null;
                }
            }
            if (MarkerData.RepresentedBy != null && MarkerData.RepresentedBy.IsValid() &&
                     _selectedMarker != null && Game.IsControlJustPressed(0, GameControl.CellphoneSelect))
            {
                CurrentMission.Objectives.Remove(_selectedMarker);
                _selectedMarker = null;
            }

            #endregion

            DrawInstructionalButtonsScaleform();
        }
Beispiel #3
0
        private void CopyWatch(Entity ent, Vector3 marker)
        {
            if (!Game.IsControlJustPressed(0, GameControl.LookBehind)) return;
            var objectTry = GetSerObjectFromEntity(ent, marker);
            
            if (objectTry != null)
            {
                SerializableObject output = null;
                if (objectTry is SerializablePed)
                    output = CreatePed((SerializablePed) objectTry);
                else if (objectTry is SerializableVehicle)
                    output = CreateVehicle((SerializableVehicle) objectTry);
                else if (objectTry is SerializableSpawnpoint)
                    output = CreateSpawnpoint((SerializableSpawnpoint) objectTry);
                else if (objectTry is SerializablePickup)
                    output = CreatePickup((SerializablePickup) objectTry);
                else
                    output = CreateObject(objectTry);

                MarkerData.RepresentedBy = output?.GetEntity();
                _isCopying = true;
                return;
            }

            var objectiveTry = GetSerObjectiveFromEntity(ent, marker);
            if (objectiveTry == null) return;

            if (objectiveTry is SerializableActorObjective)
            {
                MarkerData.RepresentedBy = CreatePedObjective((SerializableActorObjective)objectiveTry).GetPed();
                _isCopying = true;
            }
            else if (objectiveTry is SerializableVehicleObjective)
            {
                MarkerData.RepresentedBy = CreateVehicleObjective((SerializableVehicleObjective)objectiveTry).GetVehicle();
                _isCopying = true;
            }

            else if (objectiveTry is SerializablePickupObjective)
            {
                MarkerData.RepresentedBy = CreatePickupObjective((SerializablePickupObjective) objectiveTry).GetObject();
                _isCopying = true;
            }

            else if (objectiveTry is SerializableMarker)
            {
                _attachedMarker = CreateCheckpoint((SerializableMarker) objectiveTry);
            }
        }
Beispiel #4
0
 public SerializableMarker CreateCheckpoint(SerializableMarker orig)
 {
     var tmpObj = (SerializableMarker)orig.Clone();
     CurrentMission.Objectives.Add(tmpObj);
     return tmpObj;
 }
Beispiel #5
0
 public SerializableMarker CreateCheckpoint(Vector3 pos, Color col, Vector3 scale)
 {
     var tmpObj = new SerializableMarker();
     tmpObj.SpawnAfter = 0;
     tmpObj.ActivateAfter = 0;
     tmpObj.Alpha = col.A;
     tmpObj.Color = new Vector3(col.R, col.G, col.B);
     tmpObj.Scale = scale;
     tmpObj.Position = pos;
     tmpObj.Type = ObjectiveMarkerId.Value;
     CurrentMission.Objectives.Add(tmpObj);
     return tmpObj;
 }
Beispiel #6
0
        private void CheckForPickupProperty(Vector3 pos, bool entNull)
        {
            var threshold = 1.5f;
            foreach (SerializablePickup pickup in CurrentMission.Pickups)
            {
                if (pickup.GetEntity() == null || !pickup.GetEntity().IsValid()) continue;
                if ((pickup.GetEntity().Position - pos).Length() > threshold) continue;
                RingData.Color = Color.Yellow;
                _hoveringEntity = pickup.GetEntity();
                return;
            }

            foreach (SerializablePickupObjective objective in CurrentMission.Objectives.OfType<SerializablePickupObjective>())
            {
                if (objective.GetObject() == null || !objective.GetObject().IsValid()) continue;
                if ((objective.GetObject().Position - pos).Length() > threshold) continue;
                RingData.Color = Color.Yellow;
                _hoveringEntity = objective.GetObject();
                return;
            }

            foreach (var mark in CurrentMission.Objectives.OfType<SerializableMarker>())
            {
                if ((mark.Position - pos).Length() > threshold) continue;
                RingData.Color = Color.Yellow;
                _selectedMarker = mark;
                return;
            }

            if (entNull)
            {
                RingData.Color = Color.Gray;
                _hoveringEntity = null;
                _selectedMarker = null;
            }
        }