internal virtual void PostUpgradeModuleChange(int slotID, TechType techType, bool added, SeaTruckUpgrades instance)
        {
            if (parentVehicle == null)
            {
                parentVehicle = instance;
            }

            if (parentVehicle == null)
            {
                return;
            }

            if (techType == sonarModuleTechType)
            {
                if (added)
                {
                    sonarSlotID = slotID;
                }
                else
                {
                    sonarSlotID = -1;
                }
            }
            base.CancelInvoke("UpdateRecharge");
            base.CancelInvoke("UpdateSonar");
            solarCount   = parentVehicle.modules.GetCount(solarModuleTechType);
            thermalCount = parentVehicle.modules.GetCount(thermalModuleTechType);
            if (solarCount + thermalCount > 0)
            {
                base.InvokeRepeating("UpdateRecharge", 1f, 1f);
            }
        }
 internal void Initialise(ref SeaTruckUpgrades seaTruckUpgrades)
 {
     parentVehicle           = seaTruckUpgrades;
     parentMotor             = seaTruckUpgrades.motor;
     parentVehicle.onToggle += OnToggle;
     parentVehicle.onSelect += OnSelect;
 }
 protected void OnDestroy()
 {
     parentVehicle.onToggle -= OnToggle;
     parentVehicle.onSelect -= OnSelect;
     parentMotor             = null;
     parentVehicle           = null;
 }
        internal static void PostSeaTruckUpgradesModuleChange(ref SeaTruckUpgrades __instance, TechType techType)
        {
            QuickLogger.Debug($"{nameof(PostSeaTruckUpgradesModuleChange)} {techType.AsString()}", true);
            SeaTruckMotor cab = __instance.motor;

            //cab.gameObject.EnsureComponent<VehicleUpgrader>().UpgradeVehicle(techType, ref cab);
            CoroutineHost.StartCoroutine(DeferUpgrade(cab, techType));
        }
Beispiel #5
0
 static void Postfix(SeaTruckUpgrades __instance, int slotID, TechType techType, bool added)
 {
     if (techType == SeatruckBuilderModulePrefab.TechTypeID && added)
     {
         var control = __instance.gameObject.GetOrAddComponent <SeaTruckBuilderModule>();
         control.moduleSlotID = slotID + 1;
         return;
     }
 }
        public static bool Prefix(SeaTruckUpgrades __instance, TechType techType, int slotID)
        {
            if (ArmServices.main.IsSeaTruckArm(techType))
            {
                return(false);
            }

            return(true);
        }
Beispiel #7
0
        private void OnCollisionEnter(Collision collisionInfo)
        {
            SeaTruckUpgrades componentInParent = collisionInfo.gameObject.GetComponentInParent <SeaTruckUpgrades>();

            SeaTruckGrapplingHook component = collisionInfo.gameObject.GetComponent <SeaTruckGrapplingHook>();

            if (staticAttached || (fixedJoint && fixedJoint.connectedBody) || componentInParent != null || component != null)
            {
                return;
            }

            Rigidbody targetRigidbody = GetTargetRigidbody(collisionInfo.gameObject);

            rb.velocity = Vector3.zero;

            if (targetRigidbody != null && JointHelper.ConnectFixed(gameObject, targetRigidbody))
            {
                staticAttached = false;
            }
            else
            {
                staticAttached = true;
                UWE.Utils.SetIsKinematicAndUpdateInterpolation(rb, true);
            }

            Utils.PlayFMODAsset(hitSound, transform, 5f);

            Vector3 vector = default(Vector3);

            int num = 0;

            for (int i = 0; i < collisionInfo.contacts.Length; i++)
            {
                ContactPoint contactPoint = collisionInfo.contacts[i];
                if (num == 0)
                {
                    vector = contactPoint.normal;
                }
                else
                {
                    vector += contactPoint.normal;
                }
                num++;
            }
            if (num > 0)
            {
                vector /= num;
                Vector3 eulerAngles = Quaternion.LookRotation(transform.forward, vector).eulerAngles;
                eulerAngles.z        -= 90f;
                transform.eulerAngles = eulerAngles;
            }
            VFXSurface component2 = collisionInfo.gameObject.GetComponent <VFXSurface>();

            VFXSurfaceTypeManager.main.Play(component2, VFXEventTypes.impact, transform.position, transform.rotation, null);
        }
Beispiel #8
0
        static bool useStasisModuleSlot(SeaTruckUpgrades seatruck, int slotID)
        {
            if (!seatruck.ConsumeEnergy(Main.config.energyCost))
            {
                return(false);
            }

            seatruck.quickSlotTimeUsed[slotID] = Time.time;
            seatruck.quickSlotCooldown[slotID] = Main.config.cooldown;
            return(true);
        }
        public static bool PreSeatruckIsToggled(SeaTruckUpgrades __instance, ref bool __result, int slotID)
        {
            //__result = slotID >= 0 && slotID < SeaTruckUpgrades.slotIDs.Length && (TechData.GetSlotType(__instance.GetSlotBinding(slotID)) == QuickSlotType.Passive || this.quickSlotToggled[slotID]);
            __result = __result || __instance.gameObject.EnsureComponent <SeaTruckUpdater>().PreQuickSlotIsToggled(__instance, slotID);
            //Log.LogDebug($"PreSeatruckIsToggled: slotID = {slotID}, __result = {__result}");
            if (__result)
            {
                return(false);
            }

            return(true);
        }
        internal virtual void PostUpgradeModuleChange(int slotID, TechType techType, bool added, SeaTruckUpgrades instance)
        {
            if (parentVehicle == null && instance != null)
            {
                parentVehicle = instance;
                parentMotor   = instance.motor;
            }

            if (parentVehicle == null)
            {
                return;
            }


            if (techType == sonarModuleTechType)
            {
                if (added)
                {
                    sonarSlotID = slotID;
                }
                else
                {
                    sonarSlotID = -1;
                }
            }
            else if (techType == repairModuleTechType)
            {
                if (added)
                {
                    repairSlotID = slotID;
                }
                else
                {
                    repairSlotID = -1;
                }

                VehicleRepairComponent repairComponent = gameObject.EnsureComponent <VehicleRepairComponent>();
                repairComponent.SetEnabled(added, parentMotor);
                repairComponent.SetActiveState(false);
            }
            base.CancelInvoke("UpdateRecharge");
            base.CancelInvoke("UpdateSonar");

            solarCount   = parentVehicle.modules.GetCount(solarModuleTechType);
            thermalCount = parentVehicle.modules.GetCount(thermalModuleTechType);
            if (solarCount + thermalCount > 0)
            {
                base.InvokeRepeating("UpdateRecharge", 1f, 1f);
            }
        }
        internal static void Prefix(SeaTruckUpgrades __instance)
        {
            if (Main.SeatruckUpgradesCtorPatched)
            {
                BZLogger.Debug("SeaTruck constructor already patched. Exit method.");
                return;
            }

            __instance.SetPrivateField("slotIDs", SlotHelper.SessionSeatruckSlotIDs, BindingFlags.Static);

            BZLogger.Debug($"SeaTruck constructor patched. ID: {__instance.GetInstanceID()}");

            Main.SeatruckUpgradesCtorPatched = true;
        }
        public static bool Prefix(SeaTruckUpgrades __instance, Pickupable pickupable, bool verbose, ref bool __result)
        {
            TechType techType = pickupable.GetTechType();

            if (techType == SeaTruckStorage_Prefab.TechTypeID)
            {
                if (__instance.modules.GetCount(techType) <= 2)
                {
                    __result = true;
                    return(false);
                }
            }

            return(true);
        }
        public static bool PreIsAllowedToAdd(SeaTruckUpgrades __instance, Pickupable pickupable, bool verbose, ref bool __result)
        {
            TechType techType = pickupable.GetTechType();

            if (maxModulesOverrides.TryGetValue(techType, out int value))
            {
                if (__instance.modules.GetCount(techType) <= value)
                {
                    __result = true;
                    return(false);
                }
            }

            return(true);
        }
        public static bool Prefix(SeaTruckUpgrades __instance, string slot, TechType techType, bool added)
        {
            if (__instance.TryGetComponent(out FlyManager manager))
            {
                if (manager)
                {
                    if (techType == SeaTruckFlyModule_Prefab.TechTypeID)
                    {
                        manager.CheckSlotsForFlyModule();
                        return(false);
                    }
                }
            }

            return(true);
        }
 internal virtual void PostUpgradeModuleUse(SeaTruckUpgrades instance, TechType tt, int slotID)
 {
     if (tt == sonarModuleTechType)
     {
         bSonarActive = !bSonarActive;
         sonarSlotID  = slotID;
         uGUI_QuickSlots qs = uGUI.main.quickSlots;
         qs.SetBackground(qs.icons[slotID], tt, bSonarActive);
         if (bSonarActive)
         {
             base.InvokeRepeating("UpdateSonar", 0f, SonarCooldown);
         }
         else
         {
             base.CancelInvoke("UpdateSonar");
         }
     }
 }
 internal virtual void PostUpgradeModuleUse(SeaTruckUpgrades instance, TechType tt, int slotID)
 {
     if (tt == sonarModuleTechType)
     {
         bSonarActive = !bSonarActive;
         sonarSlotID  = slotID;
         uGUI_QuickSlots qs = uGUI.main.quickSlots;
         qs.SetBackground(qs.icons[slotID], tt, bSonarActive);
         if (bSonarActive)
         {
             base.InvokeRepeating("UpdateSonar", 0f, SonarCooldown);
         }
         else
         {
             base.CancelInvoke("UpdateSonar");
         }
     }
     else if (tt == repairModuleTechType)
     {
         gameObject.EnsureComponent <VehicleRepairComponent>().SetActiveState(parentMotor);
     }
 }
Beispiel #17
0
        static void Vehicle_OnUpgradeModuleUse_Postfix(MonoBehaviour __instance, TechType techType, int slotID)
        {
            if (!isStasisModule(techType))
            {
                return;
            }

            // didn't find a better way :(
            bool slotUsed = __instance switch
            {
                Vehicle v => useStasisModuleSlot(v, slotID),
#if GAME_BZ
                SeaTruckUpgrades s => useStasisModuleSlot(s, slotID),
#endif
                _ => false
            };

            if (slotUsed)
            {
                StasisSphereCreator.create(__instance.transform.position, Main.config.stasisTime, Main.config.stasisRadius);
            }
        }
 internal virtual bool PreQuickSlotIsToggled(SeaTruckUpgrades instance, int slotID)
 {
     //Log.LogDebug($"SeaTruckUpdater.PreQuickSlotIsToggled(): slotID = {slotID}, sonarSlotID = {sonarSlotID}, bSonarActive = {bSonarActive}");
     return(slotID == sonarSlotID && bSonarActive);
 }
        public static void Postfix(SeaTruckUpgrades __instance)
        {
            __instance.gameObject.EnsureComponent <SeaTruckStorageManager>();

            BZLogger.Debug($"Storage Manager added in SeaTruckUpgrades.Start -> Postfix Patch. ID: {__instance.gameObject.GetInstanceID()}");
        }
 internal virtual void PostUpdateEnergy(SeaTruckUpgrades instance = null)
 {
 }
 // Not to be confused with Unity's Update
 internal virtual void OnUpdate(SeaTruckUpgrades instance = null)
 {
 }
 internal virtual void PostNotifySelectSlot(SeaTruckUpgrades instance, int slotID)
 {
 }
        public static void PostStart(SeaTruckUpgrades __instance)
        {
            SeaTruckUpdater component = __instance.gameObject.EnsureComponent <SeaTruckUpdater>();

            component.Initialise(ref __instance);
        }
 public static void PostOnPilotEnd(SeaTruckUpgrades __instance)
 {
     __instance.gameObject.EnsureComponent <SeaTruckUpdater>()?.PostOnPilotEnd();
 }
        internal static void Postfix(SeaTruckUpgrades __instance)
        {
            __instance.gameObject.EnsureComponent <SlotExtenderZero>();

            BZLogger.Debug($"SlotExtenderZero added in SeaTruckUpgrades.Start -> Postfix Patch. ID: {__instance.gameObject.GetInstanceID()}");
        }
 public static void PostNotifySelectSlot(SeaTruckUpgrades __instance, int slotID)
 {
     __instance.gameObject.EnsureComponent <SeaTruckUpdater>()?.PostNotifySelectSlot(__instance, slotID);
 }
 public static void PostOnUpgradeModuleUse(SeaTruckUpgrades __instance, TechType techType, int slotID)
 {
     __instance.gameObject.EnsureComponent <SeaTruckUpdater>()?.PostUpgradeModuleUse(__instance, techType, slotID);
 }
Beispiel #28
0
 static bool SeaTruckUpgrades_OnUpgradeModuleUse_Prefix(SeaTruckUpgrades __instance, TechType techType) =>
 techType != SeaTruckStasisModule.TechType || __instance.relay.GetPower() > Main.config.energyCost;
 public static void PostUpgradeModuleChange(SeaTruckUpgrades __instance, int slotID, TechType techType, bool added)
 {
     __instance.gameObject.EnsureComponent <SeaTruckUpdater>()?.PostUpgradeModuleChange(slotID, techType, added, __instance);
 }
 public static void PostSeatruckIsToggled(SeaTruckUpgrades __instance, ref bool __result, int slotID)
 {
     //__result = slotID >= 0 && slotID < SeaTruckUpgrades.slotIDs.Length && (TechData.GetSlotType(__instance.GetSlotBinding(slotID)) == QuickSlotType.Passive || this.quickSlotToggled[slotID]);
     //Log.LogDebug($"PostSeatruckIsToggled: slotID = {slotID}, __result = {__result}");
 }