Exemplo n.º 1
0
        public static bool Prefix(SeamothStorageInput __instance)
        {
            ItemsContainer storageInSlot =
                (SlotExtenderAssembly != null) ?
                (ItemsContainer)methodGetStorageInSlotExtender.Invoke(null, new object[] { __instance.seamoth, __instance.slotID, TechType.VehicleStorageModule }):
                (ItemsContainer)methodGetStorageInSlotDefault.Invoke(__instance.seamoth, new object[] { __instance.slotID, TechType.VehicleStorageModule });

            if (storageInSlot != null)
            {
                List <TechType> itemTypes = storageInSlot.GetItemTypes();
                if (itemTypes.Count() == 0)
                {
                    HandReticle.main.SetInteractText("SeamothStorageOpen", "Empty");
                }
                else
                {
                    if (itemTypes.Count() == 1)
                    {
                        HandReticle.main.SetInteractText("SeamothStorageOpen", string.Format("{0} {1}", storageInSlot.count, Language.main.Get(itemTypes[0].AsString())));
                    }
                    else
                    {
                        HandReticle.main.SetInteractText("SeamothStorageOpen", string.Format("{0} items", storageInSlot.count));
                    }
                }
            }
            else
            {
                HandReticle.main.SetInteractText("SeamothStorageOpen");
            }
            HandReticle.main.SetIcon(HandReticle.IconType.Hand, 1f);
            return(false);
        }
        public void Init()
        {
            //GameObject storagePrefab = Resources.Load<GameObject>("WorldEntities/Tools/SeamothStorageModule");

            if (Initialized)
            {
                return;
            }

            var holder = ParentSeamoth.modulesRoot;

            holder.transform.parent        = this.transform;
            holder.transform.localPosition = Vector3.one;

            SeamothStorageContainer[] storages = holder.GetAllComponentsInChildren <SeamothStorageContainer>();
            Console.WriteLine($"[UpgradedVehicles] SeaMothStorageDeluxe : Awake Storages:Length {storages.Length}");

            // This is weird but each storage component shows up twice with this call
            for (int outerIndex = 0; outerIndex < 8; outerIndex += 2)
            {
                int index = outerIndex / 2;

                //var storage = GameObject.Instantiate(storagePrefab);
                storages[outerIndex].transform.parent        = holder.transform;
                storages[outerIndex].transform.localPosition = Vector3.one;

                Storages[index] = storages[outerIndex];

                SeamothStorageInput seamothStorageInput = ParentSeamoth.storageInputs[index];
                seamothStorageInput.seamoth = ParentSeamoth;
                seamothStorageInput.SetEnabled(true);
                Storages[index].enabled = true;
            }

            Initialized = true;
            Console.WriteLine($"[UpgradedVehicles] SeaMothStorageDeluxe : Initialized");
        }
Exemplo n.º 3
0
        internal static bool Prefix(Equipment __instance, string slot, Pickupable pickupable, bool verbose, ref bool __result)
        {
            TechType techTypeInSlot = pickupable.GetTechType();

            bool isExtendedSeamothSlot = SlotHelper.IsExtendedSeamothSlot(slot);

            if (isExtendedSeamothSlot && techTypeInSlot == TechType.SeamothTorpedoModule)
            {
                // Do not allow torpedo modules in extended slots in Seamoth
                __result = false;
                ErrorMessage.AddDebug("Slot Extender:\nTorpedo module not allowed for this slot!");
                return(false);
            }

            if (techTypeInSlot == TechType.VehicleStorageModule)
            {
                if (__instance.owner.GetComponent <Exosuit>())
                {
                    // Do not allow more than four storage modules in Exosuit slots
                    if (__instance.GetCount(TechType.VehicleStorageModule) >= 4)
                    {
                        __result = false;
                        ErrorMessage.AddDebug("Slot Extender:\nStorage module limit reached!");
                        return(false);
                    }
                }
                else if (SEConfig.STORAGE_SLOTS_OFFSET == 0)
                {
                    if (!isExtendedSeamothSlot)
                    {
                        return(true);
                    }

                    // Do not allow storage modules in extended slots in Seamoth
                    __result = false;
                    ErrorMessage.AddDebug("Slot Extender:\nStorage module not allowed for this slot!");
                    return(false);
                }
                else if (__instance.owner.GetComponent <SeaMoth>() is SeaMoth seamoth)
                {
                    int slotID = int.Parse(slot.Substring(13)) - 1;

                    if (slotID > 3 && (slotID < SEConfig.STORAGE_SLOTS_OFFSET || slotID > SEConfig.STORAGE_SLOTS_OFFSET + 3))
                    {
                        ErrorMessage.AddDebug("Slot Extender:\nStorage module not allowed for this slot!");
                        return(false);
                    }

                    // HACK: trying to swap one storage to another while drag, silently refusing because of ui problems
                    if (seamoth.GetSlotItem(slotID)?.item.GetTechType() == TechType.VehicleStorageModule)
                    {
                        __result = false;
                        return(false);
                    }

                    SeamothStorageInput storageInput = seamoth.storageInputs[slotID % SEConfig.STORAGE_SLOTS_OFFSET];
                    var fieldState = AccessTools.Field(typeof(SeamothStorageInput), "state");
                    __result = !(bool)fieldState.GetValue(storageInput); //already active

                    if (!__result && verbose)
                    {
                        int _slotID = (slotID < 4? slotID + SEConfig.STORAGE_SLOTS_OFFSET: slotID - SEConfig.STORAGE_SLOTS_OFFSET) + 1;
                        ErrorMessage.AddDebug($"Slot Extender:\nStorage module is already in the slot {_slotID}");
                    }

                    return(false);
                }
            }

            return(true);
        }