示例#1
0
        public WOLF_GuiManageTransfers(IRegistryCollection registry)
            : base("Transfer Resources", 400, 460)
        {
            _registry = registry;

            Start();
        }
示例#2
0
        public CrewRoute(
            string originBody,
            string originBiome,
            string destinationBody,
            string destinationBiome,
            int economyBerths,
            int luxuryBerths,
            double duration,
            string flightNumber,
            IRegistryCollection depotRegistry)
        {
            if (economyBerths + luxuryBerths < 1)
            {
                throw new RouteInsufficientPayloadException();
            }
            EconomyBerths    = economyBerths;
            LuxuryBerths     = luxuryBerths;
            OriginBody       = originBody;
            OriginBiome      = originBiome;
            DestinationBody  = destinationBody;
            DestinationBiome = destinationBiome;
            FlightNumber     = flightNumber;
            FlightStatus     = FlightStatus.Boarding;
            UniqueId         = Guid.NewGuid().ToString("N");
            Duration         = Math.Max(duration, KSPUtil.dateTimeFormatter.Day);

            OriginDepot      = depotRegistry.GetDepot(originBody, originBiome);
            DestinationDepot = depotRegistry.GetDepot(destinationBody, destinationBiome);
        }
示例#3
0
        /// <summary>
        /// Implementation of <see cref="MonoBehaviour"/>.Start
        /// </summary>
        void Start()
        {
            _wolfScenario    = FindObjectOfType <WOLF_ScenarioModule>();
            _wolfRegistry    = _wolfScenario.ServiceManager.GetService <IRegistryCollection>();
            _filters         = _wolfScenario.ServiceManager.GetService <WOLF_GuiFilters>();
            _routeMonitor    = _wolfScenario.ServiceManager.GetService <WOLF_RouteMonitor>();
            _planningMonitor = _wolfScenario.ServiceManager.GetService <WOLF_PlanningMonitor>();

            _windowId = Random.Range(int.MinValue, int.MaxValue);

            if (!_hasInitStyles)
            {
                InitStyles();
            }

            // Setup tab labels
            _tabLabels = new[] { "Depots", "Harvestable Resources", "Routes" };
            if (_isEditor)
            {
                _tabLabels = _tabLabels.Concat(new string[] { "Planner" }).ToArray();
            }

            // Setup child windows
            if (!_childWindows.Contains(_routeMonitor.ManageTransfersGui))
            {
                _childWindows.Add(_routeMonitor.ManageTransfersGui);
            }

            // Check for missing hoppers
            StartCoroutine(CheckForMissingHoppers());
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="executingAllele">The IGEPAllele that is executing the IFunction.</param>
 /// <param name="availableRegistries">The IRegistries that are readable and writable by the executing IFunction.</param>
 /// <param name="callableGenes">The IGEPGenes that can be called by the executing IGene.</param>
 /// <param name="geneExecutionDataDictionary">The IGeneExecutionData for each IGEPGene in the parent IGEPOrganism.</param>
 protected FunctionExecutionDataBase(IGEPAllele executingAllele, IRegistryCollection availableRegistries,
     IList<IGEPGene> callableGenes, IDictionary<IGeneIdentifier, IGeneExecutionData> geneExecutionDataDictionary)
 {
     this.ExecutingAllele = executingAllele;
     this.AvailableRegistries = availableRegistries;
     this.CallableGenes = callableGenes;
     this.GeneExecutionDataDictionary = geneExecutionDataDictionary;
 }
示例#5
0
        public WOLF_RouteMonitor(IRegistryCollection routeRegistry)
        {
            _routeRegistry = routeRegistry;

            InitStyles();

            ManageTransfersGui = new WOLF_GuiManageTransfers(routeRegistry);
        }
 protected DebuggableAminoAcidBase(IGEPAminoAcid aminoAcid, IAminoAcidResult result,
     IRegistryCollection registries, IVariable resultingVariable, IDebuggableAminoAcidCollection arguments)
 {
     this.AminoAcid = aminoAcid;
     this.Result = result;
     this.Registries = registries;
     this.ResultingVariable = resultingVariable;
     this.Arguments = arguments;
 }
示例#7
0
        public WOLF_GuiFilters(IRegistryCollection depotRegistry)
        {
            _depotRegistry = depotRegistry;

            InitStyles();
            CreateCache();
            CreateDropdowns();

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_HEADER_LABEL", out string headerLabel))
            {
                HEADER_LABEL = headerLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_ORIGIN_LABEL", out string originLabel))
            {
                ORIGIN_LABEL = originLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_DESTINATION_LABEL", out string destinationLabel))
            {
                DESTINATION_LABEL = destinationLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_RESOURCES_LABEL", out string resourcesLabel))
            {
                RESOURCES_LABEL = resourcesLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_RAW_LABEL", out string rawLabel))
            {
                RAW_LABEL = rawLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_REFINED_LABEL", out string refinedLabel))
            {
                REFINED_LABEL = refinedLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_ASSEMBLED_LABEL", out string assembledLabel))
            {
                ASSEMBLED_LABEL = assembledLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_LIFE_SUPPORT_LABEL", out string lifeSupportLabel))
            {
                LIFE_SUPPORT_LABEL = lifeSupportLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_CREW_LABEL", out string crewLabel))
            {
                CREW_LABEL = crewLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_RESET_HEADER_LABEL", out string resetHeaderLabel))
            {
                RESET_HEADER_LABEL = resetHeaderLabel;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_GUI_FILTERS_RESET_BUTTON_LABEL", out string resetButtonLabel))
            {
                RESET_BUTTON_LABEL = resetButtonLabel;
            }
        }
示例#8
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_CURRENT_BIOME_GUI_NAME", out string currentBiomeGuiName))
            {
                CURRENT_BIOME_GUI_NAME = currentBiomeGuiName;
            }
            Fields["CurrentBiome"].guiName = CURRENT_BIOME_GUI_NAME;

            _scenario = FindObjectOfType <WOLF_ScenarioModule>();
            _registry = _scenario.ServiceManager.GetService <IRegistryCollection>();

            ParseRecipe();
        }
示例#9
0
        public WOLF_PlanningMonitor(IRegistryCollection depotRegistry)
        {
            _depotRegistry = depotRegistry;

            CreateCache();
            CreateDropdown();

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_NO_DEPOTS_ESTABLISHED_MESSAGE", out string noDepotsMessage))
            {
                NO_DEPOTS_MESSAGE = noDepotsMessage;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_INVALID_HOPPER_PART_ATTACHMENT_MESSAGE", out string invalidPartAttachMessage))
            {
                INVALID_PART_ATTACHMENT_MESSAGE = invalidPartAttachMessage;
            }
        }
 public DebuggableAminoAcid(IGEPAminoAcid aminoAcid, IAminoAcidResult result, 
     IRegistryCollection registries, IVariable resultingVariable, IDebuggableAminoAcidCollection arguments) 
     : base(aminoAcid, result, registries, resultingVariable, arguments)
 {
 }
示例#11
0
        public override void OnStart(StartState state)
        {
            base.OnStart(state);

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_HOPPER_ALREADY_CONNECTED_MESSAGE", out string alreadyConnectedMessage))
            {
                ALREADY_CONNECTED_MESSAGE = alreadyConnectedMessage;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_HOPPER_DISCONNECTED_MESSAGE", out string disconnectedMessage))
            {
                DISCONNECTED_MESSAGE = disconnectedMessage;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_HOPPER_LOST_CONNECTION_MESSAGE", out string lostConnectionMessage))
            {
                LOST_CONNECTION_MESSAGE = lostConnectionMessage;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_HOPPER_NOT_CONNECTED_MESSAGE", out string notConnectedMessage))
            {
                NOT_CONNECTED_MESSAGE = notConnectedMessage;
            }

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_CONNECT_TO_DEPOT_GUI_NAME", out string connectGuiName))
            {
                CONNECT_TO_DEPOT_GUI_NAME = connectGuiName;
            }
            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_DISCONNECT_FROM_DEPOT_GUI_NAME", out string disconnectGuiName))
            {
                DISCONNECT_FROM_DEPOT_GUI_NAME = disconnectGuiName;
            }

            if (Localizer.TryGetStringByTag("#autoLOC_USI_WOLF_CURRENT_BIOME_GUI_NAME", out string currentBiomeGuiName))
            {
                CURRENT_BIOME_GUI_NAME = currentBiomeGuiName;
            }
            Fields["CurrentBiome"].guiName = CURRENT_BIOME_GUI_NAME;


            Events["ConnectToDepotEvent"].guiName      = CONNECT_TO_DEPOT_GUI_NAME;
            Events["DisconnectFromDepotEvent"].guiName = DISCONNECT_FROM_DEPOT_GUI_NAME;

            // Find the WOLF scenario and parse the hopper recipe
            var scenario = FindObjectOfType <WOLF_ScenarioModule>();

            _registry = scenario.ServiceManager.GetService <IRegistryCollection>();

            ParseWolfRecipe();

            // If we were previously connected to a depot, make sure we still are
            if (IsConnectedToDepot)
            {
                var body  = vessel.mainBody.name;
                var biome = WOLF_AbstractPartModule.GetVesselBiome(vessel);
                var depot = _registry.GetDepot(DepotBody, DepotBiome);

                if (depot == null || depot.Body != body || depot.Biome != biome)
                {
                    Debug.LogWarning("[WOLF] Hopper lost connection to its depot.");
                    Messenger.DisplayMessage(LOST_CONNECTION_MESSAGE);
                    StopResourceConverter();
                    ReleaseResources();
                }
                else
                {
                    // Hook into vessel destroyed event to release resources back to depot
                    if (vessel != null)
                    {
                        vessel.OnJustAboutToBeDestroyed += OnVesselDestroyed;
                        GameEvents.OnVesselRecoveryRequested.Add(OnVesselRecovered);
                    }
                }
            }

            Events["ConnectToDepotEvent"].guiActive      = !IsConnectedToDepot;
            Events["DisconnectFromDepotEvent"].guiActive = IsConnectedToDepot;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="executingAllele">The IGEPAllele that is executing the IFunction.</param>
 /// <param name="availableRegistries">The IRegistries that are readable and writable by the executing IFunction.</param>
 /// <param name="callableGenes">The IGEPGenes that can be called by the executing IGene.</param>
 /// <param name="geneExecutionDataDictionary">The IGeneExecutionData for each IGEPGene in the parent IGEPOrganism.</param>
 public FunctionExecutionData(IGEPAllele executingAllele, 
     IRegistryCollection availableRegistries, IList<IGEPGene> callableGenes, 
     IDictionary<IGeneIdentifier, IGeneExecutionData> geneExecutionDataDictionary) : base(executingAllele, availableRegistries, callableGenes, geneExecutionDataDictionary)
 {
 }
示例#13
0
 /// <summary>
 /// Don't use this constructor. It's used only by the persistence layer.
 /// </summary>
 public CrewRoute(IRegistryCollection depotRegistry)
 {
     _registry = depotRegistry;
 }
示例#14
0
        public override void OnAwake()
        {
            base.OnAwake();

            GetLocalizedTextValues();

            var wolfScenario = FindObjectOfType <WOLF_ScenarioModule>();

            _wolf = wolfScenario.ServiceManager.GetService <IRegistryCollection>();

            var usiTools = USI_AddonServiceManager.Instance;

            if (usiTools != null)
            {
                var serviceManager = usiTools.ServiceManager;
                var windowManager  = serviceManager.GetService <WindowManager>();

                try
                {
                    // Setup UI prefabs
                    var filepath = Path.Combine(KSPUtil.ApplicationRootPath,
                                                "GameData/UmbraSpaceIndustries/WOLF/Assets/UI/CrewTransferWindow.prefabs");
                    var prefabs = AssetBundle.LoadFromFile(filepath);
                    var flightSelectorPrefab = prefabs.LoadAsset <GameObject>("FlightSelector");
                    var kerbalSelectorPrefab = prefabs.LoadAsset <GameObject>("KerbalSelector");
                    var terminalWindowPrefab = prefabs.LoadAsset <GameObject>("TerminalWindow");
                    var warningPanelPrefab   = prefabs.LoadAsset <GameObject>("WarningPanel");

                    // Register prefabs with window manager
                    windowManager
                    .RegisterPrefab <FlightSelector>(flightSelectorPrefab)
                    .RegisterPrefab <KerbalSelector>(kerbalSelectorPrefab)
                    .RegisterPrefab <WarningPanel>(warningPanelPrefab)
                    .RegisterWindow <TerminalWindow>(terminalWindowPrefab);
                }
                catch (ServiceAlreadyRegisteredException) { }
                catch (NullReferenceException)
                {
                    // TODO - Create an asset bundle loader service in USITools
                }
                catch (Exception ex)
                {
                    Debug.LogError($"[WOLF] {ClassName}: {ex.Message}");
                }

                try
                {
                    _window = windowManager.GetWindow <TerminalWindow>();
                    _window.Initialize(this, windowManager, () =>
                    {
                        if (_toolbarButton != null)
                        {
                            _toolbarButton.SetFalse(false);
                        }
                    });
                }
                catch (Exception ex)
                {
                    Debug.LogError($"[WOLF] {ClassName}: {ex.Message}");
                    enabled = false;
                    return;
                }

                // Create toolbar button
                var textureService = serviceManager.GetService <TextureService>();
                var toolbarIcon    = textureService.GetTexture(
                    "GameData/UmbraSpaceIndustries/WOLF/Assets/UI/crew-transfers.png", 36, 36);
                var showInScenes = ApplicationLauncher.AppScenes.FLIGHT |
                                   ApplicationLauncher.AppScenes.MAPVIEW |
                                   ApplicationLauncher.AppScenes.SPACECENTER |
                                   ApplicationLauncher.AppScenes.SPH |
                                   ApplicationLauncher.AppScenes.TRACKSTATION |
                                   ApplicationLauncher.AppScenes.VAB;
                _toolbarButton = ApplicationLauncher.Instance.AddModApplication(
                    ShowWindow,
                    CloseWindow,
                    null,
                    null,
                    null,
                    null,
                    showInScenes,
                    toolbarIcon);
            }
        }