Exemple #1
0
        /// <summary>
        /// Handles "set" and "move" messages from client.
        /// </summary>
        /// <param name="msg">Message.</param>
        /// <param name="relative">If set to <c>true</c> relative.</param>
        protected void HandleMove(ClientMessage msg, bool relative)
        {
            var cam = ToolsModifierControl.cameraController;

            cam.ClearTarget();
            Vector3 targetPos, currentPos;
            Vector2 targetAngle, currentAngle;

            if (msg.HasKey("targetPosition"))
            {
                targetPos = msg.GetVector3("targetPosition");
            }
            else
            {
                targetPos = cam.m_targetPosition;
            }

            if (msg.HasKey("position"))
            {
                currentPos = msg.GetVector3("position");
            }
            else
            {
                currentPos = cam.m_currentPosition;
            }

            if (msg.HasKey("targetAngle"))
            {
                targetAngle = msg.GetVector2("targetAngle");
            }
            else
            {
                targetAngle = cam.m_targetAngle;
            }

            if (msg.HasKey("angle"))
            {
                currentAngle = msg.GetVector2("angle");
            }
            else
            {
                currentAngle = cam.m_currentAngle;
            }

            if (!relative)
            {
                cam.m_targetPosition.Set(0, 0, 0);
                cam.m_currentPosition.Set(0, 0, 0);
                cam.m_targetAngle.Set(0, 0);
                cam.m_currentAngle.Set(0, 0);
            }
            cam.m_targetPosition  += targetPos;
            cam.m_currentPosition += currentPos;
            cam.m_targetAngle     += targetAngle;
            cam.m_currentAngle    += currentAngle;
        }
Exemple #2
0
        /// <summary>
        /// Handles "lookAt" message from client.
        /// </summary>
        /// <param name="msg">Message.</param>
        protected void HandleLookAt(ClientMessage msg)
        {
            Vector3    pos;
            InstanceID id  = default(InstanceID);
            var        cam = ToolsModifierControl.cameraController;

            cam.ClearTarget();
            if (msg.HasKey("building"))
            {
                id.Building = (ushort)msg.GetInt("building");
                pos         = BuildingManager.instance.m_buildings.m_buffer[id.Building].m_position;
            }
            else if (msg.HasKey("vehicle"))
            {
                id.Vehicle = (ushort)msg.GetInt("vehicle");
                pos        = VehicleManager.instance.m_vehicles.m_buffer[id.Vehicle].GetLastFramePosition();
            }
            else if (msg.HasKey("parkedVehicle"))
            {
                id.ParkedVehicle = (ushort)msg.GetInt("parkedVehicle");
                pos = VehicleManager.instance.m_parkedVehicles.m_buffer[id.ParkedVehicle].m_position;
            }
            else if (msg.HasKey("segment"))
            {
                id.NetSegment = (ushort)msg.GetInt("segment");
                pos           = NetManager.instance.m_segments.m_buffer[id.NetSegment].m_bounds.center;
            }
            else if (msg.HasKey("node"))
            {
                id.NetNode = (ushort)msg.GetInt("node");
                pos        = NetManager.instance.m_nodes.m_buffer[id.NetNode].m_position;
            }
            else if (msg.HasKey("citizenInstance"))
            {
                id.CitizenInstance = (ushort)msg.GetInt("citizenInstance");
                pos = CitizenManager.instance.m_instances.m_buffer[id.CitizenInstance].GetLastFramePosition();
            }
            else if (msg.HasKey("position"))
            {
                cam.m_targetPosition = msg.GetVector3("position");
                return;
            }
            else
            {
                throw new ArgumentException("No target specified");
            }
            bool zoom      = !msg.HasKey("zoom") || msg.GetBool("zoom");
            bool openPanel = !msg.HasKey("openInfoPanel") || msg.GetBool("openInfoPanel");

            cam.SetTarget(id, pos, zoom);
            if (openPanel)
            {
                SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => {
                    DefaultTool.OpenWorldInfoPanel(id, pos);
                });
            }
        }