Ejemplo n.º 1
0
 private void AddHackingLocation(TechGroup techGroup, Vector3D coords, double researchrange = 5)
 {
     if (!researchControl.UnlockedTechs.Contains(techGroup))
     {
         hackingLocations.Add(new HackingLocation(techGroup, coords, researchrange));
     }
 }
Ejemplo n.º 2
0
        public BuildableHelper(string id, string displayname, string tooltip, TechGroup group, TechCategory category, TechType after = TechType.None, bool unlockonstart = true, Atlas.Sprite atlasSprite = null, Sprite unitySprite = null)
        {
            if (atlasSprite != null && unitySprite != null)
            {
                throw new ArgumentException("Neither atlasSprite nor unitySprite are null!");
            }

            if (atlasSprite != null)
            {
                techType = TechTypeHandler.AddTechType(id, displayname, tooltip, atlasSprite, unlockonstart);
            }
            else if (unitySprite != null)
            {
                techType = TechTypeHandler.AddTechType(id, displayname, tooltip, unitySprite, unlockonstart);
            }
            else
            {
                techType = TechTypeHandler.AddTechType(id, displayname, tooltip, unlockonstart);
            }

            CraftDataHandler.AddBuildable(techType);
            if (after == TechType.None)
            {
                CraftDataHandler.AddToGroup(group, category, techType);
            }
            else
            {
                CraftDataHandler.AddToGroup(group, category, techType, after);
            }
        }
Ejemplo n.º 3
0
        private static CalAudioClip GetAudioClipForTechGroup(TechGroup techGroup)
        {
            switch (techGroup)
            {
            case TechGroup.Permabanned:
                return(CalAudioClip.AllTechUnlocked);

            case TechGroup.AtmosphericEngines:
                return(CalAudioClip.UnlockAtmospherics);

            case TechGroup.Rockets:
                return(CalAudioClip.UnlockedMissiles);

            case TechGroup.OxygenGenerators:
                return(CalAudioClip.OxygenGeneratorUnlocked);

            case TechGroup.OxygenFarm:
                return(CalAudioClip.OxygenFarmUnlocked);

            case TechGroup.GasStorage:
                return(CalAudioClip.GasStorageUnlocked);

            default:
                return(CalAudioClip.PowerUpClipped);
            }
        }
Ejemplo n.º 4
0
        private static void GenerateOriginalsFile(TechGroup group, TechCategory category, List <TechType> list, string fileName)
        {
            var printyPrints = new List <string>();

            printyPrints.AddRange(EmUtils.CommentTextLinesCentered(new string[]
            {
                "This file was generated with original recipes in the game",
                "You can copy individual entries from this file to use in your personal overrides",
                "--------------------------------------------------------------------------------",
                $"PdaGroup: {group} - PdaCategory:{category}",
                "--------------------------------------------------------------------------------",
            }));

            var originals = new ModifiedRecipeList();

            foreach (TechType craftable in list)
            {
                originals.Add(new ModifiedRecipe(craftable));
            }

            printyPrints.Add(originals.PrettyPrint());

            File.WriteAllLines(FileLocations.OriginalsFolder + fileName, printyPrints.ToArray(), Encoding.UTF8);

            QuickLogger.Debug($"{fileName} file not found. File generated.");
        }
        protected ModPrefab_Craftable(
            string techTypeName,
            string friendlyName,
            string description,
            TechType template,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            EquipmentType equipmentType,
            QuickSlotType quickSlotType,
            CraftData.BackgroundType backgroundType,
            Vector2int itemSize,
            ModPrefab_Fragment fragment
            )
            : base(techTypeName, $"{techTypeName}.Prefab")
        {
            TechTypeName      = techTypeName;
            FriendlyName      = friendlyName;
            Description       = description;
            PrefabTemplate    = template;
            RequiredForUnlock = requiredAnalysis;
            GroupForPDA       = groupForPDA;
            CategoryForPDA    = categoryForPDA;
            TypeForEquipment  = equipmentType;
            TypeForQuickslot  = quickSlotType;
            BackgroundType    = backgroundType;
            ItemSize          = itemSize;
            _Fragment         = fragment;

            IngameMenuHandler.Main.RegisterOnQuitEvent(OnQuitEvent);
        }
Ejemplo n.º 6
0
        internal void UnlockTechGroupForAllPlayers(TechGroup techGroup)
        {
            if (UnlockedTechs.Contains(techGroup))
            {
                return; // Already unlocked
            }

            HashSet <MyDefinitionId> technologies;

            if (!techsForGroup.TryGetValue(techGroup, out technologies))
            {
                ModLog.Error("No technologies for group: " + techGroup);
                return;
            }

            var players = new List <IMyPlayer>();

            MyAPIGateway.Players.GetPlayers(players);
            foreach (var player in players)
            {
                foreach (var technology in technologies)
                {
                    MyVisualScriptLogicProvider.PlayerResearchUnlock(player.IdentityId, technology);
                }
            }
            UnlockedTechs.Add(techGroup);
            audioSystem.PlayAudio(GetAudioClipForTechGroup(techGroup));
        }
Ejemplo n.º 7
0
 protected Craftable(
     string nameID,
     string nameUsingForFiles,
     string friendlyName,
     string description,
     TechType template,
     CraftTree.Type fabricatorType,
     string fabricatorTab,
     TechType requiredAnalysis,
     TechGroup groupForPDA,
     TechCategory categoryForPDA,
     EquipmentType equipmentType,
     QuickSlotType quickSlotType,
     Vector2int itemSize,
     string gamerResourceFileName
     )
     : base(nameID, $"{nameID}Prefab")
 {
     NameID               = nameID;
     NameUsingForFiles    = nameUsingForFiles;
     FriendlyName         = friendlyName;
     Description          = description;
     PrefabTemplate       = template;
     FabricatorType       = fabricatorType;
     FabricatorTab        = fabricatorTab;
     RequiredForUnlock    = requiredAnalysis;
     GroupForPDA          = groupForPDA;
     CategoryForPDA       = categoryForPDA;
     TypeForEquipment     = equipmentType;
     TypeForQuickslot     = quickSlotType;
     ItemSize             = itemSize;
     GameResourceFileName = gamerResourceFileName;
 }
        protected BuildableModItem(
            string _classID,
            string _friendlyName,
            string _handOverText,
            string _description,
            TechType requiredForUnlock,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            bool _unlockedAtStart,

            string iconFileName,
            TechType iconTechType,
            TechType prefabTemplate,
            string gamerResourceFileName
            )
            : base(_classID, _friendlyName, _description)
        {
            _ClassID          = _classID;
            _FriendlyName     = _friendlyName;
            _Description      = _description;
            _HandOverText     = _handOverText;
            RequiredForUnlock = requiredForUnlock;
            GroupForPDA       = groupForPDA;
            CategoryForPDA    = categoryForPDA;
            _UnlockedAtStart  = _unlockedAtStart;

            IconFilename         = iconFileName;
            IconTechType         = iconTechType;
            PrefabTemplate       = prefabTemplate;
            GameResourceFileName = gamerResourceFileName;
        }
Ejemplo n.º 9
0
        internal static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
        {
            Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > > groups = CraftData.groups;
            Dictionary <TechCategory, List <TechType> > techGroup = groups[group];

            if (techGroup == null)
            {
                // Should never happen, but doesn't hurt to add it.
                Logger.Log("Invalid TechGroup!", LogLevel.Error);
                return;
            }

            List <TechType> techCategory = techGroup[category];

            if (techCategory == null)
            {
                Logger.Log($"Invalid TechCategory Combination! TechCategory: {category} TechGroup: {group}", LogLevel.Error);
                return;
            }

            int index = techCategory.IndexOf(after);

            if (index == -1) // Not found
            {
                techCategory.Add(techType);
                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
            }
            else
            {
                techCategory.Insert(index + 1, techType);

                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\" after \"{after.AsString():G}\"", LogLevel.Debug);
            }
        }
Ejemplo n.º 10
0
        public string Execute(TechGroup group, [CurrentCharacterIfNull] ICharacter player = null)
        {
            var technologies = player.SharedGetTechnologies();

            technologies.ServerAddGroup(group);
            return($"{player} tech group {group.NameWithTierName} added.");
        }
        protected Craftable(
            string nameID,
            string friendlyName,
            string description,
            TechType template,
            CraftTree.Type fabricatorType,
            string fabricatorTab,
            TechType requiredAnalysis,
            TechGroup groupForPDA,
            TechCategory categoryForPDA,
            Craftable prerequisite = null)
            : base(nameID, $"{nameID}Prefab")
        {
            NameID       = nameID;
            FriendlyName = friendlyName;
            Description  = description;

            PrefabTemplate = template;
            FabricatorType = fabricatorType;
            FabricatorTab  = fabricatorTab;

            RequiredForUnlock = requiredAnalysis;

            GroupForPDA    = groupForPDA;
            CategoryForPDA = categoryForPDA;

            Prerequisite = prerequisite;
        }
Ejemplo n.º 12
0
        internal static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType, TechType after)
        {
            if (!CraftData.groups.TryGetValue(group, out Dictionary <TechCategory, List <TechType> > techGroup))
            {
                // Should never happen, but doesn't hurt to add it.
                Logger.Log("Invalid TechGroup!", LogLevel.Error);
                return;
            }

            if (!techGroup.TryGetValue(category, out List <TechType> techCategory))
            {
                Logger.Log($"{group} does not contain {category} as a registered group. Please ensure to register your TechCategory to the TechGroup using the TechCategoryHandler before using the combination.", LogLevel.Error);
                return;
            }

            if (techCategory.Contains(techType))
            {
                Logger.Log($"\"{techType.AsString():G}\" Already exists at \"{group:G}->{category:G}\", Skipping Duplicate Entry", LogLevel.Debug);
                return;
            }

            int index = techCategory.IndexOf(after);

            if (index == -1) // Not found
            {
                techCategory.Add(techType);
                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"", LogLevel.Debug);
            }
            else
            {
                techCategory.Insert(index + 1, techType);

                Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\" after \"{after.AsString():G}\"", LogLevel.Debug);
            }
        }
Ejemplo n.º 13
0
        public ViewModelTechGroup(TechGroup techGroup)
        {
            this.TechGroup = techGroup;

            var requirements = new List <BaseViewModelTechGroupRequirement>(this.TechGroup.GroupRequirements.Count);

            foreach (var requirement in this.TechGroup.GroupRequirements)
            {
                if (requirement is TechGroupRequirementLearningPoints)
                {
                    // do not display such requirement as we display it separately now
                    continue;
                }

                var viewModel = requirement.CreateViewModel();
                viewModel.SubscribePropertyChange(_ => _.IsSatisfied,
                                                  _ => this.Refresh());
                requirements.Add(viewModel);
            }

            this.Requirements = requirements;

            this.TechGroup.NodesChanged += this.Refresh;
            ClientComponentTechnologiesWatcher.TechGroupsChanged     += this.Refresh;
            ClientComponentTechnologiesWatcher.TechNodesChanged      += this.Refresh;
            ClientComponentTechnologiesWatcher.LearningPointsChanged += this.Refresh;

            this.Refresh();
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     技術ファイルを構文解析する
        /// </summary>
        /// <param name="fileName">ファイル名</param>
        /// <returns>技術グループデータ</returns>
        public static TechGroup Parse(string fileName)
        {
            using (TextLexer lexer = new TextLexer(fileName, true))
            {
                Token token = lexer.GetToken();
                // 無効なトークン
                if (token.Type != TokenType.Identifier)
                {
                    Log.InvalidToken(LogCategory, token, lexer);
                    return(null);
                }

                string s = token.Value as string;
                if (string.IsNullOrEmpty(s))
                {
                    return(null);
                }
                s = s.ToLower();

                // technology
                if (s.Equals("technology"))
                {
                    TechGroup group = ParseTechnology(lexer);
                    if (group == null)
                    {
                        Log.InvalidSection(LogCategory, "technology", lexer);
                    }
                    return(group);
                }

                // 無効なトークン
                Log.InvalidToken(LogCategory, token, lexer);
                return(null);
            }
        }
Ejemplo n.º 15
0
        internal static TechGroup AddTechGroup(string name)
        {
            EnumTypeCache cache = cacheManager.RequestCacheForTypeName(name) ?? new EnumTypeCache()
            {
                Name  = name,
                Index = cacheManager.GetNextAvailableIndex()
            };

            TechGroup techGroup = (TechGroup)cache.Index;

            cacheManager.Add(techGroup, cache.Index, cache.Name);

            if (!uGUI_BlueprintsTab.groups.Contains(techGroup))
            {
                uGUI_BlueprintsTab.groups.Add(techGroup);
            }

            if (!CraftData.groups.ContainsKey(techGroup))
            {
                CraftData.groups[techGroup] = new Dictionary <TechCategory, List <TechType> >();
            }

            Logger.Log($"Successfully added TechGroup: '{name}' to Index: '{cache.Index}'", LogLevel.Debug);


            return(techGroup);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Adds a new <see cref="TechGroup" /> into the game.
        /// </summary>
        /// <param name="techGroupName">The name of the TechGroup. Should not contain special characters.</param>
        /// <param name="displayName">The display name of the TechGroup. Can be anything.</param>
        /// <returns>
        /// The new <see cref="TechGroup" /> that is created.
        /// </returns>
        public TechGroup AddTechGroup(string techGroupName, string displayName)
        {
            TechGroup techGroup = TechGroupPatcher.AddTechGroup(techGroupName);

            LanguageHandler.SetLanguageLine("Group" + techGroupName, displayName);

            return(techGroup);
        }
Ejemplo n.º 17
0
        public static void ServerUnlockGroup(ICharacter character, TechGroup techGroup)
        {
            techGroup.SharedValidateCanUnlock(character);
            var technologies = character.SharedGetTechnologies();

            technologies.ServerRemoveLearningPoints(techGroup.LearningPointsPrice);
            technologies.ServerAddGroup(techGroup);
        }
Ejemplo n.º 18
0
        public static void ClientUnlockGroup(TechGroup techGroup)
        {
            if (!ClientValidateCanUnlock(techGroup, showErrorNotification: true))
            {
                return;
            }

            Instance.CallServer(_ => _.ServerRemote_UnlockGroup(techGroup));
        }
Ejemplo n.º 19
0
        protected void addToGroup(TechGroup group, TechCategory category, TechType after = TechType.None)
        {
            CraftDataHandler.AddToGroup(group, category, TechType, after);

            if (group >= TechGroup.BasePieces && group <= TechGroup.Miscellaneous)             // little hack
            {
                CraftDataHandler.AddBuildable(TechType);
            }
        }
Ejemplo n.º 20
0
        public ViewModelTechGroup(TechGroup techGroup)
        {
            this.TechGroup = techGroup;
            this.Icon      = Client.UI.GetTextureBrush(this.TechGroup.Icon);

            ClientComponentTechnologiesWatcher.TechGroupsChanged     += this.TechGroupsChangedHandler;
            ClientComponentTechnologiesWatcher.TechNodesChanged      += this.TechNodesChangedHandler;
            ClientComponentTechnologiesWatcher.LearningPointsChanged += this.LearningPointsChangedHandler;

            this.Refresh();
        }
Ejemplo n.º 21
0
        private void CharacterGroupAddedOrRemovedHandler(ICharacter character, TechGroup techGroup, bool isAdded)
        {
            if (techGroup != this.TechGroup)
            {
                return;
            }

            var context = this.GetActiveContext(character, out _);

            context?.Refresh();
        }
Ejemplo n.º 22
0
        public static void ClientUnlockGroup(TechGroup techGroup)
        {
            if (!techGroup.SharedCanUnlock(Client.Characters.CurrentPlayerCharacter, out var error))
            {
                NotificationSystem.ClientShowNotification(NotificationCannotUnlockTech,
                                                          error,
                                                          NotificationColor.Bad);
                return;
            }

            Instance.CallServer(_ => _.ServerRemote_UnlockGroup(techGroup));
        }
        public void ServerAddGroup(TechGroup techGroup)
        {
            if (this.Groups.Contains(techGroup))
            {
                return;
            }

            this.Groups.Add(techGroup);
            var character = this.Character;

            Api.Logger.Info("Tech group added: " + techGroup.ShortId, character);
            Api.SafeInvoke(() => CharacterGroupAddedOrRemoved?.Invoke(character, techGroup, isAdded: true));
        }
Ejemplo n.º 24
0
        /// <summary>
        ///     技術定義ファイルを読み込む
        /// </summary>
        /// <param name="fileName">技術定義ファイル名</param>
        private static void LoadFile(string fileName)
        {
            Log.Verbose("[Tech] Load: {0}", Path.GetFileName(fileName));

            TechGroup grp = TechParser.Parse(fileName);

            if (grp == null)
            {
                Log.Error("[Tech] Read error: {0}", Path.GetFileName(fileName));
                return;
            }
            Groups.Add(grp);
        }
Ejemplo n.º 25
0
        private void NeedsResearch(MyDefinitionId techDef, TechGroup techgroup)
        {
            MyVisualScriptLogicProvider.ResearchListAddItem(techDef);

            HashSet <MyDefinitionId> techsInGroup;

            if (!techsForGroup.TryGetValue(techgroup, out techsInGroup))
            {
                techsInGroup = new HashSet <MyDefinitionId>();
                techsForGroup.Add(techgroup, techsInGroup);
            }
            techsInGroup.Add(techDef);
        }
Ejemplo n.º 26
0
        public static void ServerUnlockGroup(ICharacter character, TechGroup techGroup)
        {
            techGroup.SharedValidateCanUnlock(character, skipLearningPointsCheck: false);
            var technologies = character.SharedGetTechnologies();

            technologies.ServerRemoveLearningPoints(techGroup.LearningPointsPrice);
            technologies.ServerAddGroup(techGroup);
            technologies.IsTechTreeChanged = false;

            foreach (var rootNode in techGroup.RootNodes)
            {
                technologies.ServerAddNode(rootNode);
            }
        }
Ejemplo n.º 27
0
        public static void AddToCustomGroup(TechGroup group, TechCategory category, TechType techType)
        {
            //if (!customGroups.ContainsKey(group))
            //    customGroups.Add(group, new Dictionary<TechCategory, List<TechType>>());
            //if (!customGroups[group].ContainsKey(category))
            //    customGroups[group][category] = new List<TechType>();
            //customGroups[group][category].Add(techType);

            var groups = GroupsField.GetValue(null) as Dictionary <TechGroup, Dictionary <TechCategory, List <TechType> > >;

            groups[group][category].Add(techType);

            Logger.Log($"Added \"{techType.AsString():G}\" to groups under \"{group:G}->{category:G}\"");
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Safely looks for a modded item from another mod in the SMLHelper TechGroupCache and outputs its <see cref="TechGroup" /> value when found.
        /// </summary>
        /// <param name="techGroupString">The string used to define the techgroup.</param>
        /// <param name="modTechGroup">The TechGroup enum value of the modded. Defaults to <see cref="TechGroup.Uncategorized" /> when the item was not found.</param>
        /// <returns>
        ///   <c>True</c> if the item was found; Otherwise <c>false</c>.
        /// </returns>
        public bool TryGetModdedTechGroup(string techGroupString, out TechGroup modTechGroup)
        {
            EnumTypeCache cache = TechGroupPatcher.cacheManager.RequestCacheForTypeName(techGroupString, false);

            if (cache != null) // Item Found
            {
                modTechGroup = (TechGroup)cache.Index;
                return(true);
            }
            else // Mod not present or not yet loaded
            {
                modTechGroup = TechGroup.Uncategorized;
                return(false);
            }
        }
Ejemplo n.º 29
0
 public TraitDefinitions()
 {
     _gameplayAffinityGroup            = new GameplayAffinityGroup();
     _visualAffinityGroup              = new VisualAffinityGroup();
     _factionTraitGroup                = new FactionTraitGroup();
     _homePlanetGroup                  = new HomePlanetGroup();
     _minorPopulationGroup             = new MinorPopulationGroup();
     _primaryPopulationModifierGroup   = new PrimaryPopulationModifierGroup();
     _secondaryPopulationModifierGroup = new SecondaryPopulationModifierGroup();
     _tertiaryPopulationModifierGroup  = new TertiaryPopulationModifierGroup();
     _primaryPoliticsGroup             = new PrimaryPoliticsGroup();
     _secondaryPoliticsGroup           = new SecondaryPoliticsGroup();
     _governmentGroup                  = new GovernmentGroup();
     _techGroup = new TechGroup();
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Registers the TechCategory to a TechGroup in CraftData.groups.
        /// </summary>
        /// <param name="techGroup">The tech group.</param>
        /// <param name="techCategory">The tech category.</param>
        /// <returns></returns>
        public bool TryRegisterTechCategoryToTechGroup(TechGroup techGroup, TechCategory techCategory)
        {
            if (!CraftData.groups.TryGetValue(techGroup, out var techCategories))
            {
                //Should not even really be possible but just incase.
                return(false);
            }

            if (techCategories.ContainsKey(techCategory))
            {
                return(true);
            }

            techCategories[techCategory] = new List <TechType>();
            return(true);
        }