// From ItemSupplierInterface public bool PeekItem(StorageUserInterface storageUserInterface, out ItemBase item, out ushort cubeType, out ushort cubeValue) { cubeType = cubeValue = 0; SegmentEntity sourceEntity = storageUserInterface as SegmentEntity; if (sourceEntity == null || carriedItem == null || !outputLocation.Allow(sourceEntity)) { // ModLoader.log("PeekItem failed in precheck: sourceEntity == {0}, carriedItem=={1}, inputPort.Allow == {2}", sourceEntity, carriedItem, inputLocation.Allow(sourceEntity)); item = null; return(false); } item = carriedItem; return(true); }
// From ItemConsumerInterface // RECEIVE an item from SourceEntity public bool TryDeliverItem(StorageUserInterface storageUserInterface, ItemBase item, ushort cubeType, ushort cubeValue, bool sendImmediateNetworkUpdate) { SegmentEntity sourceEntity = storageUserInterface as SegmentEntity; if (sourceEntity == null || carriedItem != null || !inputLocation.Allow(sourceEntity)) { // ModLoader.log("TryDeliverItem failed in precheck: sourceEntity == {0}, carriedItem=={1}, inputPort.Allow == {2}", sourceEntity, carriedItem, inputLocation.Allow(sourceEntity)); return(false); } if (item == null) { item = ItemManager.SpawnCubeStack(cubeType, cubeValue, 1); } carriedItem = item; SetAnimationState(AnimateCarryItem()); if (sendImmediateNetworkUpdate) { this.RequestImmediateNetworkUpdate(); } return(true); }