Exemplo n.º 1
0
        internal void AddCompoundUnlock(TechType techType, List <TechType> compoundTechsForUnlock)
        {
            if (techType == TechType.None)
            {
                Logger.Error("Cannot Add Unlock to TechType.None!");
                return;
            }

            if (compoundTechsForUnlock.Contains(techType))
            {
                Logger.Error("Cannot Add Compound Unlock that contains itself!");
                return;
            }


            if (KnownTechPatcher.CompoundTech.TryGetValue(techType, out KnownTech.CompoundTech compoundTech))
            {
                Logger.Debug($"Compound Unlock already found for {techType.AsString()}, Overwriting.");
                compoundTech.dependencies = compoundTechsForUnlock;
            }
            else
            {
                Logger.Debug($"Adding Compound Unlock for {techType.AsString()}");
                KnownTechPatcher.CompoundTech.Add(techType, new KnownTech.CompoundTech()
                {
                    techType = techType, dependencies = compoundTechsForUnlock
                });
            }
        }
Exemplo n.º 2
0
 internal void AddAnalysisTech(TechType techTypeToBeAnalysed, IEnumerable <TechType> techTypesToUnlock, string UnlockMessage = "NotificationBlueprintUnlocked", FMODAsset UnlockSound = null, UnityEngine.Sprite UnlockSprite = null)
 {
     if (techTypeToBeAnalysed != TechType.None)
     {
         if (KnownTechPatcher.AnalysisTech.TryGetValue(techTypeToBeAnalysed, out KnownTech.AnalysisTech existingEntry))
         {
             existingEntry.unlockMessage = existingEntry.unlockMessage ?? UnlockMessage;
             existingEntry.unlockSound   = existingEntry.unlockSound ?? UnlockSound;
             existingEntry.unlockPopup   = existingEntry.unlockPopup ?? UnlockSprite;
             existingEntry.unlockTechTypes.AddRange(techTypesToUnlock);
         }
         else
         {
             KnownTechPatcher.AnalysisTech.Add(techTypeToBeAnalysed, new KnownTech.AnalysisTech()
             {
                 techType        = techTypeToBeAnalysed,
                 unlockMessage   = UnlockMessage,
                 unlockSound     = UnlockSound,
                 unlockPopup     = UnlockSprite,
                 unlockTechTypes = new List <TechType>(techTypesToUnlock)
             });
         }
     }
     else
     {
         Logger.Error("Cannot Add Unlock to TechType.None!");
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new <see cref="Texture2D" /> from an image file.
        /// </summary>
        /// <param name="filePathToImage">The path to the image file.</param>
        /// <param name="format">
        /// <para>The texture format. By default, this uses <see cref="TextureFormat.BC7" />.</para>
        /// <para>https://docs.unity3d.com/ScriptReference/TextureFormat.BC7.html</para>
        /// <para>Don't change this unless you really know what you're doing.</para>
        /// </param>
        /// <returns>Will return a new <see cref="Texture2D"/> instance if the file exists; Otherwise returns null.</returns>
        /// <remarks>
        /// Ripped from: https://github.com/RandyKnapp/SubnauticaModSystem/blob/master/SubnauticaModSystem/Common/Utility/ImageUtils.cs
        /// </remarks>
        public static Texture2D LoadTextureFromFile(string filePathToImage, TextureFormat format = TextureFormat.BC7)
        {
            if (File.Exists(filePathToImage))
            {
                byte[] imageBytes = File.ReadAllBytes(filePathToImage);
                var    texture2D  = new Texture2D(2, 2, format, false);
                try
                {
                    texture2D.LoadImage(imageBytes);
                    return(texture2D);
                }
                catch (UnityException uex)
                {
                    Logger.Error("Error on LoadTextureFromFile call. Texture cannot be loaded: " + uex);
                }
            }
            else
            {
                Logger.Log("Error on LoadTextureFromFile call. File not found at " + filePathToImage, LogLevel.Error);
            }

            return(null);
        }