public IMyRadioAntenna GetActiveAntenna() { IMyRadioAntenna resultAntenna = null; float range = 0; for (int i = Antennas.Count - 1; i >= 0; i--) { var antenna = Antennas[i]; if (!CheckBlockValid(antenna)) { Antennas.RemoveAt(i); continue; } if (antenna.IsWorking == false || antenna.IsFunctional == false) { continue; } return(antenna); } return(resultAntenna); }
public void Setup() { // Cockpit List <IMyTerminalBlock> cockpitListReferences = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(CockpitTag, cockpitListReferences); if (cockpitListReferences.Count == 0) { throw new Exception("No cockpit found! Check the naming tag."); } CockpitBlock = (IMyShipController)cockpitListReferences[0]; ReferenceBlock = cockpitListReferences[0]; // Antenna List <IMyTerminalBlock> antennaListReferences = new List <IMyTerminalBlock>(); GridTerminalSystem.SearchBlocksOfName(AntennaTag, antennaListReferences); if (antennaListReferences.Count == 0) { throw new Exception("No ILS Receiver Antenna! Check naming tag."); } Antenna = (IMyRadioAntenna)antennaListReferences[0]; IGC.RegisterBroadcastListener(ILSAntennaChannel); IGC.RegisterBroadcastListener(VORAntennaChannel); IGC.RegisterBroadcastListener(NDBAntennaChannel); // Mark setup as completed. SetupComplete = true; Echo("Setup complete."); }
public IMyRadioAntenna GetAntennaWithHighestRange(string antennaName = "") { IMyRadioAntenna resultAntenna = null; float range = 0; for (int i = Antennas.Count - 1; i >= 0; i--) { var antenna = Antennas[i]; if (!CheckBlockValid(antenna)) { Antennas.RemoveAt(i); continue; } if (antenna.IsWorking == false || antenna.IsFunctional == false || antenna.IsBroadcasting == false) { continue; } if (!string.IsNullOrWhiteSpace(antennaName) && antennaName != antenna.CustomName) { continue; } if (antenna.Radius > range) { resultAntenna = antenna; range = antenna.Radius; } } return(resultAntenna); }
protected virtual bool LoadBlocks() { bool isSuccess = true; List <IMyShipController> lstController = new List <IMyShipController>(); p.GridTerminalSystem.GetBlocksOfType(lstController); if (lstController.Count <= 0) { LOGGER.Warn("No Controller ship available"); } else { controller = lstController.First(); } List <IMyRadioAntenna> lstAntennas = new List <IMyRadioAntenna>(); p.GridTerminalSystem.GetBlocksOfType(lstAntennas); if (lstAntennas.Count == 0) { // FATAL no antenna aviable LOGGER.Error("No Antenna available"); isSuccess = false; } else { antenna = lstAntennas.First(); } return(isSuccess); }
public ComModule(Program par, IMyRadioAntenna ant, string name) { parent = par; antenna = ant; ownName = name; init(); }
public ACPWrapper(Program p, IMyRadioAntenna antenna) { CommonInit(p); this.antenna = antenna; Ping(); }
// END SCRIPT CONFIGURATION public Program() { if (this.transmode) { Echo("\nInitialising GarageDoor opener as transceiver."); } else { Echo("\nInitialising GarageDoor opener as receiver."); } antenna = (IMyRadioAntenna)GridTerminalSystem.GetBlockWithName(this.antennaName); keys = new List <String>(); String[] storedData = Storage.Split(';'); if (storedData.Length > 0) { Echo("\nRecovering stored Data"); foreach (String s in storedData) { this.keys.Add(s); } } }
public Radio() { antenna = gts.GetBlockWithName("Antenna") as IMyRadioAntenna; igc.RegisterBroadcastListener(CHANNEL_TAG); igc.GetBroadcastListeners(listeners); targetpos = new Vector3D(); }
//IMyGridProgramRuntimeInfo runtimeInfo = null; public Program() //constructor is called when you "compile" script ingame { deltaT = Runtime.TimeSinceLastRun.TotalSeconds; //runtimeInfo.TimeSinceLastRun.TotalSeconds; List <IMyRemoteControl> controllers = new List <IMyRemoteControl>(); GridTerminalSystem.GetBlocksOfType <IMyRemoteControl>(controllers); controller = controllers[0];//lazilly assuming 1 RC for now List <IMyRadioAntenna> antennas = new List <IMyRadioAntenna>(); GridTerminalSystem.GetBlocksOfType <IMyRadioAntenna>(antennas); antenna = antennas[0]; thrusters = new List <IMyThrust>(); GridTerminalSystem.GetBlocksOfType <IMyThrust>(thrusters); maxTotalEffectiveThrust = 0.0f; numThrusters = thrusters.Count; freefallThreshold = 10.0f; craftHeight = 5.0f; touchdownHeight = craftHeight + 1;//adding wiggle room because craft tends to bounce and code the inputs don't always capture that stage = 0; Storage = stage + ";";; Echo($"Code Initialized"); Runtime.UpdateFrequency = UpdateFrequency.Update1;//once run, this script needs to control the craft actively }
private void AntennaCheck() { if (Antennas.Count == 0) { Echo("AntennaCheck:\nNo antennas found."); return; } ; Echo("AntennaCheck"); Echo($"Found {Antennas.Count} Antennas."); bool AnyAntennasEnabled = false; foreach (IMyRadioAntenna Antenna in Antennas) { if (Antenna.Enabled && Antenna.EnableBroadcasting) { AnyAntennasEnabled = true; break; } } if (!AnyAntennasEnabled) { IMyRadioAntenna Antenna = (Antennas[0]); Antenna.EnableBroadcasting = true; Antenna.Enabled = true; } }
public static IMyRadioAntenna GetAntennaWithHighestRange(List <IMyRadioAntenna> antennaList, string antennaName = "") { IMyRadioAntenna resultAntenna = null; float range = 0; foreach (var antenna in antennaList) { if (antenna == null || MyAPIGateway.Entities.Exist(antenna?.SlimBlock?.CubeGrid) == false) { continue; } if (antenna.IsWorking == false || antenna.IsFunctional == false || antenna.IsBroadcasting == false) { continue; } if (!string.IsNullOrWhiteSpace(antennaName) && antennaName != antenna.CustomName) { continue; } if (antenna.Radius > range) { resultAntenna = antenna; range = antenna.Radius; } } return(resultAntenna); }
public Program() { //gets all programmable blocks, where the block's name starts with "Dock" int hangarCount = GetAllHangars(); Echo(String.Format("Found {0} Hangar Controllers", hangarCount)); antenna = GridTerminalSystem.GetBlockWithName("Dock Request Antenna") as IMyRadioAntenna; //TODO: Remove specific name requrement if (antenna != null) { antenna.AttachedProgrammableBlock = Me.EntityId; listener = IGC.RegisterBroadcastListener(MESSAGE_TAG); listener.SetMessageCallback("REQUEST_WAITING"); } logger = GridTerminalSystem.GetBlockWithName("LCD Logger") as IMyTextPanel; Echo(string.Format("ANTENNA FOUND: {0}", antenna != null)); Echo(string.Format("LOGGER FOUND: {0}", logger != null)); if (logger == null) { logger = Me.GetSurface(0); } logger.ContentType = ContentType.TEXT_AND_IMAGE; logger.FontSize = FONT_SIZE; string loggerText = logger.GetText(); if (!loggerText.Contains("DOCKING LOG")) { Echo("LOGGER TEXT DOES NOT INCLUDE HEADER. Only Found:\n" + loggerText); logger.WriteText(LOGGER_HEADER); } }
/// <summary> /// Tries to create a radio component for an entity. Creates the radio component if the entity is a radio antenna block, beacon block, or a character. /// </summary> /// <param name="obj">Entity to create the component for.</param> /// <returns>A new radio component for the entity, if it can be created. Null, otherwise.</returns> public static ComponentRadio TryCreateRadio(IMyEntity obj) { IMyRadioAntenna radioAnt = obj as IMyRadioAntenna; if (radioAnt != null) { return(new CR_AntennaBlock(radioAnt)); } IMyBeacon beacon = obj as IMyBeacon; if (beacon != null) { return(new CR_BeaconBlock(beacon)); } IMyCharacter character = obj as IMyCharacter; if (character != null) { return(new CR_Character(character)); } return(null); }
private bool CollectParts(IMyTerminalBlock block) { if (!Me.IsSameConstructAs(block)) { return(false); } if (block.CustomName == null) { block.CustomName = block.Name; } if (!block.CustomName.StartsWith($"({tag})")) { block.CustomName = $"({tag}) {block.CustomName}"; } if (block is IMyShipConnector) { connector = (IMyShipConnector)block; } if (block is IMyRadioAntenna) { antenna = (IMyRadioAntenna)block; } if (block is IMyProgrammableBlock && block.CustomName == $"({tag}) {dockingManagerName}") { dockingManager = (IMyProgrammableBlock)block; } if (block is IMyProgrammableBlock && block.CustomName == $"({tag}) {autopilotName}") { autopilotManager = (IMyProgrammableBlock)block; } return(false); }
private static void OnEntityAdd(IMyEntity entity) { try { IMyCubeGrid spawnedGrid = entity as IMyCubeGrid; if (spawnedGrid == null || spawnedGrid.IsRespawnGrid || spawnedGrid.Physics == null) { return; } List <IMySlimBlock> slimBlocks = new List <IMySlimBlock>(); spawnedGrid.GetBlocks(slimBlocks, x => x.FatBlock is IMyTerminalBlock); foreach (IMySlimBlock block in slimBlocks.ToList()) { if (block.FatBlock.GetType() != typeof(MyObjectBuilder_RadioAntenna)) { continue; } IMyRadioAntenna antenna = block.FatBlock as IMyRadioAntenna; if (antenna == null || antenna.Enabled) { return; } antenna.EnabledChanged += CallHelpRegister; } } catch (Exception e) { Core.GeneralLog.WriteToLog("Drones: OnEntityAdd", $"OnEntityAdd interrupted - exception:\t{e}"); } }
bool FuncTest(IMyRadioAntenna block) { IMyRadioAntenna radioAntenna = block; //Parent: IMyFunctionalBlock float Radius = radioAntenna.Radius; return(true); }
public static HashSet <IMyEntity> CalculateAntennaRecievers(this IMyRadioAntenna antenna, bool allowEnemy) { var tmp = new HashSet <IMyEntity>(); var result = new HashSet <IMyEntity>(); antenna.CalculateAntennaRecievers(antenna, tmp, result, allowEnemy); return(result); }
//SCRIPTINPUT (FS) public ComModule(Program par, IMyRadioAntenna ant, string name, bool antennaOn) { parent = par; antenna = ant; ownName = name; antennaAlwaysOn = antennaOn; init(); }
public void LowPriority(IMyRadioAntenna radio, string to, string from, string options, string message, MyTransmitTarget transmitTarget = MyTransmitTarget.Default, bool append = false, char seperator = ';') { List <IMyRadioAntenna> radios = new List <IMyRadioAntenna> { radio }; OutGoingMessage(ref lowPriority, radios, to, from, options, message, transmitTarget, append, seperator); }
public CR_AntennaBlock(IMyRadioAntenna antenna) { this.m_antenna = antenna; if (s_prop_broadcasting == null) { s_prop_broadcasting = antenna.GetProperty("EnableBroadCast").AsBool(); } }
bool CollectParts(IMyTerminalBlock block, IMyCubeBlock reference) { if (reference.CubeGrid.EntityId != block.CubeGrid.EntityId) { return(false); } if (block is IMyGyro) { Drive.AddGyro((IMyGyro)block); } if (block is IMySmallGatlingGun) { Gats.Add((IMySmallGatlingGun)block); } if (block is IMyCameraBlock) { Cameras.Add((IMyCameraBlock)block); } if (block is IMyMotorStator) { TurretRotor = (IMyMotorStator)block; } if (block is IMyLargeTurretBase) { Designator = (IMyLargeTurretBase)block; } if (block is IMyThrust) { Drive.AddEngine(new HoverEngineDriver((IMyThrust)block)); } if (block is IMyRadioAntenna) { Antenna = (IMyRadioAntenna)block; } if (block is IMyBeacon) { ((IMyBeacon)block).Enabled = false; } if (block is IMyShipController) { Controller = (IMyShipController)block; Controller.TryGetPlanetPosition(out PlanetPos); Drive.Controller = Controller; } return(false); }
void FactoryReset() { antenna = null; dockingManager = null; autopilotManager = null; connector = null; ResetParts(); this.tag = string.Empty; currentState = ScriptState.Uninitialized; }
public CommsHandler(Program parent, IMyRadioAntenna antenna) { this.parent = parent; if (antenna != null) { acpWrapper = new ACPWrapper(parent, antenna); } commands = new Dictionary <string, Action <List <string>, long> >(); }
public Antenna(IMyRadioAntenna radioAntenna) : this() { if (radioAntenna == null) { throw new Exception("radioAntenna cannot be null!"); } this.radioAntenna = radioAntenna; type = antennaType.radioAntenna; }
public RadioMessage(IMyRadioAntenna radio, string to, string from, string options, string message, MyTransmitTarget transmitTarget = MyTransmitTarget.Default, char seperator = ';') { Radio = radio; To = to; From = from; Options = options; Message = message; TransmitTarget = transmitTarget; Seperator = seperator; }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { base.Init(objectBuilder); try{ Antenna = Entity as IMyRadioAntenna; NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; }catch (Exception exc) { } }
private void init() { controller = getMainCockpit(); brake = fillLightList("lights brake"); reverse = fillLightList("lights reverse"); spotlights = fillSpotlightList("spotlights"); wheels = getWheels(); connectors = getConnectors(); antenna = getAntenna(); //load some ini for wheel strength, max weight, color values }
/// <summary> /// Attempts to initialize the protocol /// </summary> /// <param name="runtime">runtime object</param> /// <param name="antennas">antennas array</param> /// <param name="transmissionMode">transmission mode</param> /// <param name="localName">local id, must be between 1 and 99 characters long</param> /// <param name="sendLimit">send limit per packet, if a packet is attempted to be sent more than this value, the associated connection is terminated [default=5]</param> /// <param name="sendTimeoutMs">time to wait between attempting packet retransmission [default=400]</param> /// <param name="connectionAcceptor">connection acceptor delegate, decides whether to accept an incoming connection request, null causes any such connections to be rejected</param> /// <param name="connectionListener">connection listener delegate, invoked when a new connection has been accepted, can be null</param> public static void Initialize(IMyGridProgramRuntimeInfo runtime, IMyRadioAntenna[] antennas, MyTransmitTarget transmissionMode, string localName, int sendLimit = 5, int sendTimeoutMs = 400, Func <string, byte, bool> connectionAcceptor = null, Action <IConnection> connectionListener = null) { if (m_connections == null) { if (runtime == null) { throw new Exception("runtime can not be null"); } if (antennas == null || antennas.Length == 0) { throw new Exception("antennas can not be null or have length of 0"); } if (localName == null || localName.Length <= 0 || localName.Length > 99) { throw new Exception("localName length must be between 1 and 9 inclusive"); } m_runtime = runtime; m_antennas = (IMyRadioAntenna[])antennas.Clone(); m_localID = localName; m_sendLimit = sendLimit <= 0 ? 1 : sendLimit; m_sendTimeoutMs = sendTimeoutMs < 0 ? 0 : sendTimeoutMs; m_connectionAcceptor = connectionAcceptor; m_connectionListener = connectionListener; m_connections = new List <StaticConnection>(); m_connections.Add(new StaticConnection()); m_transmissionMode = transmissionMode; m_localIDLength = m_localID.Length.ToString("00"); CurrentTime = sendTimeoutMs * 3;// just an arbitrary value above 0 for (int i = 0, l = m_antennas.Length; i < l; i++) { IMyRadioAntenna a = m_antennas[i]; if (transmissionMode == MyTransmitTarget.Owned) { a.IgnoreAlliedBroadcast = true; a.IgnoreOtherBroadcast = true; } else if (transmissionMode == MyTransmitTarget.Ally) { a.IgnoreAlliedBroadcast = false; a.IgnoreOtherBroadcast = true; } else if (transmissionMode == MyTransmitTarget.Enemy || transmissionMode == MyTransmitTarget.Everyone) { a.IgnoreAlliedBroadcast = false; a.IgnoreOtherBroadcast = false; } } } }
/* http://steamcommunity.com/sharedfiles/filedetails/?id=360966557 */ void Main() { List <IMyTerminalBlock> blocks = new List <IMyTerminalBlock>(); GridTerminalSystem.GetBlocksOfType <IMyRadioAntenna>(blocks); if (blocks.Count == 0) { return; } IMyRadioAntenna antenna = blocks[0] as IMyRadioAntenna; antenna.SetCustomName("Hello Galaxy!"); }
public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update1; info = GridTerminalSystem.GetBlockWithName("Lcd") as IMyTextPanel; brain = GridTerminalSystem.GetBlockWithName("controller") as IMyRemoteControl; GridTerminalSystem.GetBlocksOfType <IMyThrust>(term); antenna = GridTerminalSystem.GetBlockGroupWithName("receiver") as IMyRadioAntenna; gyro = GridTerminalSystem.GetBlockWithName("gyro") as IMyGyro; IGC.RegisterBroadcastListener("pack"); IGC.RegisterBroadcastListener("pack2"); IGC.GetBroadcastListeners(listeners); }