示例#1
0
        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");
            }
        }
示例#2
0
 public void deregisterCable(Cable c)
 {
     cableDict.Remove(c.cableID);
     cableStorageDict.Remove(c.cableID);
 }
示例#3
0
 public void registerCable(Cable c)
 {
     MyLog.Default.WriteLine("registering cable");
     cableDict.Add(c.cableID, c);
     cableStorageDict.Add(c.cableID, c.storage);
 }
示例#4
0
 public void connectCable(Cable c)
 {
     cable = c;
 }
示例#5
0
 public void breakCable()
 {
     cable = null;
 }