/// <summary> /// Tests for a connection from this radio to another radio. /// </summary> /// <param name="other">The radio that may be connected.</param> public RelayNode.CommunicationType TestConnection(ComponentRadio other) { if (!IsWorking || !other.IsWorking) { return(RelayNode.CommunicationType.None); } if (!CanBroadcastData || !other.CanReceive) { return(RelayNode.CommunicationType.None); } float distSquared = Vector3.DistanceSquared(Entity.GetPosition(), other.Entity.GetPosition()); if (distSquared > Radius * Radius) { return(RelayNode.CommunicationType.None); } if (!CanReceive || !other.CanBroadcastData) { return(RelayNode.CommunicationType.OneWay); } if (distSquared > other.Radius * other.Radius) { return(RelayNode.CommunicationType.OneWay); } return(RelayNode.CommunicationType.TwoWay); }
/// <summary> /// Create a NetworkNode for a missile. Update100() will have to be invoked by GuidedMissile. /// </summary> public RelayNode(IMyEntity missile, Func <long> ownerId, ComponentRadio radio) { this.m_debugName = missile.getBestName; this.m_ownerId = ownerId; this.m_entity = missile; this.m_comp_radio = radio; Registrar.Add(missile, this); }
/// <summary> /// Creates a NetworkNode for a character, checking radio communication. /// </summary> /// <param name="character">The character to create the NetworkNode for.</param> public RelayNode(IMyCharacter character) { IMyPlayer player = character.GetPlayer_Safe(); this.m_debugName = () => player.DisplayName; this.m_ownerId = () => player.IdentityId; this.m_entity = character as IMyEntity; this.m_player = player; this.m_comp_radio = ComponentRadio.CreateRadio(character); Registrar.Add(character as IMyEntity, this); }
/// <summary> /// Creates a NetworkNode for a block, checking block attachments, laser, and radio communication. /// </summary> /// <param name="block">The block to create the NetworkNode for.</param> public RelayNode(IMyCubeBlock block) { this.m_loggingName = () => block.DisplayNameText; this.m_logger = new Logger(GetType().Name, block) { MinimumLevel = Logger.severity.INFO }; this.m_ownerId = () => block.OwnerId; this.m_entity = block; this.m_comp_blockAttach = block; this.m_comp_radio = ComponentRadio.TryCreateRadio(block); Ingame.IMyLaserAntenna lAnt = block as Ingame.IMyLaserAntenna; if (lAnt != null) this.m_comp_laser = new ComponentLaser(lAnt); Registrar.Add(block, this); }
/// <summary> /// Tests if this radio is detected by another radio. /// </summary> /// <param name="other">The radio that may detect this one.</param> /// <returns>True iff the other radio detects this one.</returns> public bool CanBroadcastPositionTo(ComponentRadio other) { if (!IsWorking || !other.IsWorking) { return(false); } if (!CanBroadcastPosition || !other.CanReceive) { return(false); } float distSquared = Vector3.DistanceSquared(Entity.GetPosition(), other.Entity.GetPosition()); return(distSquared <= Radius * Radius); }
/// <summary> /// Creates a NetworkNode for a block, checking block attachments, laser, and radio communication. /// </summary> /// <param name="block">The block to create the NetworkNode for.</param> public RelayNode(IMyCubeBlock block) { this.m_debugName = () => block.DisplayNameText; this.m_ownerId = () => block.OwnerId; this.m_entity = block; this.m_comp_blockAttach = block; this.m_comp_radio = ComponentRadio.TryCreateRadio(block); IMyLaserAntenna lAnt = block as IMyLaserAntenna; if (lAnt != null) { this.m_comp_laser = lAnt; } Registrar.Add(block, this); }
/// <summary> /// Create a NetworkNode for a missile. Update100() will have to be invoked by GuidedMissile. /// </summary> public RelayNode(IMyEntity missile, Func<long> ownerId, ComponentRadio radio) { this.m_loggingName = missile.getBestName; this.m_logger = new Logger(GetType().Name, missile) { MinimumLevel = Logger.severity.INFO }; this.m_ownerId = ownerId; this.m_entity = missile; this.m_comp_radio = radio; Registrar.Add(missile, this); }
/// <summary> /// Creates a NetworkNode for a character, checking radio communication. /// </summary> /// <param name="character">The character to create the NetworkNode for.</param> public RelayNode(IMyCharacter character) { IMyPlayer player = character.GetPlayer_Safe(); this.m_loggingName = () => player.DisplayName; this.m_logger = new Logger(GetType().Name, this.m_loggingName) { MinimumLevel = Logger.severity.INFO }; this.m_ownerId = () => player.PlayerID; this.m_entity = character as IMyEntity; this.m_player = player; this.m_comp_radio = ComponentRadio.CreateRadio(character); Registrar.Add(character as IMyEntity, this); }
/// <summary> /// Tests for a connection from this radio to another radio. /// </summary> /// <param name="other">The radio that may be connected.</param> public RelayNode.CommunicationType TestConnection(ComponentRadio other) { if (!IsWorking || !other.IsWorking) return RelayNode.CommunicationType.None; if (!CanBroadcastData || !other.CanReceive) return RelayNode.CommunicationType.None; float distSquared = Vector3.DistanceSquared(Entity.GetPosition(), other.Entity.GetPosition()); if (distSquared > Radius * Radius) return RelayNode.CommunicationType.None; if (!CanReceive || !other.CanBroadcastData) return RelayNode.CommunicationType.OneWay; if (distSquared > other.Radius * other.Radius) return RelayNode.CommunicationType.OneWay; return RelayNode.CommunicationType.TwoWay; }
/// <summary> /// Tests if this radio is detected by another radio. /// </summary> /// <param name="other">The radio that may detect this one.</param> /// <returns>True iff the other radio detects this one.</returns> public bool CanBroadcastPositionTo(ComponentRadio other) { if (!IsWorking || !other.IsWorking) return false; if (!CanBroadcastPosition || !other.CanReceive) return false; float distSquared = Vector3.DistanceSquared(Entity.GetPosition(), other.Entity.GetPosition()); return distSquared <= Radius * Radius; }