示例#1
0
        public static bool AllowedToAdd_Prefix(Equipment __instance, ref bool __result, string slot, Pickupable pickupable, bool verbose)
        {
            TechType      objTechType = pickupable.GetTechType();
            EquipmentType slotType    = Equipment.GetSlotType(slot);

            if (slotType == EquipmentType.BatteryCharger && (objTechType == TechType.Battery || objTechType == TechType.PrecursorIonBattery))
            {
#if BELOWZERO
                if (TechData.GetEquipmentType(objTechType) == EquipmentType.Hand)
#else
                if (CraftData.GetEquipmentType(objTechType) == EquipmentType.Hand)
#endif
                {
                    bool result = ((IItemsContainer)__instance).AllowedToAdd(pickupable, verbose);
                    __result = result;
                    return(false);
                }
            }
            else if (slotType == EquipmentType.PowerCellCharger && (objTechType == TechType.PowerCell || objTechType == TechType.PrecursorIonPowerCell))
            {
#if BELOWZERO
                if (TechData.GetEquipmentType(objTechType) == EquipmentType.Hand)
#else
                if (CraftData.GetEquipmentType(objTechType) == EquipmentType.Hand)
#endif
                {
                    __result = ((IItemsContainer)__instance).AllowedToAdd(pickupable, verbose);
                    return(false);
                }
            }
            return(true);
        }
示例#2
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);
        }
示例#3
0
        /// <summary>
        /// Returns the <see cref="EquipmentType"/> associated to the provided <see cref="TechType"/>.<br/>
        /// This is intended to identify if a given <see cref="TechType"/> is a Battery, Power Cell, or something else.
        /// </summary>
        /// <param name="techType">The item techtype to check</param>
        /// <returns>
        /// <see cref="EquipmentType.BatteryCharger"/> if the TechType is a Battery,
        /// <see cref="EquipmentType.PowerCellCharger"/> if the TechType is a Power Cell,
        /// or the resulting value from the game's GetEquipmentType method.
        /// </returns>
        public EquipmentType GetEquipmentType(TechType techType)
        {
            if (BatteryCharger.compatibleTech.Contains(techType))
            {
                return(EquipmentType.BatteryCharger);
            }
            else if (PowerCellCharger.compatibleTech.Contains(techType))
            {
                return(EquipmentType.PowerCellCharger);
            }
            else if (CbDatabase.TrackItems.Contains(techType))
            {
                if (CbDatabase.BatteryItems.FindIndex(cb => cb.TechType == techType) > -1)
                {
                    return(EquipmentType.BatteryCharger); // Batteries that do not go into chargers
                }
                else if (CbDatabase.PowerCellItems.FindIndex(cb => cb.TechType == techType) > -1)
                {
                    return(EquipmentType.PowerCellCharger); // Power cells that do not go into chargers
                }
            }

#if SUBNAUTICA
            return(CraftData.GetEquipmentType(techType));
#elif BELOWZERO
            return(TechData.GetEquipmentType(techType));
#endif
        }
示例#4
0
        public override GameObject GetGameObject()
        {
            GameObject prefab = CraftData.GetPrefabForTechType(this.PrefabType);
            var        obj    = GameObject.Instantiate(prefab);

            Battery battery = obj.GetComponent <Battery>();

            battery._capacity = this.PowerCapacity;
            battery.name      = $"{this.ClassID}BatteryCell";

            // If "Enable batteries/powercells placement" feature from Decorations mod is ON.
#if SUBNAUTICA
            if (CbDatabase.PlaceBatteriesFeatureEnabled && CraftData.GetEquipmentType(this.TechType) != EquipmentType.Hand)
#elif BELOWZERO
            if (CbDatabase.PlaceBatteriesFeatureEnabled && TechData.GetEquipmentType(this.TechType) != EquipmentType.Hand)
#endif
            {
                CraftDataHandler.SetEquipmentType(this.TechType, EquipmentType.Hand);       // Set equipment type to Hand.
                CraftDataHandler.SetQuickSlotType(this.TechType, QuickSlotType.Selectable); // We can select the item.
            }

            SkyApplier skyApplier = obj.EnsureComponent <SkyApplier>();
            skyApplier.renderers = obj.GetComponentsInChildren <Renderer>(true);
            skyApplier.anchorSky = Skies.Auto;

            if (CustomModelData != null)
            {
                foreach (Renderer renderer in obj.GetComponentsInChildren <Renderer>(true))
                {
                    if (CustomModelData.CustomTexture != null)
                    {
                        renderer.material.SetTexture(ShaderPropertyID._MainTex, this.CustomModelData.CustomTexture);
                    }

                    if (CustomModelData.CustomNormalMap != null)
                    {
                        renderer.material.SetTexture(ShaderPropertyID._BumpMap, this.CustomModelData.CustomNormalMap);
                    }

                    if (CustomModelData.CustomSpecMap != null)
                    {
                        renderer.material.SetTexture(ShaderPropertyID._SpecTex, this.CustomModelData.CustomSpecMap);
                    }

                    if (CustomModelData.CustomIllumMap != null)
                    {
                        renderer.material.SetTexture(ShaderPropertyID._Illum, this.CustomModelData.CustomIllumMap);
                        renderer.material.SetFloat(ShaderPropertyID._GlowStrength, this.CustomModelData.CustomIllumStrength);
                        renderer.material.SetFloat(ShaderPropertyID._GlowStrengthNight, this.CustomModelData.CustomIllumStrength);
                    }
                }
            }

            this.EnhanceGameObject?.Invoke(obj);

            return(obj);
        }
示例#5
0
        public IEnumerable <InventoryItem> GetAvailableArms()
        {
            foreach (var possibleArm in _armsContainer)
#if SUBNAUTICA_STABLE
            { if (CraftData.GetEquipmentType(possibleArm.item.GetTechType()) == EquipmentType.ExosuitArm)
#elif BELOWZERO
                if (TechData.GetEquipmentType(possibleArm.item.GetTechType()) == EquipmentType.ExosuitArm)
#endif
              { yield return(possibleArm); } }
        }
示例#6
0
        internal static bool Prefix(uGUI_QuickSlots __instance, ref uGUI_ItemIcon icon, TechType techType, bool highlighted)
        {
            if (TechData.GetEquipmentType(techType) == (EquipmentType)ModdedEquipmentType.SeatruckArm)
            {
                if (icon == null)
                {
                    return(false);
                }

                if (spriteExosuitArm == null)
                {
                    spriteExosuitArm = Object.Instantiate(__instance.spriteExosuitArm);
                }

                icon.SetBackgroundSprite(spriteExosuitArm);

                return(false);
            }

            return(true);
        }
示例#7
0
        public static bool AllowedToAdd_Prefix(Equipment __instance, ref bool __result, string slot, Pickupable pickupable, bool verbose)
        {
            TechType      objTechType = pickupable.GetTechType();
            EquipmentType slotType    = Equipment.GetSlotType(slot);

            if (slotType == EquipmentType.BatteryCharger && ModdedBatteriesFixer.BatteriesTechTypes().Contains(objTechType))
            {
#if BELOWZERO
                EquipmentType eType = TechData.GetEquipmentType(objTechType);
#else
                EquipmentType eType = CraftData.GetEquipmentType(objTechType);
#endif
                if (eType == EquipmentType.Hand || eType == EquipmentType.BatteryCharger)
                {
#if DEBUG_PLACE_TOOL
                    Logger.Log("DEBUG: AllowedToAdd battery charger for " + objTechType.AsString(false));
#endif
                    bool result = ((IItemsContainer)__instance).AllowedToAdd(pickupable, verbose);
                    __result = result;
                    return(false);
                }
            }
            else if (slotType == EquipmentType.PowerCellCharger && ModdedBatteriesFixer.PowercellsTechTypes().Contains(objTechType))
            {
#if BELOWZERO
                EquipmentType eType = TechData.GetEquipmentType(objTechType);
#else
                EquipmentType eType = CraftData.GetEquipmentType(objTechType);
#endif
                if (eType == EquipmentType.Hand || eType == EquipmentType.PowerCellCharger)
                {
#if DEBUG_PLACE_TOOL
                    Logger.Log("DEBUG: AllowedToAdd powercell charger for " + objTechType.AsString(false));
#endif
                    __result = ((IItemsContainer)__instance).AllowedToAdd(pickupable, verbose);
                    return(false);
                }
            }
            return(true);
        }
        private void SearchForModdedTechTypes()
        {
            int i = 0;

            int[] techTypeArray = (int[])Enum.GetValues(typeof(TechType));

            for (int j = 0; j < techTypeArray.Length; j++)
            {
                if (techTypeArray[j] >= 11000)
                {
                    TechType techType = (TechType)techTypeArray[j];
                    string   techName = TechTypeExtensions.AsString(techType);

                    EquipmentType equipmentType = TechData.GetEquipmentType(techType);
                    FoundModdedTechTypes.Add(techName, techType);
                    TypeDefCache.Add(techType, equipmentType);
                    BZLogger.Log($"Modded techtype found! Name: [{techName}], ID: [{(int)techType}], Type: [{equipmentType}]");
                    i++;
                }
            }

            BZLogger.Log($"Found [{i}] modded TechType(s).");
        }
示例#9
0
        private bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            TechType techType = pickupable.GetTechType();

            if (compatibleTech.Contains(techType))
            {
                return(true);
            }

            EquipmentType equipmentType = TechData.GetEquipmentType(techType);

            if (equipmentType == EquipmentType.BatteryCharger)
            {
                return(true);
            }

            if (verbose)
            {
                ErrorMessage.AddMessage(Language.main.Get("BatteryChargerIncompatibleItem"));
            }

            return(false);
        }
        private bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            bool flag = false;

            var techType = pickupable.GetTechType();

#if SUBNAUTICA
            var equipType = CraftData.GetEquipmentType(techType);
#elif BELOWZERO
            var equipType = TechData.GetEquipmentType(techType);
#endif


            if (equipType == EquipmentType.PowerCellCharger)
            {
                flag = true;
            }
            else
            {
                ErrorMessage.AddMessage(FCSDeepDrillerBuildable.OnlyPowercellsAllowed());
            }

            return(flag);
        }
        private bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            bool flag = false;

            var techType = pickupable.GetTechType();

#if SUBNAUTICA
            var equipType = CraftData.GetEquipmentType(techType);
#elif BELOWZERO
            var equipType = TechData.GetEquipmentType(techType);
#endif


            if (equipType == EquipmentType.PowerCellCharger)
            {
                flag = true;
            }
            else
            {
                QuickLogger.Message(AIPowerCellSocketBuildable.OnlyPowercellsAllowed(), true);
            }

            return(flag);
        }
        public static bool AddOrSwap_Prefix(ref bool __result, InventoryItem itemA, Equipment equipmentB, string slotB)
        {
            if (itemA == null || !itemA.CanDrag(true) || equipmentB == null)
            {
                return(true);
            }
            Pickupable item = itemA.item;

            if (item == null)
            {
                return(true);
            }
            TechType techType = item.GetTechType();

            if (techType == TechType.Battery || techType == TechType.PrecursorIonBattery ||
                techType == TechType.PowerCell || techType == TechType.PrecursorIonPowerCell)
            {
                IItemsContainer container = itemA.container;
                if (container == null)
                {
                    return(true);
                }
                Equipment equipment = container as Equipment;
                bool      flag      = equipment != null;
                string    empty     = string.Empty;
                if (flag && !equipment.GetItemSlot(item, ref empty))
                {
                    return(true);
                }
#if BELOWZERO
                EquipmentType equipmentType = TechData.GetEquipmentType(techType);
#else
                EquipmentType equipmentType = CraftData.GetEquipmentType(techType);
#endif
                if (string.IsNullOrEmpty(slotB))
                {
                    equipmentB.GetCompatibleSlot(equipmentType, out slotB);
                }
                if (string.IsNullOrEmpty(slotB))
                {
                    return(true);
                }
                if (container == equipmentB && empty == slotB)
                {
                    return(true);
                }
                EquipmentType slotBType = Equipment.GetSlotType(slotB);
                if (slotBType != EquipmentType.BatteryCharger && slotBType != EquipmentType.PowerCellCharger)
                {
                    return(true);
                }
                else // Else, we're trying to plug a battery or powercell to its charger
                {
                    InventoryItem inventoryItem = equipmentB.RemoveItem(slotB, false, true);
                    if (inventoryItem == null)
                    {
                        if (equipmentB.AddItem(slotB, itemA, false))
                        {
                            __result = true;
                            return(false);
                        }
                    }
                    else if (equipmentB.AddItem(slotB, itemA, false))
                    {
                        if ((flag && equipment.AddItem(empty, inventoryItem, false)) || (!flag && container.AddItem(inventoryItem)))
                        {
                            __result = true;
                            return(false);
                        }
                        if (flag)
                        {
                            equipment.AddItem(empty, itemA, true);
                        }
                        else
                        {
                            container.AddItem(itemA);
                        }
                        equipmentB.AddItem(slotB, inventoryItem, true);
                    }
                    else
                    {
                        equipmentB.AddItem(slotB, inventoryItem, true);
                    }
                    __result = false;
                    return(false);
                }
            }
            return(true);
        }