Exemplo n.º 1
0
		/// <summary>
		/// Copies all LastSeen and Messages to the other Receiver. Does not check if a connection is possible.
		/// Removes all invalid LastSeen and Message
		/// </summary>
		/// <param name="other">Receiving receiver</param>
		protected void Relay(ReceiverBlock other)
		{
			ForEachLastSeen(seen => {
				other.Receive(seen);
				return false;
			});

			ForEachMessage(msg => {
				other.Receive(msg);
				return false;
			});
		}
Exemplo n.º 2
0
		/// <summary>
		/// Search for an attached antenna, if we do not have one.
		/// </summary>
		/// <returns>true iff current antenna is valid or one was found</returns>
		private bool findAntenna()
		{
			if (myAntenna.IsOpen()) // already have one
				return true;

			myAntenna = null;
			Registrar.ForEach((RadioAntenna antenna) => {
				if (antenna.CubeBlock.canSendTo(CubeBlock, true))
				{
					myLogger.debugLog("found antenna: " + antenna.CubeBlock.DisplayNameText, "searchForAntenna()", Logger.severity.INFO);
					myAntenna = antenna;
					return true;
				}
				myLogger.debugLog(CubeBlock.gridBlockName() + " cannot fetch from " + antenna.CubeBlock.gridBlockName(), "searchForAntenna()", Logger.severity.TRACE);
				return false;
			});

			if (myAntenna != null)
				return true;

			Registrar.ForEach((LaserAntenna antenna) => {
				if (antenna.CubeBlock.canSendTo(CubeBlock, true))
				{
					myLogger.debugLog("found antenna: " + antenna.CubeBlock.DisplayNameText, "searchForAntenna()", Logger.severity.INFO);
					myAntenna = antenna;
					return true;
				}
				myLogger.debugLog(CubeBlock.gridBlockName() + " cannot fetch from " + antenna.CubeBlock.gridBlockName(), "searchForAntenna()", Logger.severity.TRACE);
				return false;
			});

			return myAntenna != null;
		}