Ejemplo n.º 1
0
 private void AutoFillModules()
 {
     StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
     StationModuleQueue.AutoFillModules(this.App.Game, this._selectedStation, this._queuedItemMap);
     if (this._queuedItemMap.Count <= 0)
     {
         return;
     }
     this.SyncModuleItems();
 }
Ejemplo n.º 2
0
        protected void SyncBuildQueue()
        {
            this.App.UI.ClearItems("moduleQue");
            StationInfo             si   = this.App.GameDatabase.GetStationInfo(this._selectedStation.OrbitalObjectID);
            List <DesignModuleInfo> list = this.App.GameDatabase.GetQueuedStationModules(si.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
            int num = 0;

            foreach (DesignModuleInfo designModuleInfo in list)
            {
                DesignModuleInfo module = designModuleInfo;
                this.App.UI.AddItem("moduleQue", "", module.ID, "");
                string itemGlobalId = this.App.UI.GetItemGlobalID("moduleQue", "", module.ID, "");
                StationModules.StationModule stationModule = ((IEnumerable <StationModules.StationModule>)StationModules.Modules).Where <StationModules.StationModule>((Func <StationModules.StationModule, bool>)(x =>
                {
                    ModuleEnums.StationModuleType smType            = x.SMType;
                    ModuleEnums.StationModuleType?stationModuleType = module.StationModuleType;
                    if (smType == stationModuleType.GetValueOrDefault())
                    {
                        return(stationModuleType.HasValue);
                    }
                    return(false);
                })).First <StationModules.StationModule>();
                StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
                LogicalModule logicalModule = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == this.App.AssetDatabase.GetStationModuleAsset(module.StationModuleType.Value, StationModuleQueue.GetModuleFactionDefault(module.StationModuleType.Value, this.App.Game.GetPlayerObject(si.PlayerID).Faction))));
                num += logicalModule.SavingsCost;
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "moduleName"), "text", stationModule.Name + " - $" + logicalModule.SavingsCost.ToString("N0"));
                this.App.UI.SetVisible(this.App.UI.Path(itemGlobalId, "deleteButton"), true);
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "deleteButton"), "id", "modque|" + ((int)module.StationModuleType.Value).ToString());
                this.App.UI.SetPropertyColor(this.App.UI.Path(itemGlobalId, "moduleName"), "color", new Vector3((float)byte.MaxValue, (float)byte.MaxValue, (float)byte.MaxValue));
            }
            int userItemId = 999000;

            foreach (KeyValuePair <ModuleEnums.StationModuleType, int> keyValuePair in this._queuedItemMap.ToList <KeyValuePair <ModuleEnums.StationModuleType, int> >().Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => x.Value > 0)))
            {
                KeyValuePair <ModuleEnums.StationModuleType, int> thing = keyValuePair;
                for (int index = 0; index < thing.Value; ++index)
                {
                    this.App.UI.AddItem("moduleQue", "", userItemId, "");
                    string itemGlobalId = this.App.UI.GetItemGlobalID("moduleQue", "", userItemId, "");
                    StationModules.StationModule stationModule = ((IEnumerable <StationModules.StationModule>)StationModules.Modules).Where <StationModules.StationModule>((Func <StationModules.StationModule, bool>)(x => x.SMType == thing.Key)).First <StationModules.StationModule>();
                    StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
                    LogicalModule logicalModule = this.App.AssetDatabase.Modules.First <LogicalModule>((Func <LogicalModule, bool>)(x => x.ModulePath == this.App.AssetDatabase.GetStationModuleAsset(thing.Key, StationModuleQueue.GetModuleFactionDefault(thing.Key, this.App.Game.GetPlayerObject(si.PlayerID).Faction))));
                    num += logicalModule.SavingsCost;
                    this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "moduleName"), "text", stationModule.Name + " - $" + logicalModule.SavingsCost.ToString("N0"));
                    this.App.UI.SetPropertyColor(this.App.UI.Path(itemGlobalId, "moduleName"), "color", new Vector3((float)byte.MaxValue, 200f, 50f));
                    this.App.UI.SetVisible(this.App.UI.Path(itemGlobalId, "deleteButton"), false);
                    ++userItemId;
                }
            }
            this.App.UI.SetText("queueCost", "$" + num.ToString("N0"));
            this.App.UI.SetText("turnsToComplete", list.Count.ToString() + " " + App.Localize("@UI_GENERAL_TURNS"));
        }
Ejemplo n.º 3
0
        protected void PopulateModulesList(StationInfo station)
        {
            this.App.UI.SetPropertyString("moduleDescriptionText", "text", "");
            this._selectedStation = station;
            StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
            List <LogicalModuleMount> stationModuleMounts = this.App.Game.GetStationModuleMounts(station);

            this.App.UI.ClearItems("stationModules");
            StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
            StationModuleQueue.InitializeQueuedItemMap(this.App.Game, station, this._queuedItemMap);
            int userItemId = 0;

            foreach (StationModules.StationModule uniqueStationModule in StationModuleQueue.EnumerateUniqueStationModules(this.App.Game, station))
            {
                this.App.UI.AddItem("stationModules", "", userItemId, "");
                string itemGlobalId = this.App.UI.GetItemGlobalID("stationModules", "", userItemId, "");
                this.App.UI.SetPropertyString(itemGlobalId, "id", "module" + (object)uniqueStationModule.SMType);
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "huverbuttin"), "id", station.OrbitalObjectID.ToString() + "|" + (object)uniqueStationModule.SMType);
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "module_label"), "text", uniqueStationModule.Name);
                this.App.UI.SetVisible(this.App.UI.Path(itemGlobalId, "module_up"), true);
                this.App.UI.SetVisible(this.App.UI.Path(itemGlobalId, "module_down"), true);
                this.App.UI.SetVisible(this.App.UI.Path(itemGlobalId, "module_max"), true);
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "module_up"), "id", station.OrbitalObjectID.ToString() + "|" + uniqueStationModule.SMType.ToString() + "|module_up");
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "module_down"), "id", station.OrbitalObjectID.ToString() + "|" + uniqueStationModule.SMType.ToString() + "|module_down");
                this.App.UI.SetPropertyString(this.App.UI.Path(itemGlobalId, "module_max"), "id", station.OrbitalObjectID.ToString() + "|" + uniqueStationModule.SMType.ToString() + "|module_max");
                ++userItemId;
            }
            if (stationModuleMounts.FirstOrDefault <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == "AlienHabitation")) != null && this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key].ToString() == "AlienHabitation")).Count <KeyValuePair <ModuleEnums.StationModuleType, int> >() == 0)
            {
                this.AddBlankModule(userItemId++, station, ModuleEnums.StationModuleType.AlienHabitation);
            }
            if (stationModuleMounts.FirstOrDefault <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == "LargeAlienHabitation")) != null && this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key].ToString() == "LargeAlienHabitation")).Count <KeyValuePair <ModuleEnums.StationModuleType, int> >() == 0)
            {
                int cur = userItemId;
                int num = cur + 1;
                this.AddBlankModule(cur, station, ModuleEnums.StationModuleType.LargeAlienHabitation);
            }
            this.SyncModuleItems();
            this.SyncBuildQueue();
        }
Ejemplo n.º 4
0
 protected override void OnPanelMessage(string panelName, string msgType, string[] msgParams)
 {
     if (msgType == "button_clicked" && panelName == "okButton")
     {
         this._app.UI.CloseDialog((Dialog)this, true);
     }
     if (msgType == "mouse_enter")
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         IEnumerable <StationModules.StationModule> source = ((IEnumerable <StationModules.StationModule>)StationModules.Modules).Where <StationModules.StationModule>((Func <StationModules.StationModule, bool>)(x => x.SMType == type));
         if (source.Count <StationModules.StationModule>() > 0)
         {
             string upper = stationInfo.DesignInfo.StationType.ToDisplayText(this.App.GameDatabase.GetFactionName(this.App.GameDatabase.GetPlayerFactionID(stationInfo.PlayerID))).ToUpper();
             this.App.UI.SetPropertyString("moduleDescriptionText", "text", App.Localize(string.Format(source.ElementAt <StationModules.StationModule>(0).Description, (object)upper)));
         }
     }
     else
     {
         int num1 = msgType == "mouse_leave" ? 1 : 0;
     }
     if (msgType == "list_sel_changed")
     {
         if (panelName == "station_list")
         {
             this.PopulateModulesList(this.App.GameDatabase.GetStationInfo(int.Parse(msgParams[0])));
         }
         else if (panelName == "filterDropdown")
         {
             this._currentFilterMode = (StationType)int.Parse(msgParams[0]);
             this.SyncStationList();
         }
     }
     if (!(msgType == "button_clicked"))
     {
         return;
     }
     if (panelName == "upgradeButton")
     {
         OrbitalObjectInfo orbitalObjectInfo = this._app.GameDatabase.GetOrbitalObjectInfo(this._selectedStation.OrbitalObjectID);
         this._starmap.GetUpgradeMissionOverlay().StartSelect = orbitalObjectInfo.ID;
         this._app.UI.CloseDialog((Dialog)this, true);
         this._starmap.ShowUpgradeMissionOverlay(orbitalObjectInfo.StarSystemID);
     }
     else if (panelName.StartsWith("modque"))
     {
         ModuleEnums.StationModuleType moduleID            = (ModuleEnums.StationModuleType) int.Parse(panelName.Split('|')[1]);
         List <LogicalModuleMount>     stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(this.App.GameDatabase.GetStationInfo(this._selectedStation.OrbitalObjectID));
         List <DesignModuleInfo>       queuedModules       = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => queuedModules.Any <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(y => y.MountNodeName == x.NodeName)))).ToList <LogicalModuleMount>();
         DesignModuleInfo designModuleInfo = queuedModules.FirstOrDefault <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = moduleID;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         }));
         if (designModuleInfo != null)
         {
             this.App.GameDatabase.RemoveQueuedStationModule(designModuleInfo.ID);
         }
         this.SyncModuleItems();
         this.SyncBuildQueue();
     }
     else if (panelName == "filterDiplomatic")
     {
         StationManagerDialog.StationViewFilter[StationType.DIPLOMATIC] = !StationManagerDialog.StationViewFilter[StationType.DIPLOMATIC];
         this.SyncStationList();
     }
     else if (panelName == "filterScience")
     {
         StationManagerDialog.StationViewFilter[StationType.SCIENCE] = !StationManagerDialog.StationViewFilter[StationType.SCIENCE];
         this.SyncStationList();
     }
     else if (panelName == "filterCivilian")
     {
         StationManagerDialog.StationViewFilter[StationType.CIVILIAN] = !StationManagerDialog.StationViewFilter[StationType.CIVILIAN];
         this.SyncStationList();
     }
     else if (panelName == "filterNaval")
     {
         StationManagerDialog.StationViewFilter[StationType.NAVAL] = !StationManagerDialog.StationViewFilter[StationType.NAVAL];
         this.SyncStationList();
     }
     else if (panelName == "filterMining")
     {
         StationManagerDialog.StationViewFilter[StationType.MINING] = !StationManagerDialog.StationViewFilter[StationType.MINING];
         this.SyncStationList();
     }
     else if (panelName == "filterSDS")
     {
         StationManagerDialog.StationViewFilter[StationType.DEFENCE] = !StationManagerDialog.StationViewFilter[StationType.DEFENCE];
         this.SyncStationList();
     }
     else if (panelName == "filterGate")
     {
         StationManagerDialog.StationViewFilter[StationType.GATE] = !StationManagerDialog.StationViewFilter[StationType.GATE];
         this.SyncStationList();
     }
     else if (panelName == "confirmOrderButton")
     {
         StationInfo stationInfo = this.App.GameDatabase.GetStationInfo(this._selectedStation.OrbitalObjectID);
         StationModuleQueue.UpdateStationMapsForFaction(this.App.LocalPlayer.Faction.Name);
         StationModuleQueue.ConfirmStationQueuedItems(this.App.Game, stationInfo, this._queuedItemMap);
         this.SyncModuleItems();
         this.SyncBuildQueue();
     }
     else if (panelName.EndsWith("module_up"))
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         this.App.GameDatabase.GetModuleID(this.App.AssetDatabase.GetStationModuleAsset(type, this.App.Game.LocalPlayer.Faction.Name), this.App.Game.LocalPlayer.ID);
         List <LogicalModuleMount> stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(stationInfo);
         List <DesignModuleInfo>   list = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = type;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         })).ToList <DesignModuleInfo>();
         int num2 = list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.StationModuleType.Value] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Count <DesignModuleInfo>();
         if (this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Sum <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, int>)(x => x.Value)) >= stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == AssetDatabase.StationModuleTypeToMountTypeMap[type].ToString())).Count <LogicalModuleMount>() - num2)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index;
         (queuedItemMap = this._queuedItemMap)[index = type] = queuedItemMap[index] + 1;
         this.SyncModuleItems();
     }
     else if (panelName.EndsWith("module_down"))
     {
         string[] strArray = panelName.Split('|');
         int.Parse(strArray[0]);
         ModuleEnums.StationModuleType index1 = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         if (this._queuedItemMap[index1] <= 0)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index2;
         (queuedItemMap = this._queuedItemMap)[index2 = index1] = queuedItemMap[index2] - 1;
         this.SyncModuleItems();
     }
     else if (panelName.EndsWith("module_max"))
     {
         string[] strArray                  = panelName.Split('|');
         int      orbitalObjectID           = int.Parse(strArray[0]);
         ModuleEnums.StationModuleType type = (ModuleEnums.StationModuleType)Enum.Parse(typeof(ModuleEnums.StationModuleType), strArray[1]);
         StationInfo stationInfo            = this.App.GameDatabase.GetStationInfo(orbitalObjectID);
         this.App.GameDatabase.GetModuleID(this.App.AssetDatabase.GetStationModuleAsset(type, this.App.Game.LocalPlayer.Faction.Name), this.App.Game.LocalPlayer.ID);
         List <LogicalModuleMount> stationModuleMounts = this.App.Game.GetAvailableStationModuleMounts(stationInfo);
         List <DesignModuleInfo>   list = this.App.GameDatabase.GetQueuedStationModules(this._selectedStation.DesignInfo.DesignSections[0]).ToList <DesignModuleInfo>();
         list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x =>
         {
             ModuleEnums.StationModuleType?stationModuleType1 = x.StationModuleType;
             ModuleEnums.StationModuleType stationModuleType2 = type;
             if (stationModuleType1.GetValueOrDefault() == stationModuleType2)
             {
                 return(stationModuleType1.HasValue);
             }
             return(false);
         })).ToList <DesignModuleInfo>();
         int num2 = list.Where <DesignModuleInfo>((Func <DesignModuleInfo, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.StationModuleType.Value] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Count <DesignModuleInfo>();
         int num3 = stationModuleMounts.Where <LogicalModuleMount>((Func <LogicalModuleMount, bool>)(x => x.ModuleType == AssetDatabase.StationModuleTypeToMountTypeMap[type].ToString())).Count <LogicalModuleMount>();
         int num4 = this._queuedItemMap.Where <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, bool>)(x => AssetDatabase.StationModuleTypeToMountTypeMap[x.Key] == AssetDatabase.StationModuleTypeToMountTypeMap[type])).Sum <KeyValuePair <ModuleEnums.StationModuleType, int> >((Func <KeyValuePair <ModuleEnums.StationModuleType, int>, int>)(x => x.Value));
         if (num4 >= num3 - num2)
         {
             return;
         }
         Dictionary <ModuleEnums.StationModuleType, int> queuedItemMap;
         ModuleEnums.StationModuleType index;
         (queuedItemMap = this._queuedItemMap)[index = type] = queuedItemMap[index] + (num3 - num2 - num4);
         this.SyncModuleItems();
     }
     else
     {
         if (!(panelName == "autoUpgradeButton"))
         {
             return;
         }
         this.AutoFillModules();
     }
 }