Exemple #1
0
        static object GetItemInControlPanel()
        {
            if (MyGuiScreenTerminal.GetCurrentScreen() == MyTerminalPageEnum.ControlPanel)
            {
                return(MyGuiScreenTerminal.InteractedEntity);
            }

            return(null);
        }
        void Write(BitStream stream)
        {
            // TODO: Make sure sleeping, server controlled entities are not moving locally (or they can be but eventually their position should be corrected)

            stream.WriteBool(MySession.ControlledEntity != null);
            if (MySession.ControlledEntity == null)
            {
                Vector3D pos = MySpectatorCameraController.Static.Position;
                stream.WriteDouble(pos.X);
                stream.WriteDouble(pos.Y);
                stream.WriteDouble(pos.Z);
            }
            else
            {
                var controlledEntity = MySession.ControlledEntity.Entity.GetTopMostParent();

                // Send controlled entity every other frame to server
                if (MyMultiplayer.Static.FrameCounter % 2 == 0)
                {
                    // TODO: Write additional client data, context

                    if (controlledEntity != null && controlledEntity.SyncFlag && ((MySyncEntity)controlledEntity.SyncObject).ResponsibleForUpdate(Sync.Clients.LocalClient))
                    {
                        stream.WriteInt64(controlledEntity.EntityId);
                        switch (MyGuiScreenTerminal.GetCurrentScreen())
                        {
                        case MyTerminalPageEnum.Inventory:
                            stream.WriteInt32((int)MyContextKind.Inventory, 2);
                            break;

                        case MyTerminalPageEnum.ControlPanel:
                            stream.WriteInt32((int)MyContextKind.Terminal, 2);
                            break;

                        case MyTerminalPageEnum.Production:
                            stream.WriteInt32((int)MyContextKind.Production, 2);
                            break;

                        default:
                            stream.WriteInt32((int)MyContextKind.None, 2);
                            break;
                        }

                        if (MyGuiScreenTerminal.InteractedEntity != null)
                        {
                            stream.WriteInt64(MyGuiScreenTerminal.InteractedEntity.EntityId);
                        }
                        else
                        {
                            stream.WriteInt64(0);
                        }

                        ((MySyncEntity)controlledEntity.SyncObject).SerializePhysics(stream, null);
                    }
                }
            }
        }
        protected override void WriteInternal(BitStream stream, MyEntity controlledEntity)
        {
            MyContextKind context = GetContextByPage(MyGuiScreenTerminal.GetCurrentScreen());

            stream.WriteInt32((int)context, 2);
            if (context != MyContextKind.None)
            {
                var entityId = MyGuiScreenTerminal.InteractedEntity != null ? MyGuiScreenTerminal.InteractedEntity.EntityId : 0;
                stream.WriteInt64(entityId);
            }
        }
Exemple #4
0
        protected override void WriteInternal(BitStream stream, MyEntity controlledEntity)
        {
            MyContextKind contextByPage = GetContextByPage(MyGuiScreenTerminal.GetCurrentScreen());

            stream.WriteInt32((int)contextByPage, 2);
            if (contextByPage != MyContextKind.None)
            {
                long value = (MyGuiScreenTerminal.InteractedEntity != null) ? MyGuiScreenTerminal.InteractedEntity.EntityId : 0L;
                stream.WriteInt64(value, 64);
            }
        }
Exemple #5
0
        protected override void OnUpdate()
        {
            if (_available)
            {
                var screen = MyGuiScreenTerminal.GetCurrentScreen();
                if (screen != _currentScreen)
                {
                    _currentScreen = screen;
                    OnScreenChanged(screen);
                }
            }

            base.OnUpdate();
        }
Exemple #6
0
        private void Grab()
        {
            if (MyAPIGateway.Session.ControlledObject != null && MyGuiScreenTerminal.GetCurrentScreen() == MyTerminalPageEnum.None && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
            {
                if (grabber.TryGrabNew(5))
                {
                    var packet = new List <byte>();
                    packet.AddRange(BitConverter.GetBytes(true));
                    packet.AddRange(BitConverter.GetBytes(MyAPIGateway.Session.Player.IdentityId));

                    MyAPIGateway.Multiplayer.SendMessageToOthers(HANDLER_ID, packet.ToArray());

                    grabbed = true;
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Updates positions & orientations
        /// </summary>
        public void Update1()
        {
            if (!Enabled || !m_playerCanSee)
            {
                foreach (SeenHolo sh in m_holoEntities.Values)
                {
                    if (sh.Holo.Render.Visible)
                    {
                        Log.DebugLog("hiding holo: " + sh.Seen.Entity.getBestName());
                        SetVisible(sh.Holo, false);
                    }
                }
                return;
            }

            if (MyGuiScreenTerminal.GetCurrentScreen() == MyTerminalPageEnum.None && MyAPIGateway.Session.ControlledObject.Entity is IMyCharacter && Static.MouseControls)
            {
                CheckInput();
            }

            PositionWorld projectionCentre = m_offset.ToWorld(m_block);

            float distanceScale = m_radiusHolo / m_rangeDetection;
            float sizeScale     = distanceScale * m_sizeDistScale;

            foreach (SeenHolo sh in m_holoEntities.Values)
            {
                MatrixD worldMatrix = sh.Seen.Entity.WorldMatrix;
                worldMatrix.Translation = projectionCentre + (sh.Seen.Entity.GetPosition() - m_centreEntity.GetPosition()) * distanceScale + (sh.Seen.Entity.GetPosition() - sh.Seen.Entity.GetCentre()) * (sizeScale - distanceScale);
                Log.DebugLog("entity: " + sh.Seen.Entity.getBestName() + "(" + sh.Seen.Entity.EntityId + "), centre: " + projectionCentre + ", offset: " + (worldMatrix.Translation - projectionCentre) + ", position: " + worldMatrix.Translation);
                sh.Holo.PositionComp.SetWorldMatrix(worldMatrix);
                sh.Holo.PositionComp.Scale = sizeScale;
            }

            if (ShowBoundary)
            {
                MatrixD sphereMatrix = m_block.WorldMatrix;
                sphereMatrix.Translation = projectionCentre;
                Color c = Color.Yellow;
                MySimpleObjectDraw.DrawTransparentSphere(ref sphereMatrix, m_radiusHolo, ref c, MySimpleObjectRasterizer.Wireframe, 8);
            }
        }
 public static bool IsInMenu()
 {
     return(MyGuiScreenTerminal.GetCurrentScreen() == MyTerminalPageEnum.None &&
            MyGuiScreenGamePlay.ActiveGameplayScreen == null);
 }