private static void OnSetToConstructionRequest(MySyncGrid sync, ref SetToConstructionRequestMsg msg, MyNetworkClient sender) { var block = sync.Entity.GetCubeBlock(msg.BlockPosition); Debug.Assert(block != null, "Could not find block to set to construction site"); if (block == null) return; block.SetToConstructionSite(); MyEntity ownerEntity = null; if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity)) { Debug.Assert(false, "Set to construction site inventory owner entity was null"); return; } var owner = (ownerEntity as IMyInventoryOwner); Debug.Assert(owner != null, "Set to construction site inventory owner was not an inventory owner"); var inventory = owner.GetInventory(msg.InventoryIndex); Debug.Assert(inventory != null, "Set to construction site inventory owner did not have the given inventory"); block.MoveItemsToConstructionStockpile(inventory); block.IncreaseMountLevel(MyWelder.WELDER_AMOUNT_PER_SECOND * MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, msg.RequestingPlayer); }
public void RequestSetToConstruction(Vector3I blockPosition, MyInventory fromInventory) { var msg = new SetToConstructionRequestMsg(); msg.GridEntityId = Entity.EntityId; msg.BlockPosition = blockPosition; msg.InventoryIndex = fromInventory.InventoryIdx; msg.OwnerEntityId = fromInventory.Owner.EntityId; // CH: TODO: Allow bots to set to construction msg.RequestingPlayer = MySession.LocalPlayerId; Sync.Layer.SendMessageToServer(ref msg); }