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); }
static void OnMessageSpawnGridSuccess(ref SpawnGridReplyMsg msg, MyNetworkClient sender) { MyGuiAudio.PlaySound(MyGuiSounds.HudPlaceBlock); }
static void OnMessageSpawnGridFailure(ref SpawnGridReplyMsg msg, MyNetworkClient sender) { MyGuiAudio.PlaySound(MyGuiSounds.HudUnable); }
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); }