예제 #1
0
        public static void ApplyOptions()
        {
            try
            {
                foreach (var w in UnityEngine.Object.FindObjectsOfType <WaterBiomeManager>())
                {
                    w.Rebuild();
                }

                QualitySettings.masterTextureLimit = 4 - config.TextureQuality;

                foreach (var s in UnityEngine.Object.FindObjectsOfType <WaterSunShaftsOnCamera>())
                {
                    s.enabled = config.LightShafts;
                }

                if (!config.VariablePhysicsStep)
                {
                    Time.fixedDeltaTime           = 0.02f;
                    Time.maximumDeltaTime         = 0.33333f;
                    Time.maximumParticleDeltaTime = 0.03f;
                }

                config.Save();
            }
            catch (Exception e)
            {
                Logger.Log(Logger.Level.Error, msg: "Reload failed with Exception: \n", ex: e);
            }
        }
예제 #2
0
        //private List<RecipeOverride> defaultRecipeOverrides

        public bool TryOverrideRecipe(TechType fragment, out TechData outRecipe)
        {
            string sFragment = fragment.ToString();

            foreach (RecipeOverride r in RecipeOverrides)
            {
                if (sFragment == r.overridden)
                {
                    outRecipe = new TechData();
                    foreach (StringIngredient s in r.replacements)
                    {
                        if (Enum.TryParse <TechType>(s.techType, out TechType t))
                        {
                            outRecipe.Ingredients.Add(new Ingredient(t, s.amount));
                        }
                        else
                        {
#if !RELEASE
                            Logger.Log(Logger.Level.Error, $"Could not parse {s.techType} as TechType; check the spelling and/or case");
#endif
                            outRecipe = null;
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            outRecipe = null;
            return(false);
        }
예제 #3
0
            public bool AddTank(TechType tank, float baseCapacity, Sprite sprite = null, bool bUpdate = false, bool bUnlockAtStart = false)
            {
                if (TankTypes == null)
                {
                    TankTypes = new Dictionary <TechType, TankType>();
                }

                //if (TankTypes[i].tankTechType == tank)
                if (TankTypes.TryGetValue(tank, out TankType tt))
                {
                    if (bUpdate)
                    {
#if !RELEASE
                        Logger.Log(Logger.Level.Debug, $"Updating tank type for TechType '{tank.AsString()}' with value {baseCapacity}");
#endif
                        TankTypes[tank].UpdateCapacity(baseCapacity);
                    }
                    return(false);
                }
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"Adding Tank '{tank.AsString()}' with capacity of {baseCapacity}");
#endif
                TankTypes[tank] = new TankType(tank, baseCapacity, bUnlockAtStart: bUnlockAtStart);
                return(true);
            }
예제 #4
0
        public bool TrySubstituteIngredient(TechType tech, out List <Ingredient> Substitutes)
        {
            Substitutes = new List <Ingredient>();
            for (int i = 0; i < SubstitutionList.Count; i++)
            {
                if (tech.ToString() == SubstitutionList[i].replacedTech)
                {
                    //for (int j = 0; j < SubstitutionList[i].replacements.Count; j++)
                    foreach (StringIngredient si in SubstitutionList[i].replacements)
                    {
                        if (Enum.TryParse <TechType>(si.techType, out TechType tt))
                        {
                            Substitutes.Add(new Ingredient(tt, si.amount));
                        }
                        else
                        {
#if !RELEASE
                            Logger.Log(Logger.Level.Error, $"Failed to parse string '{si.techType}' as TechType; check to make sure the entry is spelled correctly, and using the correct case");
#endif
                        }
                    }
                    //Substitutes = SubstitutionList[i].replacements;
                    return(Substitutes.Count > 0);                      // It's possible every single entry in the list failed to parse; we don't want to return true in that instance. But this condition is an easy fix.
                }
            }

            // We only get this far if the tech to be replaced doesn't match this object's replacedTech.
            Substitutes = null;
            return(false);
        }
예제 #5
0
        public static void Patch()
        {
            Logger.Log(Logger.Level.Info, "Patched successfully!");

            /// Here we are registering a console command by use of a delegate. The delegate will respond to the "delegatecommand"
            /// command from the dev console, passing values following "delegatecommand" as the correct types, provided they can be
            /// parsed to that type. For example, "delegatecommand foo 3 true" would be a valid command for the
            /// <see cref="MyCommand"/> delegate signature. You can also use Func or Action to define your delegate signatures
            /// if you prefer, and you can also pass a reference to a method that matches this signature.
            ///
            /// Registered commands must be unique. If another mod has already added the command, your command will be rejected.
            ///
            /// If the user enters incorrect parameters for a command, they will be notified of the expected parameter types,
            /// both on-screen and in the log.
            ///
            /// Note that a command can have a return type, but it is not necessary. If it does return any type, it will be printed
            /// both on-screen and in the log.
            ConsoleCommandsHandler.Main.RegisterConsoleCommand <MyCommand>("delegatecommand", (myString, myInt, myBool) =>
            {
                return($"Parameters: {myString} {myInt} {myBool}");
            });

            /// Here we are registering all console commands defined in <see cref="ExampleMod"/>, defined by decorating them
            /// with the <see cref="ConsoleCommandAttribute"/>. See <see cref="MyAttributedCommand(string, int, bool)"/> below
            /// for an example.
            ConsoleCommandsHandler.Main.RegisterConsoleCommands(typeof(ExampleMod));
        }
예제 #6
0
        // Attempt to get the text for a vehicle prompt.
        // initialKey should be "Enter", "Exit" or "Leave", followed by "Seamoth", "Exosuit" or "Cyclops". Any other value will return false.
        public static bool TryGetVehiclePrompt(string initialKey, string targetLanguage, string VehicleName, out string prompt)
        {
            string targetKey = targetLanguage + initialKey;
            bool   result;

            if (string.IsNullOrEmpty(VehicleName))
            {
                prompt = Language.main.Get(initialKey);
                return(true);
            }
            else
            {
                result = vehiclePromptDict.TryGetValue(targetKey, out prompt);
                if (result)
                {
                    prompt = prompt.Replace("<vehicle>", VehicleName);
                }
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"Main.TryGetVehiclePrompt: got prompt value of {prompt} with key {targetKey}");
#endif
            }

            //return vehiclePromptDict.TryGetValue(targetKey, out prompt);
            return(result);
        }
예제 #7
0
        private void Start()
        {
            _light            = GetComponentInChildren <Light>(true);
            _renderers        = transform.GetChild(0).GetComponentsInChildren <Renderer>(true);
            _particleRenderer = _renderers.First(r => r.material.shader.name.Contains("Particle"));

            PrefabIdentifier prefabIdentifier = GetComponentInParent <PrefabIdentifier>();

            if ((prefabIdentifier ??= GetComponent <PrefabIdentifier>()) is null)
            {
                return;
            }

            string saveFolder = Main.GetSaveFolderPath();
            string filePath   = Main.Combine(saveFolder, prefabIdentifier.Id + ".json");

            if (File.Exists(filePath))
            {
                ColorInfo colorInfo;
                using (StreamReader reader = new StreamReader(filePath))
                {
                    var serializer = new JsonSerializer();
                    colorInfo = serializer.Deserialize(reader, typeof(ColorInfo)) as ColorInfo;
                }

                if (colorInfo != null)
                {
                    _savedColor = new Color(colorInfo.RedLevel, colorInfo.GreenLevel, colorInfo.BlueLevel);
                    _dirty      = true;
                    return;
                }
                Logger.Log(Logger.Level.Warn, "colorInfo is null");
            }
        }
예제 #8
0
 private static bool TryCreateModParticleParams(Workbench workbench)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparks = ((GameObject[])sparksField.GetValue(workbench))[0].GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparks.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         Logger.Log(Logger.Level.Error, null, e);
         return(false);
     }
 }
예제 #9
0
        static IEnumerable <CodeInstruction> Transpiler(IEnumerable <CodeInstruction> instructions)
        {
            List <CodeInstruction> codes = new(instructions);

            var pickupText = AccessTools.Method(typeof(ExosuitPatcher), nameof(PickupText));

            bool found = false;

            for (int i = 0; i < codes.Count(); i++)
            {
                if (codes[i].opcode == OpCodes.Ldstr && (string)codes[i].operand == "PropulsionCannonToRelease")
                {
                    codes.Insert(i + 5, new CodeInstruction(OpCodes.Ldarg_0));
                    codes.Insert(i + 6, new CodeInstruction(OpCodes.Call, pickupText));

                    found = true;
                    break;
                }
            }

            if (found is true)
            {
                Logger.Log(Logger.Level.Debug, "Transpiler Succeeded!");
            }
            else
            {
                Logger.Log(Logger.Level.Error, "Transpiler Failed.");
            }

            return(codes.AsEnumerable());
        }
예제 #10
0
        private static void CreateAndPatchPacks()
        {
            Logger.Log(Logger.Level.Info, "Started Patching BioPlasma MK2");

            var bioPlasma = new BioPlasma();

            bioPlasma.Patch();

            Logger.Log(Logger.Level.Info, "Finished Patching BioPlasma MK2");

            var bioChemBattery = new CbBattery()
            {
                ID                = "BioChemBatteryMK2",
                Name              = "Biochemical Battery",
                FlavorText        = "Alterra battery technology combined with a Warper power core makes for quite a potent renewable energy source.",
                EnergyCapacity    = Config.BioChemBatteryEnergy,
                UnlocksWith       = bioPlasma.TechType,
                CraftingMaterials = new List <TechType>()
                {
                    bioPlasma.TechType, bioPlasma.TechType,
                    TechType.Silver, TechType.Silver,
                    TechType.Gold,
                    TechType.Lead
                },
                CustomIcon  = new Atlas.Sprite(assetBundle.LoadAsset <Sprite>("BioChemBattery")),
                CBModelData = new CBModelData()
                {
                    UseIonModelsAsBase = true,
                    CustomTexture      = assetBundle.LoadAsset <Texture2D>("BioChemBatteryskin"),
                    CustomSpecMap      = assetBundle.LoadAsset <Texture2D>("BioChemBatteryspec"),
                    CustomIllumMap     = assetBundle.LoadAsset <Texture2D>("BioChemBatteryillum"),
                },
            };

            bioChemBattery.Patch();

            var bioChemCell = new CbPowerCell()
            {
                ID                = "BioChemCellMK2",
                Name              = "Biochemical Power Cell",
                FlavorText        = "Alterra power cell technology combined with a Warper power core makes for quite a potent renewable energy source.",
                EnergyCapacity    = Config.BioChemCellenergy,
                UnlocksWith       = bioPlasma.TechType,
                CraftingMaterials = new List <TechType>()
                {
                    bioChemBattery.TechType, bioChemBattery.TechType,
                    TechType.Silicone
                },
                CustomIcon  = new Atlas.Sprite(assetBundle.LoadAsset <Sprite>("BioChemCell.png")),
                CBModelData = new CBModelData()
                {
                    UseIonModelsAsBase = true,
                    CustomTexture      = assetBundle.LoadAsset <Texture2D>("BioChemCellskin"),
                    CustomSpecMap      = assetBundle.LoadAsset <Texture2D>("BioChemCellskin"),
                    CustomIllumMap     = assetBundle.LoadAsset <Texture2D>("BioChemCellillum")
                },
            };

            bioChemCell.Patch();
        }
예제 #11
0
        public void Activate()
        {
            spin                      = gameObject.FindChild("Blade Parent").EnsureComponent <TurbineSpin>();
            powerSource               = gameObject.EnsureComponent <PowerSource>();
            powerSource.maxPower      = QPatch.config.MaxPower;
            relay                     = gameObject.EnsureComponent <PowerRelay>();
            relay.internalPowerSource = powerSource;
            relay.dontConnectToRelays = false;
            relay.maxOutboundDistance = 50;
            //relay.powerSystemPreviewPrefab = Resources.Load<GameObject>("Base/Ghosts/PowerSystemPreview.prefab");

            if (relayPrefab != null)
            {
                PowerFX yourPowerFX = gameObject.AddComponent <PowerFX>();

                yourPowerFX.vfxPrefab   = relayPrefab.powerFX.vfxPrefab;
                yourPowerFX.attachPoint = gameObject.transform;
                relay.powerFX           = yourPowerFX;
            }

#if SUBNAUTICA
            Resources.UnloadAsset(powerRelay);
#endif
            relay.UpdateConnection();

            if (QPatch.config.TurbineMakesNoise)
            {
                SetupAudio();
            }
            Logger.Log(Logger.Level.Debug, $"WindTurbine.Activate: end");
        }
예제 #12
0
        public bool InitSubstitutions()
        {
            if (SubstitutionList == null)
            {
#if !RELEASE
                Logger.Log(Logger.Level.Warn, "No SubstitutionList found, setting default values");
#endif
                SubstitutionList = new List <SSubstitutionEntry>()
                {
                    new SSubstitutionEntry(
                        "AdvancedWiringKit",
                        new List <StringIngredient> {
                        new StringIngredient("Silver", 2),
                        new StringIngredient("ComputerChip", 1)
                    }
                        ),
                    new SSubstitutionEntry(
                        "PlasteelIngot",
                        new List <StringIngredient> {
#if SUBNAUTICA_STABLE
                        new StringIngredient("ScrapMetal", 2),
                        new StringIngredient("Lithium", 1)
#elif BELOWZERO
                        new StringIngredient("ScrapMetal", 1),
                        new StringIngredient("Lithium", 1)
#endif
                    }
예제 #13
0
        // The gloves texture is used for the suit as well, on the arms, so we need to do something about that.
        // The block that generates the glove texture is sizable, so it's made into a function here.
        private static Material GetGloveMaterial(Shader shader, Material OriginalMaterial)
        {
            // if the gloves shader isn't null, add the shader
            //Logger.Log(Logger.Level.Debug, "Creating new brineGloveMaterial");
            if (OriginalMaterial != null)
            {
                Material newMat = new Material(OriginalMaterial);
                // if the suit's shader isn't null, add the shader
                if (shader != null)
                {
                    newMat.shader = shader;
                }
                // add the gloves main Texture when equipped
                //Logger.Log(Logger.Level.Debug, $"add the gloves main Texture when equipped");
                newMat.mainTexture = Main.glovesTexture;
                // add  the gloves illum texture when equipped
                //Logger.Log(Logger.Level.Debug, $"add  the gloves illum texture when equipped");
                newMat.SetTexture(ShaderPropertyID._Illum, Main.glovesIllumTexture);
                // add  the gloves spec texture when equipped
                //Logger.Log(Logger.Level.Debug, $"add  the gloves spec texture when equipped");
                newMat.SetTexture(ShaderPropertyID._SpecTex, Main.glovesTexture);

                return(newMat);
            }
            else
            {
#if !RELEASE
                Logger.Log(Logger.Level.Debug, "Default material not found while trying to create new brineGloveMaterial");
#endif
            }

            return(null);
        }
예제 #14
0
        public static bool PreAllowedToAdd(Equipment __instance, ref bool __result, string slot, Pickupable pickupable, bool verbose)
        {
            //Log.LogDebug($"EquipmentPatches.PreAllowedToAdd(): __result = {__result}, slot = '{slot}'");

            TechType objTechType = pickupable.GetTechType();
            //Log.LogDebug($"EquipmentPatches.PreAllowedToAdd(): objTechType = {objTechType.AsString()}");
            EquipmentType slotType = Equipment.GetSlotType(slot);

            if (slotType == EquipmentType.BatteryCharger && InventoryPatches.IsChip(objTechType))
            {
#if BELOWZERO
                EquipmentType eType = TechData.GetEquipmentType(objTechType);
#else
                EquipmentType eType = CraftData.GetEquipmentType(objTechType);
#endif
                if (eType == EquipmentType.Chip || eType == EquipmentType.BatteryCharger)
                {
#if false
                    Logger.Log("DEBUG: AllowedToAdd battery charger for " + objTechType.AsString(false));
#endif
                    bool result = ((IItemsContainer)__instance).AllowedToAdd(pickupable, verbose);
                    __result = result;
                    return(false);
                }
            }

            return(true);
        }
예제 #15
0
 private static bool TryCreateModParticleParams(Fabricator fabricator)
 {
     if (modParticlesParams != null)
     {
         return(true);
     }
     try
     {
         var sparksL = ((GameObject)sparksLFieldInfo.GetValue(fabricator)).GetComponent <ParticleSystem>();
         originParticlesParams = new ParticleSystemParameters()
         {
             startColor = sparksL.main.startColor
         };
         modParticlesParams = new ParticleSystemParameters()
         {
             startColor = Config.BeamAlphaColor
         };
         return(true);
     }
     catch (Exception e)
     {
         Logger.Log(Logger.Level.Error, null, e);
         return(false);
     }
 }
예제 #16
0
        internal void Start()
        {
            Scene scene = SceneManager.GetActiveScene();

            numGameObjects = scene.rootCount;

            Application.logMessageReceived += HandleLog;
            DontDestroyOnLoad(this);

            //Load Player Settings
            windowMargin              = PlayerPrefs.GetInt("QModManager_PrefabDebugger_WindowMargin", 50);
            viewMargin                = PlayerPrefs.GetInt("QModManager_PrefabDebugger_ViewMargin", 10);
            showReadonlyProperties    = PlayerPrefs.GetInt("QModManager_PrefabDebugger_ShowReadonlyProperties", 0) == 1 ? true : false;
            showBlacklistedProperties = PlayerPrefs.GetInt("QModManager_PrefabDebugger_ShowBlacklistedProperties", 0) == 1 ? true : false;
            pauseWhenWindowOpen       = PlayerPrefs.GetInt("QModManager_PrefabDebugger_PauseWhenWindowOpen", 0) == 1 ? true : false;

            if (skinUWE == null)
            {
                guiBundle = AssetBundle.LoadFromFile(Path.Combine(Application.dataPath, "Managed/QModManagerAssets.unity3d"));
                if (guiBundle.LoadAsset("SubnauticaGUI") != null)
                {
                    skinUWE = (GUISkin)guiBundle.LoadAsset("SubnauticaGUI");

                    stop_symbol    = (Texture2D)guiBundle.LoadAsset("stop");
                    warning_symbol = (Texture2D)guiBundle.LoadAsset("warning");
                    log_symbol     = (Texture2D)guiBundle.LoadAsset("speech");
                }
                else
                {
                    Logger.Error("Could not load assets from \"QModManagerAssets.unity3d\"");
                }
            }
            LoadSceneObjects();
        }
예제 #17
0
        public static void Load()
        {
            var assembly = Assembly.GetExecutingAssembly();
            var harmony  = Harmony.CreateAndPatchAll(assembly, $"MrPurple6411_{assembly.GetName().Name}");

            var EasyCraft = AppDomain.CurrentDomain.GetAssemblies()
                            .Where((x) => x.FullName.StartsWith("EasyCraft"))
                            .FirstOrFallback(null);

            if (EasyCraft == null)
            {
                return;
            }
            var ClosestItemContainers = AccessTools.TypeByName("ClosestItemContainers");

            if (ClosestItemContainers == null)
            {
                return;
            }
            containers = AccessTools.Property(ClosestItemContainers, "containers");
            if (containers == null)
            {
                return;
            }
            var ClosestItemContainers_GetPickupCount = AccessTools.Method(ClosestItemContainers, "GetPickupCount");
            var ClosestItemContainers_DestroyItem    = AccessTools.Method(ClosestItemContainers, "DestroyItem");

            if (ClosestItemContainers_GetPickupCount == null || ClosestItemContainers_DestroyItem == null)
            {
                return;
            }
            harmony.Patch(ClosestItemContainers_GetPickupCount, prefix: new HarmonyMethod(typeof(ClosestItemContainers_Patches), nameof(ClosestItemContainers_Patches.ClosestItemContainers_GetPickupCount_Prefix)));
            harmony.Patch(ClosestItemContainers_DestroyItem, prefix: new HarmonyMethod(typeof(ClosestItemContainers_Patches), nameof(ClosestItemContainers_Patches.ClosestItemContainers_DestroyItem_Prefix)));
            Logger.Log(Logger.Level.Info, "Successfully Patched EasyCraft Methods.");
        }
예제 #18
0
        internal void Init()
        {
            if (NewScannables == null)
            {
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"NewScannables list is null, initialising defaults");
#endif
                NewScannables = new List <TechType>() // List of TechTypes to add ResourceTrackers to, if they don't have one already.
                {
                    TechType.BasaltChunk,
                    TechType.BaseFiltrationMachine,
                    TechType.BatteryChargerFragment,
                    TechType.Bleeder,
                    TechType.Crabsnake,
                    TechType.CrabSquid,
                    TechType.SeaCrown,
                    TechType.Warper
                };
            }

            if (NonScannables == null)
            {
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"NonScannables list is null, initialising defaults");
#endif
                NonScannables = new List <TechType>() // For any object whose TechType is on this list, its ResourceTracker, if it has one, should be removed.
                {
                    TechType.Wreck
                };
            }
        }
예제 #19
0
        private static bool LoadLanguageFile()
        {
            if (!File.Exists(languageFile))
            {
#if !RELEASE
                Logger.Log(Logger.Level.Error, "File does not exist");
#endif
                return(false);
            }

            JsonData jsonData;
            using (StreamReader streamReader = new StreamReader(languageFile))
            {
                try
                {
                    jsonData = JsonMapper.ToObject(streamReader);
                    //Logger.Log(Logger.Level.Debug, $"Read JSON data of: {JsonConvert.SerializeObject(jsonData, Oculus.Newtonsoft.Json.Formatting.Indented)}");
                }
                catch (Exception exception)
                {
                    Debug.LogException(exception);
                    return(false);
                }
            }

            foreach (string text in jsonData.Keys)
            {
                Main.vehiclePromptDict[text] = (string)jsonData[text];
            }
            return(true);
        }
예제 #20
0
 private static void SetFabricatorLightColor(Fabricator fabricator, Color color)
 {
     try
     {
         fabricator.fabLight.color = color;
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }
예제 #21
0
        public static void AddSubstitution(TechType substituted, TechType substitution)
        {
            Substitutions.Add(new TechTypeSub(substituted, substitution));
            substitutionTargets.Add(substitution);
#if !RELEASE
            Logger.Log(Logger.Level.Debug, $"AddSubstitution: Added sub with substituted {substituted.ToString()} and substitution {substitution.ToString()}, new count {Substitutions.Count}");
#endif
        }
        public static bool TryGetResourceName(string uniqueId, out string resourceName)
        {
            bool result = IdToResourceNameDict.TryGetValue(uniqueId, out resourceName);

            QLogger.Log(QLogger.Level.Debug, $"Attempting to retrieve resource name for unique ID '{uniqueId}': Result is {result}" + (result ? $", retrieved string '{resourceName}'" : ""));

            return(result);
        }
예제 #23
0
        /*internal class Pirate : MonoBehaviour
         * {
         *  internal static string videoURL;
         *  internal const string VideoURLObtainer = "https://you-link.herokuapp.com/?url=https://www.youtube.com/watch?v=i8ju_10NkGY";
         *
         *  internal static readonly HashSet<string> BannedGameObjectNames = new HashSet<string>()
         *  {
         *      "Audio",
         *      "WorldCursor",
         *      "Default Notification Center",
         *      "InputHandlerStack",
         *      "SelectorCanvas",
         *      "Clip Camera"
         *  };
         *
         *  internal void Start()
         *  {
         *      Canvas canvas = gameObject.AddComponent<Canvas>();
         *      canvas.renderMode = RenderMode.ScreenSpaceOverlay;
         *      gameObject.AddComponent<RawImage>();
         *
         *      gameObject.AddComponent<AudioListener>().enabled = true;
         *
         *      GetVideo();
         *  }
         *
         *  internal void Update()
         *  {
         *      RuntimeManager.MuteAllEvents(true);
         *      UWE.Utils.alwaysLockCursor = true;
         *      UWE.Utils.lockCursor = true;
         *      foreach (GameObject go in SceneManager.GetActiveScene().GetRootGameObjects())
         *      {
         *          if (BannedGameObjectNames.Contains(go.name)) DestroyImmediate(go);
         *      }
         *  }
         *
         *  internal void GetVideo()
         *  {
         *      if (!NetworkUtilities.CheckConnection())
         *      {
         *          ShowText();
         *          return;
         *      }
         *      try
         *      {
         *          ServicePointManager.ServerCertificateValidationCallback = NetworkUtilities.CustomSCVC;
         *
         *          using (WebClient client = new WebClient())
         *          {
         *              client.DownloadStringCompleted += (sender, e) =>
         *              {
         *                  if (e.Error != null)
         *                  {
         *                      UnityEngine.Logger.Exception(e.Error);
         *                      ShowText();
         *                      return;
         *                  }
         *                  if (!ParseVideo(e.Result)) ShowText();
         *              };
         *
         *              client.DownloadStringAsync(new Uri(VideoURLObtainer));
         *          }
         *      }
         *      catch (Exception e)
         *      {
         *          UnityEngine.Logger.Exception(e);
         *          ShowText();
         *      }
         *  }
         *  internal bool ParseVideo(string result)
         *  {
         *      if (result == null)
         *      {
         *          return false;
         *      }
         *      Dictionary<string, string>[] parsed;
         *      try
         *      {
         *          parsed = JsonConvert.DeserializeObject<Dictionary<string, string>[]>(result);
         *      }
         *      catch
         *      {
         *          return false;
         *      }
         *      if (parsed == null || parsed[0] == null)
         *      {
         *          return false;
         *      }
         *      Dictionary<string, string> firstLink = parsed[0];
         *      if (!firstLink.TryGetValue("url", out string url))
         *      {
         *          return false;
         *      }
         *      videoURL = url;
         *
         *      StartCoroutine(PlayVideo());
         *
         *      return true;
         *  }
         *
         *  internal IEnumerator PlayVideo()
         *  {
         *      VideoPlayer videoPlayer = gameObject.GetComponent<VideoPlayer>() ?? gameObject.AddComponent<VideoPlayer>();
         *      AudioSource audioSource = gameObject.GetComponent<AudioSource>() ?? gameObject.AddComponent<AudioSource>();
         *
         *      videoPlayer.enabled = true;
         *      audioSource.enabled = true;
         *
         *      videoPlayer.playOnAwake = false;
         *      audioSource.playOnAwake = false;
         *
         *      videoPlayer.errorReceived += (VideoPlayer source, string message) => UnityEngine.Debug.LogError(message);
         *
         *      videoPlayer.source = VideoSource.Url;
         *      videoPlayer.url = videoURL;
         *
         *      videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
         *      videoPlayer.controlledAudioTrackCount = 1;
         *      videoPlayer.EnableAudioTrack(0, true);
         *      videoPlayer.SetTargetAudioSource(0, audioSource);
         *
         *      videoPlayer.Prepare();
         *
         *      while (!videoPlayer.isPrepared)
         *      {
         *          yield return null;
         *      }
         *
         *      GetComponent<RawImage>().texture = videoPlayer.texture;
         *
         *      videoPlayer.Play();
         *
         *      yield return new WaitForSeconds(15);
         *      if (Patcher.game == Patcher.Game.Subnautica)
         *      {
         *          Process.Start("https://store.steampowered.com/app/264710/Subnautica/");
         *          Process.Start("https://www.epicgames.com/store/en-US/product/subnautica/home");
         *          Process.Start("https://discordapp.com/store/skus/489926636943441932/subnautica");
         *      }
         *      else
         *      {
         *          Process.Start("https://store.steampowered.com/app/848450/Subnautica_Below_Zero/");
         *          Process.Start("https://www.epicgames.com/store/en-US/product/subnautica-below-zero/home");
         *          Process.Start("https://discordapp.com/store/skus/535869836748783616/subnautica-below-zero");
         *      }
         *
         *      while (videoPlayer.isPlaying)
         *      {
         *          yield return null;
         *      }
         *
         *      Process.Start("https://www.youtube.com/watch?v=dQw4w9WgXcQ");
         *
         *      yield return StartCoroutine(PlayVideo());
         *  }
         *  internal void ShowText()
         *  {
         *      DestroyImmediate(gameObject.GetComponent<RawImage>());
         *      Text text = gameObject.AddComponent<Text>();
         *      text.text = $"An error has occured!\nQModManager couldn't be initialized.\nPlease go and actually purchase {(Patcher.game == Patcher.Game.Subnautica ? "Subnautica" : "Below Zero")}.\nPiracy is bad and hurts the game developer.";
         *      text.color = new Color(1, 0, 0);
         *      text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
         *      text.fontStyle = FontStyle.BoldAndItalic;
         *      text.fontSize = 40;
         *  }
         * }*/

        internal static void PirateDetected()
        {
            Logger.Warn("Ahoy, matey! Ye be a pirate!");

            /*Hooks.Update += Log;
             * GameObject obj = new GameObject("YOU ARE A PIRATE");
             * obj.AddComponent<Pirate>();*/
        }
예제 #24
0
 private static void SetWorkbenchLightColor(Workbench workbench, Color color)
 {
     try
     {
         workbench.workingLight.GetComponent <Light>().color = color;
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }
예제 #25
0
        public static void Load()
        {
            Logger.Log(Logger.Level.Info, "Started Patching");

            Config.Load();
            CreateAndPatchPacks();

            Logger.Log(Logger.Level.Info, "Patching Complete");
        }
예제 #26
0
        internal static void Main()
        {
            var debugger = new GameObject("PrefabDebugger");

            debugger.AddComponent <PrefabDebugger>();
            debuggerRectTransform = debugger.AddComponent <RectTransform>();
            inputGroup            = debugger.AddComponent <uGUI_InputGroup>();
            Logger.Debug("Debugger initialized");
        }
예제 #27
0
 private static void SetFabricatorBeamsMaterial(Fabricator fabricator, Material material)
 {
     try
     {
         fabricator.leftBeam.GetComponent <Renderer>().material  = material;
         fabricator.rightBeam.GetComponent <Renderer>().material = material;
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }
예제 #28
0
        private static GameObject SetupPrefab(GameObject activePrefab)
        {
            var obj = GameObject.Instantiate(activePrefab);

            if (obj == null)
            {
                return(null);
            }

            Knife knife = obj.GetComponent <Knife>();

            VibrobladeBehaviour blade = obj.EnsureComponent <VibrobladeBehaviour>();

            if (blade != null)
            {
                if (hbPrefab != null)
                {
                    HeatBlade hb = hbPrefab.GetComponent <HeatBlade>();
                    blade.fxControl    = hb.fxControl;
                    blade.vfxEventType = hb.vfxEventType;
                }
                if (knife != null)
                {
#if SUBNAUTICA_STABLE
                    blade.attackSound         = knife.attackSound;
                    blade.underwaterMissSound = knife.underwaterMissSound;
                    blade.surfaceMissSound    = knife.surfaceMissSound;
#endif
                    blade.mainCollider    = knife.mainCollider;
                    blade.drawSound       = knife.drawSound;
                    blade.firstUseSound   = knife.firstUseSound;
                    blade.hitBleederSound = knife.hitBleederSound;
                    if (hbPrefab == null)
                    {
                        blade.vfxEventType = knife.vfxEventType;
                    }
                    GameObject.DestroyImmediate(knife);
                }
                blade.attackDist    = 2f;
                blade.damageType    = DamageType.Normal;
                blade.socket        = PlayerTool.Socket.RightHand;
                blade.ikAimRightArm = true;
#if BELOWZERO
                blade.bleederDamage = 90f;
#endif
            }
            else
            {
#if !RELEASE
                Logger.Log(Logger.Level.Debug, $"Could not ensure VibrobladeBehaviour component in Vibroblade prefab");
#endif
            }

            ModPrefabCache.AddPrefab(obj, false);
            return(obj);
        }
예제 #29
0
 private static void SetWorkbenchBeamsMaterial(Workbench workbench, Material material)
 {
     try
     {
         foreach (var beam in workbench.fxLaserBeam)
         {
             beam.GetComponent <Renderer>().material = material;
         }
     }
     catch (Exception e) { Logger.Log(Logger.Level.Error, null, e); }
 }
예제 #30
0
        public static void Load()
        {
            if (!LoadLanguageFile())
            {
#if !RELEASE
                Logger.Log(Logger.Level.Error, $"Failed loading language file {languageFile}");
#endif
            }
            var assembly = Assembly.GetExecutingAssembly();
            new Harmony($"DaWrecka_{assembly.GetName().Name}").PatchAll(assembly);
        }