Esempio n. 1
0
        public CombatDrone()
        //////public Program()
        {
            shipComponents = new ShipComponents();
            LocateAllParts();
            log = new Logger(Me.CubeGrid, shipComponents);

            communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents);
            navigationSystems    = new NavigationSystem(log, Me.CubeGrid, shipComponents);
            productionSystems    = new ProductionSystem(log, Me.CubeGrid, shipComponents);
            storageSystem        = new StorageSystem(log, Me.CubeGrid, shipComponents);
            trackingSystems      = new TrackingSystem(log, Me.CubeGrid, shipComponents);
            weaponSystems        = new WeaponSystem(log, Me.CubeGrid, shipComponents);

            operatingOrder.AddLast(new TaskInfo(LocateAllParts));
            operatingOrder.AddLast(new TaskInfo(FollowOrders));
            operatingOrder.AddLast(new TaskInfo(SensorScan));
            operatingOrder.AddLast(new TaskInfo(AnalyzePlanetaryData));
            operatingOrder.AddLast(new TaskInfo(InternalSystemScan));
            //operatingOrder.AddLast(new TaskInfo(MaintainAltitude));
            operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets));
            operatingOrder.AddLast(new TaskInfo(FollowOrders));
            operatingOrder.AddLast(new TaskInfo(UpdateDisplays));
            maxCameraRange = 5000;
            maxCameraAngle = 80;

            //set new defaults
            hoverHeight = 100;
        }
Esempio n. 2
0
        public CombatDrone()
        //////public Program()
        {
            shipComponents = new ShipComponents();
            LocateAllParts();
            log = new Logger(Me.CubeGrid, shipComponents);

            communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents);
            navigationSystems    = new NavigationSystem(log, Me.CubeGrid, shipComponents);

            trackingSystems = new TrackingSystem(log, Me.CubeGrid, shipComponents, false);
            weaponSystems   = new WeaponSystem(log, Me.CubeGrid, shipComponents);

            operatingOrder.AddLast(new TaskInfo(LocateAllParts));
            operatingOrder.AddLast(new TaskInfo(InternalSystemCheck));
            operatingOrder.AddLast(new TaskInfo(NavigationCheck));
            operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages));
            operatingOrder.AddLast(new TaskInfo(SendPendingMessages));
            operatingOrder.AddLast(new TaskInfo(FollowOrders));
            operatingOrder.AddLast(new TaskInfo(ScanLocalArea));
            operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets));
            operatingOrder.AddLast(new TaskInfo(UpdateDisplays));
            operatingOrder.AddLast(new TaskInfo(FollowOrders));
            SetupFleetListener();

            maxCameraRange = 5000;
            maxCameraAngle = 80;

            //set new defaults
            hoverHeight             = 150;
            InitialBlockCount       = shipComponents.AllBlocks.Count();
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
Esempio n. 3
0
 AstronautControlPanel()
 {
     CommunicationSystem     comms       = new CommunicationSystem();
     ExperimentSystem        experiment  = new ExperimentSystem();
     FlightControlSystem     flight      = new FlightControlSystem();
     LifeSupportSystem       lifeSupport = new LifeSupportSystem();
     PowerDistributionSystem power       = new PowerDistributionSystem();
 }
Esempio n. 4
0
 public AIState(string name, AIPilot pilot)
 {
     this.name = name;
     this.pilot = pilot;
     this.entity = pilot.entity;
     this.transform = entity.transform;
     this.sensorSystem = entity.sensorSystem;
     this.engineSystem = entity.engineSystem;
     this.weaponSystem = entity.weaponSystem;
     this.commSystem = entity.commSystem;
     this.navSystem = entity.navSystem;
 }
Esempio n. 5
0
 public AISubstate(AIState parentState)
 {
     this.parentState = parentState;
     this.pilot = parentState.pilot;
     this.entity = parentState.pilot.entity;
     this.transform = entity.transform;
     this.sensorSystem = entity.sensorSystem;
     this.engineSystem = entity.engineSystem;
     this.weaponSystem = entity.weaponSystem;
     this.commSystem = entity.commSystem;
     this.navSystem = entity.navSystem;
 }
Esempio n. 6
0
        public MiningBase()
        //////public Program()
        {
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
            shipComponents          = new ShipComponents();
            LocateAllParts();
            SetupFleetListener();

            log = new Logger(Me.CubeGrid, shipComponents);

            communicationSystems = new CommunicationSystem(log, Me.CubeGrid, shipComponents);
            navigationSystems    = new BasicNavigationSystem(log, Me.CubeGrid, shipComponents);
            factorySystems       = new FactorySystem(log, Me.CubeGrid, shipComponents);
            trackingSystems      = new TrackingSystem(log, Me.CubeGrid, shipComponents, true);
            weaponSystems        = new WeaponSystem(log, Me.CubeGrid, shipComponents);

            operatingOrder.AddLast(new TaskInfo(LocateAllParts));
            operatingOrder.AddLast(new TaskInfo(NavigationCheck));

            operatingOrder.AddLast(new TaskInfo(InternalSystemCheck));
            operatingOrder.AddLast(new TaskInfo(ScanLocalArea));

            operatingOrder.AddLast(new TaskInfo(UpdateTrackedTargets));
            operatingOrder.AddLast(new TaskInfo(UpdateDisplays));

            operatingOrder.AddLast(new TaskInfo(RecieveFleetMessages));
            operatingOrder.AddLast(new TaskInfo(SendPendingMessages));

            operatingOrder.AddLast(new TaskInfo(MaintainAltitude));

            operatingOrder.AddLast(new TaskInfo(IssueOrders));

            //operatingOrder.AddLast(new TaskInfo(RunProductionRoutine));

            maxCameraRange = 5000;
            maxCameraAngle = 80;
            //set new defaults
            hoverHeight             = 400;
            InitialBlockCount       = shipComponents.AllBlocks.Count();
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
        }
Esempio n. 7
0
        public Main()
        {
            InitializeComponent();

            m_insight3D      = new Insight3D();
            m_insight3D.Dock = DockStyle.Fill;
            m_insight3DPanel.Controls.Add(m_insight3D);

            // We don't have a call placed yet.
            m_hangUpButton.Enabled = false;
            m_callPlaced           = false;

            // Load a texture which we will use for our phone locations.
            m_phoneTexture = SceneManager.Textures.FromUri(Path.Combine(Application.StartupPath, "Data/Markers/facility.png"));

            // Create a ServiceProviderDisplay to be used for visualization.
            m_display = new ServiceProviderDisplay();

            // Create the font to use for labeling. We are using the same font as the control, only smaller.
            m_labelFont = new Font(Font.FontFamily, 10, Font.Style, Font.Unit, Font.GdiCharSet, Font.GdiVerticalFont);

            // The call will be taking place at a frequency of 1620.5e6.
            m_intendedSignal = new IntendedSignalByFrequency(1620.5e6);

            // Create the transmitting phone that we will use for our call and add it to the display.
            m_transmittingPhone = CreateTransmittingPhone();
            m_display.ServiceProviders.Add(m_transmittingPhone);

            // Do the same for the receiving phone.
            m_receivingPhone = CreateReceivingPhone();
            m_display.ServiceProviders.Add(m_receivingPhone);

            // Create an instance of IridiumSatellite for each of the three satellites we will
            // be using and add them to the display.

            // IridiumSatellite is a Platform-based class that adds default graphics and a
            // Transceiver object for communication.

            var analysisDate = new JulianDate(new GregorianDate(2011, 8, 2, 18, 1, 0));

            var iridium49Tles = TwoLineElementSetHelper.GetTles("25108", analysisDate);
            var iridium49     = new IridiumSatellite("Iridium 49", iridium49Tles, m_labelFont, m_intendedSignal.TargetFrequency);

            m_display.ServiceProviders.Add(iridium49);

            var iridium58Tles = TwoLineElementSetHelper.GetTles("25274", analysisDate);
            var iridium58     = new IridiumSatellite("Iridium 58", iridium58Tles, m_labelFont, m_intendedSignal.TargetFrequency);

            m_display.ServiceProviders.Add(iridium58);

            var iridium4Tles = TwoLineElementSetHelper.GetTles("24796", analysisDate);
            var iridium4     = new IridiumSatellite("Iridium 4", iridium4Tles, m_labelFont, m_intendedSignal.TargetFrequency);

            m_display.ServiceProviders.Add(iridium4);

            // If the TLE epoch is too far from our expected analysis date, then we are
            // offline and loading cached data. Adjust the analysis date to match.
            if (iridium49Tles[0].Epoch.DaysDifference(analysisDate) > 5)
            {
                analysisDate = iridium49Tles[0].Epoch;
            }

            // Iridium 49 will be the receiving end of our caller's "uplink".
            // Modify the receiving antenna to be isotropic.
            iridium49.Transceiver.InputAntennaGainPattern = new IsotropicGainPattern();

            // Iridium 4 will be the transmitting end of our call receiver's "downlink".
            // Modify the transmitting antenna to be isotropic.
            iridium4.Transceiver.OutputAntennaGainPattern = new IsotropicGainPattern();

            // Now that we've created all of our definition objects, we need to build
            // the links between them that make up our communication system.
            m_communicationSystem = new CommunicationSystem();

            // Add a link for each hop in the chain.
            // This could have been accomplished with a single call to AddChain.
            // However, since we plan on further configuring each of the individual links
            // generated for us, we add them one at a time.

            var linkCollection = m_communicationSystem.Links;

            m_callerToIridium49UpLink    = linkCollection.Add("Uplink to Iridium 49", m_transmittingPhone, iridium49.Transceiver);
            m_iridium49To58Crosslink     = linkCollection.Add("Iridium 49 -> Iridium 58", iridium49.Transceiver, iridium58.Transceiver);
            m_iridium58To4Crosslink      = linkCollection.Add("Iridium 58 -> Iridium 4", iridium58.Transceiver, iridium4.Transceiver);
            m_iridium4ToReceiverDownLink = linkCollection.Add("Downlink from Iridium 4", iridium4.Transceiver, m_receivingPhone);

            // Now that we have the links, we can add an AccessConstraintsExtension to them so
            // that each link is only valid if they have line of sight to each other.
            var earth = CentralBodiesFacet.GetFromContext().Earth;

            var callerToIridium49Constraint = new CentralBodyObstructionConstraint(m_callerToIridium49UpLink, earth);

            m_callerToIridium49UpLink.Extensions.Add(new AccessConstraintsExtension(callerToIridium49Constraint));

            var iridium49To58Constraint = new CentralBodyObstructionConstraint(m_iridium49To58Crosslink, earth);

            m_iridium49To58Crosslink.Extensions.Add(new AccessConstraintsExtension(iridium49To58Constraint));

            var iridium58To4Constraint = new CentralBodyObstructionConstraint(m_iridium58To4Crosslink, earth);

            m_iridium58To4Crosslink.Extensions.Add(new AccessConstraintsExtension(iridium58To4Constraint));

            var iridium4ToReceiverConstraint = new CentralBodyObstructionConstraint(m_iridium4ToReceiverDownLink, earth);

            m_iridium4ToReceiverDownLink.Extensions.Add(new AccessConstraintsExtension(iridium4ToReceiverConstraint));

            m_linkComboBox.DisplayMember = "Name";
            m_linkComboBox.Items.Add(m_callerToIridium49UpLink);
            m_linkComboBox.Items.Add(m_iridium49To58Crosslink);
            m_linkComboBox.Items.Add(m_iridium58To4Crosslink);
            m_linkComboBox.Items.Add(m_iridium4ToReceiverDownLink);
            m_linkComboBox.SelectedItem = m_iridium4ToReceiverDownLink;

            // Even though we haven't added any link graphics yet, we will later, so add them
            // to the display now.
            m_display.ServiceProviders.Add(m_callerToIridium49UpLink);
            m_display.ServiceProviders.Add(m_iridium49To58Crosslink);
            m_display.ServiceProviders.Add(m_iridium58To4Crosslink);
            m_display.ServiceProviders.Add(m_iridium4ToReceiverDownLink);

            // While we have set the location for our two phones and the satellite
            // transceivers, what we haven't done is assign their orientations. This can be
            // done automatically using the ConfigureAntennaTargeting method. Note that
            // ConfigureAntennaTargeting is a best effort method and returns status information
            // in regards to any problems it encounters. We don't check them here
            // simply because we know it will succeed.
            m_communicationSystem.ConfigureAntennaTargeting();

            // Now that our initial configuration is complete, make sure we call ApplyChanges
            // on the display so that the visualization is created.
            m_display.ApplyChanges();

            // Update the display to the current time.
            m_display.Update(SceneManager.Time);

            // Set up the animation time for our call.
            var animation = new SimulationAnimation
            {
                StartTime  = analysisDate,
                EndTime    = analysisDate.AddMinutes(15.0),
                TimeStep   = Duration.FromSeconds(0.5),
                StartCycle = SimulationAnimationCycle.Loop,
                EndCycle   = SimulationAnimationCycle.Loop
            };

            SceneManager.Animation = animation;

            // Subscribe to the time changed event so we can update our display.
            SceneManager.TimeChanged += SceneManagerTimeChanged;

            // Reset to the beginning.
            animation.Reset();

            // Configure the animation toolbar that overlays the 3D view.
            OverlayToolbar animationToolbar = new OverlayToolbar(m_insight3D);

            animationToolbar.Overlay.Origin = ScreenOverlayOrigin.BottomCenter;

            // Zoom to a location that includes both the caller and receiver.
            m_insight3D.Scene.Camera.ViewExtent(earth,
                                                Trig.DegreesToRadians(39.6333), Trig.DegreesToRadians(11.1333),
                                                Trig.DegreesToRadians(77.5833), Trig.DegreesToRadians(12.9833));

            // Move the camera further back so that all satellites are visible.
            m_insight3D.Scene.Camera.Distance += 5000000.0;

            // Turn off lighting since it's the middle of the night and we want to be able to see everything,
            m_insight3D.Scene.Lighting.Enabled = false;

            // Create our link budget overlay helper which will display
            // the complete link budget for a selected link on top of the display.
            m_linkBudgetOverlayHelper = new LinkBudgetOverlayHelper(m_labelFont);

            //Hide it until the call is initiated
            m_linkBudgetOverlayHelper.Overlay.Display = false;

            // Add the actual overlay to Insight3D
            SceneManager.ScreenOverlays.Add(m_linkBudgetOverlayHelper.Overlay);
        }
Esempio n. 8
0
    // Use this for initialization
    void Start()
    {
        compileExpressionParser();


        //Knowledge update rate
        KnowledgeUpdateWindow.LoadFromFile();

        //Get goal
        goal = (CompoundTask)serializedGoal.DeSerialize(null);



        //Initialize knowledge

        foreach (SerializedFact fact in serializedKnowledge)
        {
            Atom newFact = new Atom(fact.name, fact.sign);

            foreach (string objName in fact.values)
            {
                newFact.addTerm(new Term(GameObject.Find(objName)));
            }

            state.addFact(newFact);
        }


        //Initialize variables


        foreach (SerializedVariable var in serializedDomainVariables)
        {
            if (var.key != "" && var.value != "")
            {
                domainVariables [serializedDomainVariables.IndexOf(var)].value = GameObject.Find(var.value);
            }
        }
        //Instantiate variables
        InstantiateVariables(goal, domainVariables);

        //Add sensor
        if (sensor == 0)
        {
            sensorySystem = new CameraSensor(this);
        }
        else if (sensor == 1)
        {
            sensorySystem = new RadiusSensor(this, radiusLength);
        }


        try {
            definitions = FactDefinitionsContainer.Load(FactsDefinitionWindow.definitionsPath).list;
        }

        catch (Exception e) {
            Debug.Log(e.Message);
        }



        //Agent FSM
        FSM = new AgentStateMachine(AgentState.IDLE, this);

        //Action manager
        actionManager = new ActionManager(this);



        //Coordination
        communicationSystem = new CommunicationSystem(this);

        groupMembers = new List <HTNAgent> ();

        //Personalities
        knownPersonalities = PersonalitiesContainer.Load(PersonalityEditorWindow.path).list;
    }
Esempio n. 9
0
        static int Main(string[] args)
        {
            stopwatch.Restart();

            if (args.Length != 4)
            {
                PrintUsage();
                return(1);
            }

            // Avoid missing component errors because no components are directly used in this project
            // and the GeneratedCode assembly is not loaded but it should be
            Assembly.Load("GeneratedCode");

            using (var connection = ConnectWithReceptionist(args[1], Convert.ToUInt16(args[2]), args[3]))
            {
                SpatialOSConnectionSystem.connection = connection;
                Connected = true;

                var channel = new Channel(FirestoreClient.DefaultEndpoint.Host, GoogleCredential.FromFile(Path.Combine(Directory.GetCurrentDirectory(), CloudFirestoreInfo.GoogleCredentialFile)).ToChannelCredentials());
                CloudFirestoreInfo.Database = FirestoreDb.Create(CloudFirestoreInfo.FirebaseProjectId, FirestoreClient.Create(channel));

                var tasks = new Task[15];

                tasks[1] = TriggerControllersSystem.UpdateLoop();

                tasks[2] = DamageablesSystem.UpdateLoop();
                tasks[3] = RechargeablesSystem.UpdateLoop();

                tasks[4] = SensorsSystem.UpdateLoop();
                tasks[5] = ScannersSystem.UpdateLoop();
                tasks[6] = SamplersSystem.UpdateLoop();

                tasks[7] = PingsSenderSystem.UpdateLoop();
                tasks[8] = PositionsSystem.UpdateLoop();

                tasks[9]  = CraftingSystem.UpdateLoop();
                tasks[10] = MapItemsSystem.UpdateLoop();
                tasks[11] = ModularsSystem.UpdateLoop();
                tasks[12] = ModulesInventorySystem.UpdateLoop();
                tasks[13] = ResourcesInventorySystem.UpdateLoop();

                tasks[14] = CommunicationSystem.UpdateLoop();

                var dispatcher = new Dispatcher();

                dispatcher.OnDisconnect(op =>
                {
                    connection.SendLogMessage(LogLevel.Info, "Disconnect", string.Format("Reason for diconnect {0}", op.Reason));
                    Connected = false;
                });

                stopwatch.Stop();

                for (int i = 1; i < tasks.Length; i++)
                {
                    tasks[i].Start();
                }

                connection.SendLogMessage(LogLevel.Info, "Initialization", string.Format("Init Time {0}ms", stopwatch.Elapsed.TotalMilliseconds.ToString("N0")));

                while (Connected)
                {
                    using (var opList = connection.GetOpList(100))
                    {
                        stopwatch.Restart();

                        Parallel.Invoke(
                            () => dispatcher.Process(opList),
                            () => PingsSenderSystem.dispatcher.Process(opList),
                            () => PositionsSystem.dispatcher.Process(opList),
                            () => IdentificationsSystem.dispatcher.Process(opList),
                            () => ExplorationHacksSystem.dispatcher.Process(opList),
                            () => DamageablesSystem.dispatcher.Process(opList),
                            () => RechargeablesSystem.dispatcher.Process(opList),
                            () => SamplersSystem.dispatcher.Process(opList),
                            () => ScannersSystem.dispatcher.Process(opList),
                            () => SensorsSystem.dispatcher.Process(opList),
                            () => TriggerControllersSystem.dispatcher.Process(opList),
                            () => ModularsSystem.dispatcher.Process(opList),
                            () => ModulesInventorySystem.dispatcher.Process(opList),
                            () => ResourcesInventorySystem.dispatcher.Process(opList),
                            () => MapItemsSystem.dispatcher.Process(opList),
                            () => CraftingSystem.dispatcher.Process(opList),
                            () => CommunicationSystem.dispatcher.Process(opList)
                            );

                        stopwatch.Stop();

                        connection.SendLogMessage(LogLevel.Info, "Process OpList", string.Format("Time {0}ms", stopwatch.ElapsedMilliseconds.ToString("N0")));
                    }

                    stopwatch.Restart();
                    SpatialOSConnectionSystem.Update();
                    stopwatch.Stop();

                    connection.SendLogMessage(LogLevel.Info, "SpatialOSConnectionSystem.Update", string.Format("Time {0}ms", stopwatch.ElapsedMilliseconds.ToString("N0")));
                }

                tasks[0] = channel.ShutdownAsync();
                tasks[0].Start();

                Task.WaitAll(tasks);
            }

            return(1);
        }
Esempio n. 10
0
    //todo -- probably takes a descriptor to read pilot stats out of
    public void Start()
    {
        this.entity = GetComponent<Entity>();
        this.engines = GetComponentInChildren<EngineSystem>();
        this.controls = engines.FlightControls;
        this.sensorSystem = entity.sensorSystem;
        this.weaponSystem = entity.weaponSystem;
        this.commSystem = entity.commSystem;
        this.navSystem = entity.navSystem;
        Assert.IsNotNull(this.entity, "AIPilot needs an entity " + transform.name);
        Assert.IsNotNull(this.engines, "AIPilot needs an engine system");
        Assert.IsNotNull(this.sensorSystem, "AIPilot needs a sensor system");
        goals = new List<AIGoal>(5);
        AddGoal(new AIGoal_Idle());

        AIGoalDescriptor desc = new AIGoalDescriptor(0.5f);
        AddGoal(new AIGoal_GoTo(desc, new Vector3(0, 0, 42f), 5f));

        aiStates = CreateAIStates(this);

        SetAIState();
    }