private static void OnStockpileFillRequest(MySyncGrid sync, ref StockpileFillRequestMsg msg, MyNetworkClient sender) { var block = sync.Entity.GetCubeBlock(msg.BlockPosition); Debug.Assert(block != null, "Could not find block whose stockpile fill was requested"); if (block == null) return; MyEntity ownerEntity = null; if (!MyEntities.TryGetEntityById(msg.OwnerEntityId, out ownerEntity)) { Debug.Assert(false, "Stockpile fill inventory owner entity was null"); return; } var owner = (ownerEntity as IMyInventoryOwner); Debug.Assert(owner != null, "Stockpile fill inventory owner was not an inventory owner"); var inventory = owner.GetInventory(msg.InventoryIndex); Debug.Assert(inventory != null, "Stockpile fill inventory owner did not have the given inventory"); block.MoveItemsToConstructionStockpile(inventory); }
public void RequestFillStockpile(Vector3I blockPosition, MyInventory fromInventory) { Debug.Assert(fromInventory.Owner != null, "Inventory owner was null"); var msg = new StockpileFillRequestMsg(); msg.GridEntityId = Entity.EntityId; msg.BlockPosition = blockPosition; msg.InventoryIndex = fromInventory.InventoryIdx; msg.OwnerEntityId = fromInventory.Owner.EntityId; Sync.Layer.SendMessageToServer(ref msg); }