private void interactWithPort(IMySlimBlock hit) { var hitEntity = hit as IMyEntity; var hitCablePort = hit.FatBlock.GameLogic.GetAs <Cables.CablePort>(); // if hit port is unoccupied if (hitCablePort.cable == null) { MyAPIGateway.Utilities.ShowNotification("hit port unoccupied"); // if welder is unoccupied if (cable == null) { MyAPIGateway.Utilities.ShowNotification("creating new cable"); // new cable cable = new Cable(); MyLog.Default.WriteLine("Tool: connect cable to self"); cable.connectToHead(hitCablePort); cable.connectToTail(wrenchCablePort); //CableSession.Instance.registerCable(cable); } // elif welder is already holding cable // - connect to new port else { MyLog.Default.WriteLine("Tool: connect cable to cable"); cable.connectToTail(hitCablePort); cable = null; // free welder } } else { // TODO occupied port error MyAPIGateway.Utilities.ShowNotification("Port occupied"); } }
public void deregisterCable(Cable c) { cableDict.Remove(c.cableID); cableStorageDict.Remove(c.cableID); }
public void registerCable(Cable c) { MyLog.Default.WriteLine("registering cable"); cableDict.Add(c.cableID, c); cableStorageDict.Add(c.cableID, c.storage); }
public void connectCable(Cable c) { cable = c; }
public void breakCable() { cable = null; }