public static void AddEnergyTool(EnergyMixin __instance, ref float amount) { // Acid Battery is not chargeable by any method (e.g. Swim Charge Fins) if (!Config.NORMAL.Equals(DeathRun.config.batteryCosts)) { var batt = __instance.GetBattery(); if (batt != null) { TechType t = CraftData.GetTechType(batt); if (t == AcidBatteryCellBase.BatteryID) { amount = 0; return; } } } if (isTransformInRadiation(Player.main.transform)) { if (Config.DEATHRUN.Equals(DeathRun.config.powerCosts) || Config.EXORBITANT.Equals(DeathRun.config.powerCosts)) { amount /= 4; } else if (Config.HARD.Equals(DeathRun.config.powerCosts)) { amount /= 2; } } else if (Config.DEATHRUN.Equals(DeathRun.config.powerCosts) || Config.EXORBITANT.Equals(DeathRun.config.powerCosts)) { amount /= 2; } }
public static void MonitorSeamothBatteryCount(SeaMoth thisSeaMoth) { EnergyMixin energyMixin = thisSeaMoth.gameObject.GetComponent <EnergyMixin>(); if (energyMixin != null) { GameObject thisGameObject = energyMixin.GetBattery(); if (thisGameObject != null) { SeamothInfo.BatteryInSlot = 1; } else { SeamothInfo.BatteryInSlot = 0; } } SeamothInfo.MainBatteryCount = 0; foreach (InventoryItem item in Inventory.main.container) { if (energyMixin.Filter(item)) { SeamothInfo.MainBatteryCount += 1; } } SeamothInfo.TotalBatteryCount = SeamothInfo.BatteryInSlot + SeamothInfo.MainBatteryCount; }
public static void Postfix(EnergyMixin __instance, float __result) { GameObject battery = __instance.GetBattery(); if (battery) { if (Math.Abs(Math.Floor(__instance.charge) - Math.Floor(__instance.charge - __result)) > 0.0) //Send package if power changed to next natural number { NitroxId instanceId = NitroxEntity.GetId(__instance.gameObject); ItemData batteryData = new(instanceId, NitroxEntity.GetId(battery), SerializationHelper.GetBytes(battery)); NitroxServiceLocator.LocateService <StorageSlots>().EnergyMixinValueChanged(instanceId, UnityEngine.Mathf.Floor(__instance.charge), batteryData); } } }
public static bool BatteryCheck(Pickupable pickupable) { EnergyMixin energyMixin = pickupable.gameObject.GetComponentInChildren <EnergyMixin>(); if (energyMixin != null) { GameObject gameObject = energyMixin.GetBattery(); if (gameObject != null && energyMixin.defaultBattery == CraftData.GetTechType(gameObject)) { IBattery battery = gameObject.GetComponent <IBattery>(); return(battery.capacity == battery.charge); } return(false); } IBattery b2 = pickupable.GetComponent <IBattery>(); return(b2 != null ? b2.capacity == b2.charge : true); }
public static bool BatteryCheck(Pickupable pickupable) { TechType techType = pickupable.GetTechType(); string techString = Language.main.GetOrFallback(techType.AsString(), techType.AsString()); EnergyMixin energyMixin = pickupable.gameObject.GetComponentInChildren <EnergyMixin>(); if (energyMixin != null) { GameObject gameObject = energyMixin.GetBattery(); bool defaultCheck = false; if (gameObject != null) { TechType batteryTechType = CraftData.GetTechType(gameObject); defaultCheck = energyMixin.defaultBattery == batteryTechType; if (defaultCheck) { IBattery battery = gameObject.GetComponent <IBattery>(); if (battery != null && battery.charge < (battery.capacity * 0.99)) { ErrorMessage.AddMessage($"{techString} is not charged so it cannot be recycled."); return(false); } else { return(true); } } else { string batteryString = Language.main.GetOrFallback(batteryTechType.AsString(), batteryTechType.AsString()); ErrorMessage.AddMessage($"{batteryString} is not the default battery for {techString}."); return(false); } } else { ErrorMessage.AddMessage($"{techString} has no battery."); return(false); } } IBattery b2 = pickupable.GetComponent <IBattery>(); if (b2 != null) { if (b2.charge > (b2.capacity * 0.99)) { return(true); } else { ErrorMessage.AddMessage($"{techString} is not fully charged and cannot be recycled."); return(false); } } return(true); }
public static bool BatteryCheck(Pickupable pickupable) { EnergyMixin energyMixin = pickupable.gameObject.GetComponentInChildren <EnergyMixin>(); if (energyMixin != null) { GameObject gameObject = energyMixin.GetBattery(); bool defaultCheck = false; if (gameObject != null) { defaultCheck = energyMixin.defaultBattery == CraftData.GetTechType(gameObject); } if (gameObject == null && QModServices.Main.ModPresent("NoBattery")) { return(true); } if (gameObject != null && (defaultCheck || QModServices.Main.ModPresent("NoBattery"))) { IBattery battery = gameObject.GetComponent <IBattery>(); #if SUBNAUTICA TechData techData = CraftDataHandler.GetTechData(pickupable.GetTechType()); #elif BELOWZERO RecipeData techData = CraftDataHandler.GetRecipeData(pickupable.GetTechType()); #endif bool recipeCheck = techData.Ingredients.FindAll((ingredient) => ingredient.techType == TechType.Battery || ingredient.techType == TechType.PrecursorIonBattery || ingredient.techType == TechType.LithiumIonBattery || ingredient.techType == TechType.PowerCell || ingredient.techType == TechType.PrecursorIonPowerCell).Count == 0; if (battery != null && QModServices.Main.ModPresent("NoBattery") && recipeCheck) { ErrorMessage.AddMessage($"{pickupable.GetTechType().ToString()} has a battery in it. Cannot Recycle."); return(false); } else if (battery != null && defaultCheck && battery.charge > (battery.capacity * 0.99)) { return(true); } else { if (gameObject != null && !defaultCheck) { ErrorMessage.AddMessage($"{CraftData.GetTechType(gameObject).ToString()} is not the default battery for {pickupable.GetTechType().ToString()}."); } else { ErrorMessage.AddMessage($"{pickupable.GetTechType().ToString()} is not fully charged and cannot be recycled."); } return(false); } } else { if (gameObject != null) { ErrorMessage.AddMessage($"{CraftData.GetTechType(gameObject).ToString()} is not the default battery for {pickupable.GetTechType().ToString()}."); } else { ErrorMessage.AddMessage($"{pickupable.GetTechType().ToString()} has no battery."); } return(false); } } IBattery b2 = pickupable.GetComponent <IBattery>(); if (b2 != null) { if (b2.charge > (b2.capacity * 0.99)) { return(true); } else { ErrorMessage.AddMessage($"{pickupable.GetTechType().ToString()} is not fully charged and cannot be recycled."); return(false); } } return(true); }