//Idle Drone function void Idle() { //If Auto Home enabled then return home if not within buffer range. if (Vector3.DistanceSquared(_homeLoc, Me.GetPosition()) > distanceBuffer * distanceBuffer && autoHome) { ReturnHome(); return; } else { if (modeIndicator != null) { modeIndicator.SetValue <Color>("Color", new Color(1f, 1f, 0f)); } EchoToLCD("Status: Idle"); if (_patrolEnabled && !MissingOrDamaged()) { Patrol(); } else { StopPatrol(); ResetTargets(); //resets any target info if (_remoteBlock != null) { _remoteBlock.SetAutoPilotEnabled(false); _remoteBlock.FlightMode = FlightMode.OneWay; _remoteBlock.ClearWaypoints(); } } } }
public static void setColor(List <IMyInteriorLight> lights, Color color) { for (int i = 0; i < lights.Count; i++) { IMyInteriorLight light = lights[i]; light.SetValue <Color>("Color", color); } }
void UpdateIndicator() { if (indicator == null) { return; } indicator.SetValue("Color", indicators[numOccupied]); indicator.ApplyAction("OnOff_On"); }
public HangarController(IMyGridTerminalSystem grid, IMyProgrammableBlock me, Action <string> echo, TimeSpan elapsedTime) { GridTerminalSystem = grid; Echo = echo; ElapsedTime = elapsedTime; Me = me; hangarDoors = new List <IMyDoor> [groups.Count]; interiorDoors = new List <IMyDoor> [groups.Count]; exteriorDoors = new List <IMyDoor> [groups.Count]; soundBlocks = new List <IMySoundBlock> [groups.Count]; warningLights = new List <IMyInteriorLight> [groups.Count]; airVents = new List <IMyAirVent> [groups.Count]; hangarOpen = new Boolean[groups.Count]; // Get list of groups on this station/ship List <IMyBlockGroup> BlockGroups = new List <IMyBlockGroup>(); GridTerminalSystem.GetBlockGroups(BlockGroups); // Search all groups that exist for the groups with name as specified in groups list for (int i = 0; i < BlockGroups.Count; i++) { int pos = groups.IndexOf(BlockGroups[i].Name); // If name is one of our candidates... if (pos != -1) { List <IMyTerminalBlock> blocks = BlockGroups[i].Blocks; // Define list of blocks for each group List <IMyDoor> hangarDoorList = new List <IMyDoor>(); List <IMyDoor> interiorDoorList = new List <IMyDoor>(); List <IMyDoor> exteriorDoorList = new List <IMyDoor>(); List <IMySoundBlock> soundBlockList = new List <IMySoundBlock>(); List <IMyInteriorLight> warningLightList = new List <IMyInteriorLight>(); List <IMyAirVent> airVentList = new List <IMyAirVent>(); // Go through all blocks and add to appropriate list // Also initialize to a sane known state e.g. closed, on... for (int j = 0; j < blocks.Count; j++) { IMyTerminalBlock block = blocks[j]; String blockType = block.DefinitionDisplayNameText; String blockName = block.CustomName; block.ApplyAction("OnOff_On"); if (blockType.Equals("Airtight Hangar Door")) { IMyDoor item = block as IMyDoor; item.ApplyAction("Open_Off"); hangarDoorList.Add(item); } else if ((blockType.Equals("Sliding Door") || blockType.Equals("Door")) && blockName.Contains("Interior")) { IMyDoor item = block as IMyDoor; item.ApplyAction("Open_Off"); interiorDoorList.Add(item); } else if ((blockType.Equals("Sliding Door") || blockType.Equals("Door")) && blockName.Contains("Exterior")) { IMyDoor item = block as IMyDoor; item.ApplyAction("Open_Off"); exteriorDoorList.Add(item); } else if (blockType.Equals("Sound Block")) { IMySoundBlock item = block as IMySoundBlock; item.ApplyAction("StopSound"); item.SetValueFloat("LoopableSlider", 10); soundBlockList.Add(item); } else if (blockType.Equals("Interior Light")) { IMyInteriorLight item = block as IMyInteriorLight; item.ApplyAction("OnOff_Off"); item.SetValueFloat("Blink Interval", 1); item.SetValueFloat("Blink Lenght", 50); item.SetValueFloat("Blink Offset", 0); item.SetValue <Color>("Color", Color.Red); warningLightList.Add(item); } else if (blockType.Contains("Air Vent")) { IMyAirVent item = block as IMyAirVent; item.ApplyAction("Depressurize_Off"); airVentList.Add(item); } } // Some cleanup hangarDoorList.TrimExcess(); interiorDoorList.TrimExcess(); exteriorDoorList.TrimExcess(); soundBlockList.TrimExcess(); warningLightList.TrimExcess(); airVentList.TrimExcess(); if (hangarDoorList.Count == 0) { Echo("Warning: no hangar doors detected for " + BlockGroups[i].Name); } else if (interiorDoorList.Count == 0) { Echo("Warning: no interior doors detected for " + BlockGroups[i].Name); } else if (soundBlockList.Count == 0) { Echo("Warning: no sound blocks detected for " + BlockGroups[i].Name); } else if (warningLightList.Count == 0) { Echo("Warning: no warning lights detected for " + BlockGroups[i].Name); } else if (airVentList.Count == 0) { Echo("Warning: no air vents detected for " + BlockGroups[i].Name); } // Now that we have populated lists add them to the correct position in the group list hangarDoors[pos] = hangarDoorList; interiorDoors[pos] = interiorDoorList; exteriorDoors[pos] = exteriorDoorList; soundBlocks[pos] = soundBlockList; warningLights[pos] = warningLightList; airVents[pos] = airVentList; hangarOpen[pos] = false; // Exterior doors have been requested to close so we set a check to lock them when they are in fact closed requests.Add(new requestTicket(pos, "lockExteriorDoors")); } } }