public void Register(MyCameraBlock camera)
        {
            MyDebug.AssertDebug(camera != null);
            MyDebug.AssertDebug(!m_cameras.Contains(camera));

            m_cameras.Add(camera);
        }
        public void SetAsCurrent(MyCameraBlock newCamera)
        {
            MyDebug.AssertDebug(newCamera != null);
            
            if (m_currentCamera == newCamera)
            {
                return;
            }

            if (newCamera.BlockDefinition.OverlayTexture != null)
            {
                MyHudCameraOverlay.TextureName = newCamera.BlockDefinition.OverlayTexture;
                MyHudCameraOverlay.Enabled = true;
            }
            else
            {
                MyHudCameraOverlay.Enabled = false;
            }

            string shipName = MyAntennaSystem.GetLogicalGroupRepresentative(m_grid).DisplayName ?? "";
            string cameraName = newCamera.DisplayNameText;
            
            MyHud.CameraInfo.Enable(shipName, cameraName);
            m_currentCamera = newCamera;
            m_ignoreNextInput = true;

            MySessionComponentVoxelHand.Static.Enabled = false;
            MyCubeBuilder.Static.Deactivate();
        }
        public void Unregister(MyCameraBlock camera)
        {
            MyDebug.AssertDebug(camera != null);
            MyDebug.AssertDebug(m_cameras.Contains(camera));

            if (camera == m_currentCamera)
            {
                ResetCamera();
            }

            m_cameras.Remove(camera);
        }
        private MyCameraBlock GetPrev(MyCameraBlock current)
        {
            MyDebug.AssertDebug(current != null);
            MyDebug.AssertDebug(m_cameras.Contains(current));

            if (m_relayedCameras.Count == 1)
            {
                return current;
            }

            int indexOf = m_relayedCameras.IndexOf(current);
            if (indexOf == -1)
            {
                ResetCamera();
                return null;
            }
            int prevIndex = indexOf - 1;
            if (prevIndex < 0)
            {
                prevIndex = m_relayedCameras.Count - 1;
            }
            return m_relayedCameras[prevIndex];
        }
        private void SetCamera(MyCameraBlock newCamera)
        {
            if (newCamera == m_currentCamera)
            {
                return;
            }

            if (m_cameras.Contains(newCamera))
            {
                SetAsCurrent(newCamera);
                newCamera.SetView();
            }
            else
            {
                MyHudCameraOverlay.Enabled = false;
                MyHud.CameraInfo.Disable();
                ResetCurrentCamera();
                newCamera.RequestSetView();
            }
        }
        private MyCameraBlock GetNext(MyCameraBlock current)
        {
            MyDebug.AssertDebug(current != null);
            MyDebug.AssertDebug(m_cameras.Contains(current));

            if (m_relayedCameras.Count == 1)
            {
                return current;
            }

            int indexOf = m_relayedCameras.IndexOf(current);

            if (indexOf == -1)
            {
                ResetCamera();
                return null;
            }

            return m_relayedCameras[(indexOf + 1) % m_relayedCameras.Count];
        }
 private void ResetCurrentCamera()
 {
     m_currentCamera.OnExitView();
     
     m_currentCamera = null;
 }
        public static bool CameraIsInRangeAndPlayerHasAccess(MyCameraBlock camera)
        {
            if (MySession.ControlledEntity != null)
            {
                MyIDModule module;
                if ((camera as IMyComponentOwner<MyIDModule>).GetComponent(out module))
                {
                    if (!(camera.HasPlayerAccess(MySession.LocalPlayerId) || module.Owner == 0))
                    {
                        return false;
                    }
                }

                if (MySession.ControlledEntity is MyCharacter)
                {
                    return MyAntennaSystem.CheckConnection(MySession.LocalCharacter, camera.CubeGrid, MySession.LocalHumanPlayer);
                }
                else if (MySession.ControlledEntity is MyShipController)
                {
                    return MyAntennaSystem.CheckConnection((MySession.ControlledEntity as MyShipController).CubeGrid, camera.CubeGrid, MySession.LocalHumanPlayer);
                }
            }

            return false;
        }
Esempio n. 9
0
 public MySyncCameraBlock(MyCameraBlock cameraBlock)
     : base(cameraBlock)
 {
 }
Esempio n. 10
0
 public MySyncCameraBlock(MyCameraBlock cameraBlock)
     : base(cameraBlock)
 {
 }
        public void SetAsCurrent(MyCameraBlock newCamera)
        {
            MyDebug.AssertDebug(newCamera != null);
            
            if (m_currentCamera == newCamera)
            {
                return;
            }

            if (newCamera.BlockDefinition.OverlayTexture != null)
            {
                MyHudCameraOverlay.TextureName = newCamera.BlockDefinition.OverlayTexture;
                MyHudCameraOverlay.Enabled = true;
            }
            else
            {
                MyHudCameraOverlay.Enabled = false;
            }

            //By Gregory: Temporary fix cause Session component for antenna system hasn't been called yet and Static isn't assigned yet at game load(see BeforeStart function).
            string shipName = "";
            if (MyAntennaSystem.Static != null)
            {
                shipName = MyAntennaSystem.Static.GetLogicalGroupRepresentative(m_grid).DisplayName ?? "";
            }
            string cameraName = newCamera.DisplayNameText;
            
            MyHud.CameraInfo.Enable(shipName, cameraName);
            m_currentCamera = newCamera;
            m_ignoreNextInput = true;

            MySessionComponentVoxelHand.Static.Enabled = false;
            MySession.Static.GameFocusManager.Clear();
            //MyCubeBuilder.Static.Deactivate();
        }