Ejemplo n.º 1
0
        private void InitAll()
        {
            fullPathToolTip.AutoPopDelay = 5000;
            fullPathToolTip.InitialDelay = 1000;
            fullPathToolTip.ReshowDelay  = 500;
            fullPathToolTip.ShowAlways   = true;

            InitializeComponent();

            attachmentControl = new AttachmentControl {
                Size = new Size(210, Height - 34), Location = new Point(0, 34)
            };
            attachmentControl.DeleteFileCliked                  += attachmentControl_DeleteFileCliked;
            attachmentControl.CaptureAnotherPicture             += attachmentControl_CaptureAnotherPicture;
            attachmentControl.AddAnotherPicture                 += attachmentControl_AddAnotherPicture;
            TpAuthenticationManager.Instance.OnChangeLoginEvent += CancelAndRefresh;

            Controls.Add(attachmentControl);

            InitDropDowns();
        }
Ejemplo n.º 2
0
        internal void OnControl(AttachmentControl attachmentControl)
        {
            if (_attachmentStage != AttachmentStage.Position && _attachmentStage != AttachmentStage.Detach)
            {
                return;
            }

            float changeAmount = CONFIG.ChangeAmount;

            if (_goFaster)
            {
                changeAmount += CONFIG.FasterAmount;
            }
            else if (_goSlower)
            {
                changeAmount += CONFIG.SlowerAmount;
            }

            Vector3
                position = _attachments.Last().AttachmentPosition,
                rotation = _attachments.Last().AttachmentRotation;

            Vehicle
                towVehicle        = (Vehicle)Entity.FromNetworkId(_attachments.Last().TowVehicle),
                vehicleBeingTowed = (Vehicle)Entity.FromNetworkId(_attachments.Last().VehicleBeingTowed);

            if (!Entity.Exists(towVehicle) || !Entity.Exists(vehicleBeingTowed))
            {
                Game.PlaySound("CANCEL", "HUD_FREEMODE_SOUNDSET");
                Screen.ShowNotification("~g~Attachment canceled.");

                _attachmentStage = AttachmentStage.Cancel;

                return;
            }

            switch (attachmentControl)
            {
            case AttachmentControl.Forward:
                position.Y += changeAmount;
                break;

            case AttachmentControl.Back:
                position.Y -= changeAmount;
                break;

            case AttachmentControl.Left:
                position.X -= changeAmount;
                break;

            case AttachmentControl.Right:
                position.X += changeAmount;
                break;

            case AttachmentControl.Up:
                position.Z += changeAmount;
                break;

            case AttachmentControl.Down:
                position.Z -= changeAmount;
                break;

            case AttachmentControl.RotateLeft:
                rotation.Z += changeAmount * 10;
                break;

            case AttachmentControl.RotateRight:
                rotation.Z -= changeAmount * 10;
                break;

            case AttachmentControl.RotateUp:
                rotation.X += changeAmount * 10;
                break;

            case AttachmentControl.RotateDown:
                rotation.X -= changeAmount * 10;
                break;

            case AttachmentControl.Confirm:
                TriggerServerEvent("Inferno-Collection:Vehicle-Attachment:RemoveInUseVehicle", _attachments.Last().TowVehicle);
                TriggerServerEvent("Inferno-Collection:Vehicle-Attachment:RemoveInUseVehicle", _attachments.Last().VehicleBeingTowed);

                if (_attachmentStage == AttachmentStage.Position)
                {
                    Screen.ShowNotification("~g~Attachment complete! Drive safe.");

                    vehicleBeingTowed.ResetOpacity();
                    vehicleBeingTowed.IsCollisionEnabled = true;
                }
                else if (_attachmentStage == AttachmentStage.Detach)
                {
                    Screen.ShowNotification($"~g~{vehicleBeingTowed.LocalizedName} detached!");

                    ResetTowedVehicle(vehicleBeingTowed);

                    _attachments.RemoveAll(
                        i =>
                        i.TowVehicle == _attachments.Last().TowVehicle&&
                        i.VehicleBeingTowed == _attachments.Last().VehicleBeingTowed
                        );
                }

                Game.PlaySound("WAYPOINT_SET", "HUD_FRONTEND_DEFAULT_SOUNDSET");

                _attachmentStage = AttachmentStage.None;

                return;
            }

            if (towVehicle.Position.DistanceToSquared(towVehicle.GetOffsetPosition(position)) > CONFIG.MaxDistanceFromTowVehicle)
            {
                Screen.ShowNotification("~r~Cannot move there, too far from tow vehicle!", true);
                return;
            }

            vehicleBeingTowed.AttachTo(towVehicle, position, rotation);

            // Store current position so we can reference it later
            _attachments.Last().AttachmentPosition = position;
            _attachments.Last().AttachmentRotation = rotation;
        }