Example #1
0
        public void UpdateNumbers()
        {
            Drillable drillable = gameObject.EnsureComponent <Drillable>();

            drillable.minResourcesToSpawn = Min;
            drillable.maxResourcesToSpawn = Max;
        }
Example #2
0
    // Start is called before the first frame update
    void Start()
    {
        drillable = FindObjectOfType <Drillable>();
        parentRb  = GetComponentInParent <Rigidbody2D>();
        //col = GetComponent<PolygonCollider2D>();
        Invoke("MakeCave", .5f); // Small delay to let map spawn first

        Destroy(this.gameObject, 1);
    }
Example #3
0
        public static void PostStart(Drillable __instance)
        {
            if (__instance.gameObject.TryGetComponent <LargeWorldEntity>(out LargeWorldEntity lwe))
            {
                lwe.cellLevel = LargeWorldEntity.CellLevel.Far;
            }
#if SUBNAUTICA_STABLE
            __instance.kChanceToSpawnResources = Mathf.Max(DWConstants.newKyaniteChance, __instance.kChanceToSpawnResources);
#endif
        }
Example #4
0
        static bool Prefix(Drillable __instance)
        {
            // Call the BetterDrillable.HoverDrillable function
            var betterDrillable = __instance.GetComponent <BetterDrillable>();

            betterDrillable.HoverDrillable();

            // Return out of original method.
            return(false);
        }
Example #5
0
        static bool Prefix(Drillable __instance)
        {
            // Call the BetterDrillable.ManagedUpdate method
            var betterDrillable = __instance.GetComponent <BetterDrillable>();

            betterDrillable.ManagedUpdate();

            // Return out of original method.
            return(false);
        }
Example #6
0
        static bool Prefix(Drillable __instance, Vector3 position, Exosuit exo, out GameObject hitObject)
        {
            // Call the BetterDrillable.OnDrill function
            var betterDrillable = __instance.GetComponent <BetterDrillable>();

            betterDrillable.OnDrill(position, exo, out hitObject);

            // Return out of original method
            return(false);
        }
Example #7
0
        static bool Prefix(Drillable __instance)
        {
            if (Player.main.inSeamoth)
            {
                __instance.GetComponent <SeamothDrillable>().HoverDrillable();

                return(false);
            }

            return(true);
        }
        static bool Prefix(Drillable __instance)
        {
            if (Player.main.IsPilotingSeatruck())
            {
                var seatruckDrillable = __instance.GetComponent <SeaTruckDrillable>();
                seatruckDrillable.HoverDrillable();

                return(false);
            }

            return(true);
        }
Example #9
0
 public static void Postfix(Drillable __instance)
 {
     try
     {
         CDC_Config cdc = __instance.gameObject.AddComponent <CDC_Config>();
         Logger.Log("Added component to Drillable!", QMod.assembly);
     }
     catch (Exception e)
     {
         Logger.Exception(e, LoggedWhen.InPatch, QMod.assembly);
     }
 }
Example #10
0
 public void UpdateNumbers()
 {
     try
     {
         Drillable drillable = gameObject.GetComponent <Drillable>();
         drillable.minResourcesToSpawn = Min;
         drillable.maxResourcesToSpawn = Max;
     }
     catch (Exception e)
     {
         Logger.Exception(e);
     }
 }
Example #11
0
        static void Prefix(Drillable __instance)
        {
            // Add BetterDrillable component to the Drillable GameObject
            var betterDrillable = __instance.gameObject.AddComponent <BetterDrillable>();

            betterDrillable.drillable = __instance;

            // Set the fields
            betterDrillable.resources           = __instance.resources;
            betterDrillable.breakFX             = __instance.breakFX;
            betterDrillable.breakAllFX          = __instance.breakAllFX;
            betterDrillable.primaryTooltip      = __instance.primaryTooltip;
            betterDrillable.secondaryTooltip    = __instance.secondaryTooltip;
            betterDrillable.deleteWhenDrilled   = __instance.deleteWhenDrilled;
            betterDrillable.modelRoot           = __instance.modelRoot;
            betterDrillable.minResourcesToSpawn = __instance.minResourcesToSpawn;
            betterDrillable.maxResourcesToSpawn = __instance.maxResourcesToSpawn;
            betterDrillable.lootPinataOnSpawn   = __instance.lootPinataOnSpawn;
            betterDrillable.health = __instance.health;
        }
Example #12
0
 public void Awake()
 {
     drill = GetComponent <Drillable>();
 }
Example #13
0
            public static void Postfix(Drillable __instance)
            {
                CDC_Config cdc = __instance.gameObject.AddComponent <CDC_Config>();

                Logger.Log("Added component to Drillable!");
            }
Example #14
0
 public static void Postfix(Drillable __instance)
 {
     __instance.minResourcesToSpawn     = QMultiModSettings.Instance.MinDrillableAmount;
     __instance.maxResourcesToSpawn     = QMultiModSettings.Instance.MaxDrillableAmount;
     __instance.kChanceToSpawnResources = QMultiModSettings.Instance.DrillableSpawnChanceMultiplier;
 }
 public static void Postfix(Drillable __instance)
 {
     __instance.gameObject.EnsureComponent <SharkDrillable>();
 }
        static void Postfix(Drillable __instance)
        {
            __instance.gameObject.EnsureComponent <SeaTruckDrillable>();

            BZLogger.Log($"SeatruckDrillable component added in Drillable.Start -> Postfix Patch. ID: {__instance.GetInstanceID()}");
        }
        public void Update()
        {
            upgradeModels.SetActive(upgradeInstalled);
            if (!active)
            {
                return;
            }
            if (drilling)
            {
                if (!shark.fxControl.drillFX.isPlaying)
                {
                    shark.fxControl.drillFX.Play();
                }
            }
            else
            {
                if (shark.fxControl.drillFX.isPlaying)
                {
                    shark.fxControl.drillFX.Stop(false, ParticleSystemStopBehavior.StopEmitting);
                }
            }
            drillTarget = null;
            GameObject target = null;
            Vector3    zero   = Vector3.zero;

            UWE.Utils.TraceFPSTargetPosition(gameObject, 20f, ref target, ref zero);
            if (target == null)
            {
                InteractionVolumeUser user = Player.main.GetComponent <InteractionVolumeUser>();
                if (user != null && user.GetMostRecent() != null)
                {
                    target = user.GetMostRecent().gameObject;
                }
            }

            Drillable drillable = target.FindAncestor <Drillable>();

            if (drillable)
            {
                drillTarget = drillable.GetComponent <SharkDrillable>();
                HandReticle.main.SetInteractText(Language.main.GetFormat <string>("DrillResource", Language.main.Get(drillTarget.drill.primaryTooltip)), drillTarget.drill.secondaryTooltip, false, true, HandReticle.Hand.Left);
                HandReticle.main.SetIcon(HandReticle.IconType.Drill, 1f);
                float distToTarget = Vector3.Distance(shark.fxControl.drillFX.transform.parent.position, drillTarget.transform.position);
                ParticleSystem.EmissionModule em = shark.fxControl.drillFX.emission;
                em.rateOverTime = 200 * distToTarget;
                ParticleSystem.ShapeModule shape = shark.fxControl.drillFX.shape;
                shape.scale = new Vector3(0.3f, 0.3f, distToTarget);

                Vector3 targetVector = drillTarget.transform.position - shark.fxControl.drillFX.transform.parent.position;
                targetVector.Normalize();

                shark.fxControl.drillFX.transform.localPosition  = new Vector3(0f, 0f, distToTarget / 2f);
                shark.fxControl.drillFX.transform.parent.forward = targetVector;
            }
            else
            {
                ParticleSystem.EmissionModule em = shark.fxControl.drillFX.emission;
                em.rateOverTime = 4000;
                ParticleSystem.ShapeModule shape = shark.fxControl.drillFX.shape;
                shape.scale = new Vector3(0.3f, 0.3f, 20f);

                shark.fxControl.drillFX.transform.localPosition    = new Vector3(0f, 0f, 10f);
                shark.fxControl.drillFX.transform.localEulerAngles = Vector3.zero;
            }
        }
Example #18
0
 static void Postfix(Drillable __instance)
 {
     __instance.gameObject.AddIfNeedComponent <SeamothDrillable>();
 }
 static bool Prefix(Drillable __instance)
 {
     __instance.SendMessage("OnBreakResource", null, SendMessageOptions.DontRequireReceiver);
     return(true);
 }
Example #20
0
        internal static IEnumerator PostPatchCoroutine()
        {
            foreach (TechType tt in new HashSet <TechType>()
            {
                TechType.Exosuit,
#if SUBNAUTICA_STABLE
                TechType.Seamoth,
                TechType.Cyclops,
#elif BELOWZERO
                TechType.SeaTruck,
                TechType.Hoverbike
#endif
            })
            {
                CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(tt);
                yield return(task);

                GameObject prefab = task.GetResult();
                if (prefab != null)
                {
                    LiveMixin mixin = prefab.GetComponent <LiveMixin>();
                    if (mixin?.data != null)
                    {
                        Main.defaultHealth.Add(tt, mixin.data.maxHealth);
                        Log.LogDebug($"For TechType {tt.AsString()}, got default health of {mixin.data.maxHealth}");
                    }
                    else
                    {
                        Log.LogDebug($"Failed to get LiveMixin for TechType {tt.AsString()}");
                    }
                }
                else
                {
                    Log.LogDebug($"Failed to get prefab for TechType {tt.AsString()}");
                }
            }

            foreach (TechType tt in new HashSet <TechType>()
            {
                TechType.DrillableAluminiumOxide,
                TechType.DrillableCopper,
                TechType.DrillableDiamond,
                TechType.DrillableGold,
                TechType.DrillableKyanite,
                TechType.DrillableLead,
                TechType.DrillableLithium,
                TechType.DrillableMagnetite,
                TechType.DrillableMercury,
                TechType.DrillableNickel,
                TechType.DrillableQuartz,
                TechType.DrillableSalt,
                TechType.DrillableSilver,
                TechType.DrillableSulphur,
                TechType.DrillableTitanium,
                TechType.DrillableUranium
            })
            {
                Log.LogInfo($"Fixing Cell Level for TechType {tt.AsString()}");
                var classid = CraftData.GetClassIdForTechType(tt);
                if (WorldEntityDatabase.TryGetInfo(classid, out var worldEntityInfo))
                {
                    worldEntityInfo.cellLevel = LargeWorldEntity.CellLevel.VeryFar;

                    WorldEntityDatabase.main.infos[classid] = worldEntityInfo;
                }

                CoroutineTask <GameObject> task = CraftData.GetPrefabForTechTypeAsync(tt);
                yield return(task);

                GameObject prefab = task.GetResult();
                if (prefab != null)
                {
                    LargeWorldEntity lwe = prefab.GetComponent <LargeWorldEntity>();
                    if (lwe != null)
                    {
                        lwe.cellLevel = LargeWorldEntity.CellLevel.VeryFar;
                        Log.LogDebug($"CellLevel for TechType {tt.AsString()} updated to Far");
                    }
                    else
                    {
                        Log.LogWarning($"Could not find LargeWorldEntity component in prefab for TechType {tt.AsString()}");
                    }
#if SUBNAUTICA_STABLE
                    // Since we're here, make kyanite less troll-tastic.
                    Drillable drillable = prefab.GetComponent <Drillable>();
                    if (drillable != null && drillable.kChanceToSpawnResources < DWConstants.newKyaniteChance)
                    {
                        drillable.kChanceToSpawnResources = DWConstants.newKyaniteChance;
                    }
#endif
                }
                else
                {
                    Log.LogWarning($"Could not get prefab for TechType {tt.AsString()}");
                }
            }

            yield break;
        }
Example #21
0
 static void Postfix(Drillable __instance)
 {
     __instance.gameObject.EnsureComponent <SeamothDrillable>();
 }
 private void Awake()
 {
     drillable = GetComponent <Drillable>();
     renderers = GetComponentsInChildren <MeshRenderer>();
 }
        public static void Prefix(ExosuitDrillArm __instance)
        {
            try
            {
                var damage = Config.Instance.AddOtherDamage;
                if (damage <= 0)
                {
                    return;
                }

                var exosuit = ExosuitField.GetValue(__instance) as Exosuit;

                if (exosuit == null)
                {
                    QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: exosuit is null", null, true);
                    return;
                }

                if (exosuit.CanPilot() && exosuit.GetPilotingMode())
                {
                    Vector3    zero       = Vector3.zero;
                    GameObject gameObject = null;
                    Vector3    vector;
                    UWE.Utils.TraceFPSTargetPosition(exosuit.gameObject, 5f, ref gameObject, ref zero, out vector, true);

                    if (gameObject != null && gameObject && (bool)DrillingField.GetValue(__instance))
                    {
                        Drillable drillable = gameObject.FindAncestor <Drillable>();

                        if (!drillable)
                        {
                            LiveMixin liveMixin = gameObject.FindAncestor <LiveMixin>();
                            if (liveMixin)
                            {
                                liveMixin.IsAlive();
                                liveMixin.TakeDamage(damage, zero, DamageType.Drill, null);

                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, "Drill Extra Damaging: " + damage, null, true);

                                // Leave this for the real one
                                // this.drillTarget = gameObject;
                            }
                            return;
                        }

                        var maxHealth = Config.Instance.MaxDrillHealth;
                        var healths   = drillable.health;

                        QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Hitting drillable with healths: " + healths.Length, null, true);

                        for (int i = 0; i < healths.Length; i++)
                        {
                            if (healths[i] > maxHealth)
                            {
                                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Debug, $"Drillable health reduced from {healths[i]} to {maxHealth}", null, true);

                                healths[i] = maxHealth;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                QModManager.Utility.Logger.Log(QModManager.Utility.Logger.Level.Error, "Error: " + ex.ToString(), ex, true);
            }
        }