static void OnMessageSpawnGrid(ref SpawnGridMsg msg, MyNetworkClient sender)
        {
            Debug.Assert(MyCubeBuilder.BuildComponent != null, "The build component was not set in cube builder!");

            MyEntity builder = null;

            MyEntities.TryGetEntityById(msg.BuilderEntityId, out builder);

            var     definition  = Definitions.MyDefinitionManager.Static.GetCubeBlockDefinition(msg.Definition);
            MatrixD worldMatrix = MatrixD.CreateWorld(msg.Position, msg.Forward, msg.Up);

            var reply = new SpawnGridReplyMsg();

            MyCubeBuilder.BuildComponent.GetGridSpawnMaterials(definition, worldMatrix, msg.Static);
            bool canSpawn = MyCubeBuilder.BuildComponent.HasBuildingMaterials(builder);

            MySession.Static.SyncLayer.SendMessage(ref reply, sender.SteamUserId, canSpawn ? MyTransportMessageEnum.Success : MyTransportMessageEnum.Failure);

            if (!canSpawn)
            {
                return;
            }

            MyCubeBuilder.SpawnGrid(definition, worldMatrix, builder, msg.Static);
        }
        public static void RequestDynamicGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix)
        {
            SpawnGridMsg msg = new SpawnGridMsg();

            msg.Definition = definition.Id;
            msg.Position   = worldMatrix.Translation;
            msg.Forward    = worldMatrix.Forward;
            msg.Up         = worldMatrix.Up;
            msg.Static     = false;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
        public static void RequestStaticGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix, long builderEntityId)
        {
            SpawnGridMsg msg = new SpawnGridMsg();

            msg.Definition      = definition.Id;
            msg.Position        = worldMatrix.Translation;
            msg.Forward         = worldMatrix.Forward;
            msg.Up              = worldMatrix.Up;
            msg.Static          = true;
            msg.BuilderEntityId = builderEntityId;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
Example #4
0
        public static void RequestDynamicGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix, long builderEntityId)
        {
            Debug.Fail("Use replication instead of this!");
            SpawnGridMsg msg = new SpawnGridMsg();

            msg.Definition      = definition.Id;
            msg.Position        = worldMatrix.Translation;
            msg.Forward         = worldMatrix.Forward;
            msg.Up              = worldMatrix.Up;
            msg.Static          = false;
            msg.BuilderEntityId = builderEntityId;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
        static void OnMessageSpawnGrid(ref SpawnGridMsg msg, MyNetworkClient sender)
        {
            if (Sync.IsServer)
            {
                var     definition  = Definitions.MyDefinitionManager.Static.GetCubeBlockDefinition(msg.Definition);
                MatrixD worldMatrix = MatrixD.CreateWorld(msg.Position, msg.Forward, msg.Up);

                MyCubeGrid grid = null;

                if (msg.Static)
                {
                    grid = MyCubeBuilder.SpawnStaticGrid(definition, worldMatrix);
                }
                else
                {
                    grid = MyCubeBuilder.SpawnDynamicGrid(definition, worldMatrix);
                }

                if (grid != null)
                {
                    msg.Grid = grid.GetObjectBuilder() as MyObjectBuilder_CubeGrid;
                    MySession.Static.SyncLayer.SendMessageToAll(ref msg);
                }

                if (grid != null && msg.Static)
                {
                    MyCubeBuilder.AfterStaticGridSpawn(grid);
                }
            }
            else
            {
                System.Diagnostics.Debug.Assert(msg.Grid != null, "Client must obtain complete grid from server");

                MyCubeGrid grid = MyEntities.CreateFromObjectBuilderAndAdd(msg.Grid) as MyCubeGrid;

                if (grid != null)
                {
                    if (grid.IsStatic)
                    {
                        MyCubeBuilder.AfterStaticGridSpawn(grid);
                    }
                }
            }
        }
Example #6
0
        static void OnMessageSpawnGrid(ref SpawnGridMsg msg, MyNetworkClient sender)
        {
            Debug.Fail("Use replication instead of this!");
            Debug.Assert(MyCubeBuilder.BuildComponent != null, "The build component was not set in cube builder!");

            MyEntity builder = null;
            MyEntities.TryGetEntityById(msg.BuilderEntityId, out builder);

            var definition = Definitions.MyDefinitionManager.Static.GetCubeBlockDefinition(msg.Definition);
            MatrixD worldMatrix = MatrixD.CreateWorld(msg.Position, msg.Forward, msg.Up);

            var reply = new SpawnGridReplyMsg();

            MyCubeBuilder.BuildComponent.GetGridSpawnMaterials(definition, worldMatrix, msg.Static);
            bool canSpawn = MyCubeBuilder.BuildComponent.HasBuildingMaterials(builder);

            MySession.Static.SyncLayer.SendMessage(ref reply, sender.SteamUserId, canSpawn ? MyTransportMessageEnum.Success : MyTransportMessageEnum.Failure);

            if (!canSpawn) return;

            MyCubeBuilder.SpawnGrid(definition, worldMatrix, builder, msg.Static);
        }
Example #7
0
        public static void RequestDynamicGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix, long builderEntityId)
        {
            Debug.Fail("Use replication instead of this!");
            SpawnGridMsg msg = new SpawnGridMsg();

            msg.Definition = definition.Id;
            msg.Position = worldMatrix.Translation;
            msg.Forward = worldMatrix.Forward;
            msg.Up = worldMatrix.Up;
            msg.Static = false;
            msg.BuilderEntityId = builderEntityId;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
        static void OnMessageSpawnGrid(ref SpawnGridMsg msg, MyNetworkClient sender)
        {
            if (Sync.IsServer)
            {
                var definition = Definitions.MyDefinitionManager.Static.GetCubeBlockDefinition(msg.Definition);
                MatrixD worldMatrix = MatrixD.CreateWorld(msg.Position, msg.Forward, msg.Up);

                MyCubeGrid grid = null;

                if (msg.Static)
                    grid = MyCubeBuilder.SpawnStaticGrid(definition, worldMatrix);
                else
                    grid = MyCubeBuilder.SpawnDynamicGrid(definition, worldMatrix);

                if (grid != null)
                {
                    msg.Grid = grid.GetObjectBuilder() as MyObjectBuilder_CubeGrid;
                    MySession.Static.SyncLayer.SendMessageToAll(ref msg);
                }

                if (grid != null && msg.Static)
                {
                    MyCubeBuilder.AfterStaticGridSpawn(grid);
                }
            }
            else
            {
                System.Diagnostics.Debug.Assert(msg.Grid != null, "Client must obtain complete grid from server");

                MyCubeGrid grid = MyEntities.CreateFromObjectBuilderAndAdd(msg.Grid) as MyCubeGrid;

                if (grid != null)
                {
                    if (grid.IsStatic)
                        MyCubeBuilder.AfterStaticGridSpawn(grid);
                }
            }
        }
        public static void RequestDynamicGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix)
        {
            SpawnGridMsg msg = new SpawnGridMsg();

            msg.Definition = definition.Id;
            msg.Position = worldMatrix.Translation;
            msg.Forward = worldMatrix.Forward;
            msg.Up = worldMatrix.Up;
            msg.Static = false;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }
Example #10
0
        public static void RequestStaticGridSpawn(MyCubeBlockDefinition definition, MatrixD worldMatrix, long builderEntityId)
        {
            SpawnGridMsg msg = new SpawnGridMsg();
            
            msg.Definition = definition.Id;
            msg.Position = worldMatrix.Translation;
            msg.Forward = worldMatrix.Forward;
            msg.Up = worldMatrix.Up;
            msg.Static = true;
            msg.BuilderEntityId = builderEntityId;

            MySession.Static.SyncLayer.SendMessageToServer(ref msg);
        }