public static bool IsConveyorFacingMe(this MachineEntity center, ConveyorEntity conv) { long x = conv.mnX + (long)conv.mForwards.x; long y = conv.mnY + (long)conv.mForwards.y; long z = conv.mnZ + (long)conv.mForwards.z; return((x == center.mnX) && (y == center.mnY) && (z == center.mnZ)); }
protected virtual bool isConveyorNotFacingMe(ConveyorEntity conv) { long x = conv.mnX + (long)conv.mForwards.x; long y = conv.mnY + (long)conv.mForwards.y; long z = conv.mnZ + (long)conv.mForwards.z; return((x != mnX) || (y != mnY) || (z != mnZ)); }
protected virtual bool isConveyorFacingMe(ConveyorEntity conv) { long x = conv.mnX + (long)conv.mForwards.x; long y = conv.mnY + (long)conv.mForwards.y; long z = conv.mnZ + (long)conv.mForwards.z; return((x == mnX) && (y == mnY) && (z == mnZ)); }
protected override Boolean TrySetScalarValue(SegmentEntity entity, Single value) { ConveyorEntity conv = entity as ConveyorEntity; if (conv == null) { return(false); } conv.mrCarrySpeed = value; return(true); }
protected override Byte CalculateOutput(SegmentEntity entity, UInt16 data) { ConveyorEntity conveyorEntity = entity as ConveyorEntity; if (conveyorEntity == null) { return(0); } Single timer = conveyorEntity.mrCarryTimer; return((Byte)(timer * 255f)); }
protected override Boolean TryGetScalarValue(SegmentEntity entity, out Single value) { ConveyorEntity conv = entity as ConveyorEntity; if (conv == null) { value = 0; return(false); } value = conv.mrCarrySpeed; return(true); }
protected virtual void pickUpFromConveyors() { bool ignore; List <ConveyorEntity> list = VicisMod.checkSurrounding <ConveyorEntity>(this, out ignore); VicisMod.log(getPrefix(), "Found " + list.Count + " ConveyorEntities"); for (int i = 0; i < list.Count && getStoredItemsCount() < maxItems; ++i) { ConveyorEntity c = list[i]; if (!isConveyorFacingMe(c)) { continue; } if (!c.mbReadyToConvey && c.mrCarryTimer <= 0.2f) { ItemBase item = null; if (c.mCarriedItem != null) { item = c.mCarriedItem; } if (c.mCarriedCube != 0) { item = ItemManager.SpawnCubeStack(c.mCarriedCube, c.mCarriedValue, 1); } // Wha... How? if (item == null) { continue; } // Check if I can add it to the items list if (!addItem(item)) { return; } c.mCarriedItem = null; c.mCarriedCube = 0; c.mCarriedValue = 0; c.RemoveCube(); c.FinaliseOffloadingCargo(); } } }
public static StorageMachineInterface getStorageHandlerForEntityForBelt(Segment s, long x, long y, long z, ConveyorEntity belt) { SegmentEntity ret = s.SearchEntity(x, y, z); if (belt.mValue == 15) { //Debug.Log("Motor belt at "+new Coordinate(belt)+" is pulling from a "+ret+" at "+new Coordinate(ret)); } if (ret is ContinuousCastingBasin && belt.mValue == 15) //motor belt { ContinuousCastingBasin ccb = ret as ContinuousCastingBasin; ccb = ccb.GetCenter(); return(ccb != null ? new BasinInterfaceWrapper(ccb) : null); } else { return(ret as StorageMachineInterface); } }
protected virtual void dropOffToConveyors() { bool ignore; List <ConveyorEntity> list = VicisMod.checkSurrounding <ConveyorEntity>(this, out ignore); VicisMod.log(getPrefix(), "Found " + list.Count + " ConveyorEntities"); string msg = items.Count + ": "; foreach (ItemBase it in items) { msg += it.GetDisplayString() + ", "; } VicisMod.log(getPrefix(), "Currently storing " + msg); for (int i = 0; i < list.Count && items.Count > 0; ++i) { ConveyorEntity c = list[i] as ConveyorEntity; if (!isConveyorNotFacingMe(c)) { VicisMod.log(getPrefix(), "Conveyor is either not facing somewhere else: " + isConveyorNotFacingMe(c)); continue; } if (c.mbReadyToConvey && c.mrLockTimer == 0f) { VicisMod.log(getPrefix(), "Ready to convey, will be giving " + items[0].GetDisplayString() + ", a " + items[0].mType); if (items[0].mType == ItemType.ItemCubeStack) { ItemCubeStack a = items[0] as ItemCubeStack; c.AddCube(a.mCubeType, a.mCubeValue, 1); c.mItemForwards = forwards; --a.mnAmount; if (a.mnAmount == 0) { VicisMod.log(getPrefix(), "Removing cube " + a.GetDisplayString() + " from items list"); items.RemoveAt(0); } } else if (items[0].mType == ItemType.ItemStack) { ItemStack a = ItemBaseUtil.newInstance(items[0]) as ItemStack; a.mnAmount = 1; ItemBaseUtil.decrementStack(items[0], 1); c.AddItem(a); c.mItemForwards = forwards; if (ItemBaseUtil.getAmount(items[0]) == 0) { VicisMod.log(getPrefix(), "Removing item " + a.GetDisplayString() + " from items list"); items.RemoveAt(0); } } else { c.AddItem(items[0]); c.mrCarryTimer = 1f; c.mrVisualCarryTimer = 1f; c.mItemForwards = forwards; items.RemoveAt(0); } } else { VicisMod.log(getPrefix(), "Conveyor is not ready to convey"); } } }