Example #1
0
            public Spaceship(IMyGridTerminalSystem system, IMyIntergridCommunicationSystem igc)
            {
                this.system = system;
                this.igc    = igc;

                cpu = FindRunningPB(system);

                control   = FindBlockOfType <IMyRemoteControl>(system, this, Settings.TAG);
                connector = FindBlockOfType <IMyShipConnector>(system, this, Settings.TAG);
                debug     = FindBlockOfType <IMyTextPanel>(system, this, Settings.TAG);
                if (debug == null)
                {
                    IMyCockpit cockpit = FindBlockOfType <IMyCockpit>(system, this, Settings.TAG);
                    if (cockpit.SurfaceCount > 0)
                    {
                        debug = cockpit.GetSurface(0);
                    }
                }
                debug.Font        = "Monospace";
                debug.ContentType = ContentType.TEXT_AND_IMAGE;

                /*
                 *  screen = cockpit.GetSurface(0);
                 *  screen.ContentType = ContentType.SCRIPT;
                 *  MySpriteDrawFrame frame = screen.DrawFrame();
                 *
                 *
                 *  frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(0, 0), new Vector2(512, 512), Color.Black));
                 *  frame.Add(MySprite.CreateText("Ftiaxe Me!!!", "DEBUG", Color.White));
                 *  frame.Dispose();
                 */

                listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL);
                listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL);
                listener.SetMessageCallback(Settings.COMM_CHANNEL);
                thrusters = new ThrustersManager(this, control, system);

                autopilot = new Autopilot(this, control, FindBlockOfType <IMyGyro>(system, this));
                cas       = new CollisionAvoidanceSystem(this);
                fd        = new FlightDirector(this);

                if (connector.Status == MyShipConnectorStatus.Connected)
                {
                    flags = SpaceshipFlags.Dock;
                }
                else
                {
                    flags = SpaceshipFlags.Idle;
                }
            }
 public Communication(IMyProgrammableBlock pb, IMyIntergridCommunicationSystem igc)
 {
     this.igc          = igc;
     broadcastListener = igc.RegisterBroadcastListener(listenerId);
     unicastListener   = igc.UnicastListener;
     this.pb           = pb;
 }
        public GreedleManager(IMyIntergridCommunicationSystem IGC, IMyTextSurface outputSurface)
        {
            this.IGC = IGC;
            this.responseListener = IGC.RegisterBroadcastListener("greedle_response");
            this.responseListener.SetMessageCallback("Message Callback");
            this.greedles      = new List <Greedle>();
            this.outputSurface = outputSurface;

            commandTree = new PanelCommander.CommandTree()
            {
                label    = "Greedle Commands",
                commands = new List <PanelCommander.Command>()
                {
                    new PanelCommander.Command()
                    {
                        label = "List", action = ListGreedles
                    },
                    new PanelCommander.Command()
                    {
                        label = "Check For Greedle Updates", action = CheckForUpdates
                    }
                },
                subtrees = new List <PanelCommander.CommandTree>(),
            };
            ListGreedles();
        }
Example #4
0
            public InterGridComms(IMyIntergridCommunicationSystem comms, IngameTime time, IMyProgrammableBlock me)
            {
                commands       = new Dictionary <string, Action <object> >();
                keepaliveChann = comms.RegisterBroadcastListener("ServerKeepAlive");

                this.comms = comms;
                this.time  = time;
                this.me    = me;
            }
Example #5
0
        /// <summary>
        /// Registers an ICommand handler
        /// </summary>
        /// <typeparam name="TCommand">Type of command</typeparam>
        /// <param name="handler">Handler</param>
        /// <param name="acceptBroadcasts">Should we register a broadcast listener?</param>
        /// <typeparam name="TCommand"></typeparam>
        public void RegisterHandler <TCommand>(ICommandHandler handler, bool acceptBroadcasts = false) where TCommand : ICommand, new()
        {
            RegisterParser <TCommand>();
            var messageType = new TCommand().Tag;

            if (CommandHandlers.ContainsKey(messageType))
            {
                throw new ArgumentException($"A cmd-handler for tag {messageType} is already registered");
            }
            CommandHandlers.Add(messageType, handler);
            if (acceptBroadcasts)
            {
                broadcastListeners.Add(IGC.RegisterBroadcastListener(messageType));
            }
        }
Example #6
0
 public void SetupFleetListener()
 {
     IGC.RegisterBroadcastListener("fleet");
 }