Exemple #1
0
        public void UpdateAfterSimulation100()
        {
            try
            {
                if (!myRadioAntenna.IsWorking)
                {
                    return;
                }

                //Showoff.doShowoff(CubeBlock, myLastSeen.Values.GetEnumerator(), myLastSeen.Count);

                float radiusSquared;
                MyObjectBuilder_RadioAntenna antBuilder = CubeBlock.GetObjectBuilderCubeBlock() as MyObjectBuilder_RadioAntenna;
                if (!antBuilder.EnableBroadcasting)
                {
                    radiusSquared = 0;
                }
                else
                {
                    radiusSquared = myRadioAntenna.Radius * myRadioAntenna.Radius;
                }

                // send antenna self to radio antennae
                LinkedList <RadioAntenna> canSeeMe = new LinkedList <RadioAntenna>();               // friend and foe alike
                foreach (RadioAntenna ant in RadioAntenna.registry)
                {
                    if (CubeBlock.canSendTo(ant.CubeBlock, false, radiusSquared, true))
                    {
                        canSeeMe.AddLast(ant);
                    }
                }

                LastSeen self = new LastSeen(CubeBlock.CubeGrid);
                foreach (RadioAntenna ant in canSeeMe)
                {
                    ant.receive(self);
                }

                // relay information to friendlies
                foreach (RadioAntenna ant in value_registry)
                {
                    if (CubeBlock.canSendTo(ant.CubeBlock, true, radiusSquared, true))
                    {
                        foreach (LastSeen seen in myLastSeen.Values)
                        {
                            ant.receive(seen);
                        }
                        foreach (Message mes in myMessages)
                        {
                            ant.receive(mes);
                        }
                    }
                }

                Receiver.sendToAttached(CubeBlock, myLastSeen);
                Receiver.sendToAttached(CubeBlock, myMessages);

                UpdateEnemyNear();
            }
            catch (Exception e)
            { myLogger.log("Exception: " + e, "UpdateAfterSimulation100()", Logger.severity.ERROR); }
        }
Exemple #2
0
 public static bool IsOpen(this Receiver receiver)
 {
     return(receiver != null && receiver.CubeBlock != null && !receiver.CubeBlock.Closed);
 }