banner
Rating
Voted0

ReservedItemSlotCore core

0
Mod version:1
Game version:2.0.37
The mod has been successfully tested for the absence of viruses
1349.29K12.84K

Report mod

  • image
modalImage

About This Mod

ReservedItemSlotCore

V64 compatible!

The main mod for all ReservedItemSlot mods.


This mod is required for my ReservedItemSlot mods, such as ReservedFlashlightSlot and ReservedWalkieSlot.

These mods will give you free dedicated slots in inventory for the respective items. These slots will appear on the right side of the screen, folding vertically.


You will not be able to switch to these slots manually by scrolling the screen. Instead, to switch to these items, hold down Alt (the default hotkey) and scroll up and down to switch between them.

So you can switch to these items to throw them, as well as perform other activities such as charging, storage, etc.


The capture of the reserved items, as well as the switch between the main hotbar and the reserved hotbar slots, must be synchronized between customers using this mod.

If appropriate, these mods will have special key bindings to activate items without having to select them now.


All customers using this main mode will synchronize with the host and have the same reserved item slots regardless of which of the reserved item slots mods they have installed.

Using reserved slots for host items for mods you don't have should not be a problem, but you won't be able to take advantage of additional fashion features, such as special hotkeys for reserved items, and won't see these reserved items with players until they're at the moment.

This may change or be adjusted in the future, but this is currently done in order to try to keep the same inventory size for everyone to help with synchronization.

It can also help in sending reserved slots for items to other clients from the host, if I add functionality to create them in config, or if I create a ReservedCustomItemSlot mod that will be a server-side mod.


~Using this mode while the host does not have this mode has been allowed, but expect errors and out-of-sync issues. Use with caution!

This mod will again be disabled for non-host clients if the host does not have this mod for various reasons.

For those who are stubborn enough, it can be forcibly allowed in config. You've been warned!



Buying reserved item slots (new in 2.0.0)

Reserved slots for items can be purchased at the terminal. At the moment, buying reserved slots will unlock the slot for each player. There is currently no way to set his unlock for each player.

You can enter "reserved" in the terminal to see tips on how to purchase reserved item slots.

For Reserved Item Slot mods that support this feature, prices can be configured in config. All reserved slots items I made have these configs.

Purchased slots items will be saved in saving your game. Quitting the game and reloading the save must reload all previously unlocked item slots. Unlocked slots will be reset when you start a new game.

Purchasing of slots items can be disabled in config.


Custom

Each of the following configurations must be supported by each Reserved Item Slot mode.

Adds support that allows Reserved Item Slot mods to set the price of the item slot in config.

Adds support to allow Reserved Item Slot mods to configure the item slot priority in config.

The higher the priority, the lower the order they will be on the right side of the screen.

Negative priority will cause item slots to be displayed on the right side of the screen if it is not disabled in config.

Adds support for adding additional items to reserved slots in config.

Adds support for removing existing items from reserved slots in config.


Supports InputUtils

All required hotkeys for this mode can be controlled in the in-game shortcut menu.

InputUtils is not a dependency, but is recommended!


API support (examples below)

Adds API functions that allow developers to easily create their own Reserved Item Slot mods or add their own items to existing Reserved Item Slots.

When creating a ReservedItemData for a specific item, developers can specify the target bone to which the item will be attached to the player (and the enemy in the mask), as well as specify position/rotation offset.

My ReservedItemSlot Fashions

ReservedFlashlightSlot

ReservedWalkieSlot

ReservedWeaponSlot

ReservedUtilitySlot

ReservedSprayPaintSlot

Other Reserved Item Slot mods can exist on Thunderstore!


Mode Compatibility

HotbarPlus is compatible!

LethalThings Utility Belt is (or should be) compatible! (i hope it stays that way.)

This mod may not work well with Advanced Company. Use at your own risk!

Other mods that add hotbar slots are not guaranteed to work.

Other mods that can change the layout of hotbar (HUD) slots do not guarantee good work with these mods, but can technically work.


If you've read it to this point and you like my fashion.

Please support me here!

This is not necessary, but I would appreciate it! =)





API Samples

First, make sure you add the latest version of ReservedItemSlotCore.dll to your VS project references.

NOTE

Adding items that do not exist (either by mistake or from an unloaded mod) to ReservedItemSlotData will not break anything.

Adding an item to an existing ReservedItemSlotData that was created from an unloaded mod will not break anything.


Add your fashion items to an existing reserved items slot

This class will be used to add items from your mod to existing reserved items slots that have been created by another mod, and if ReservedItemSlotCore is enabled.


Create a class like this in a separate file.


using ReservedItemSlotCore.Data;



public static class ReservedItemSlotsCompat

{

  public static void AddItemsToReservedItemSlots()

  {

    // Name of your item as it is displayed in the game

    ReservedItemData myReservedItemData = new ReservedItemData(«ItemDisplayName»);

     

    // It's okay if the mod that created this slot for the item is not enabled on the client. Nothing will break

    ReservedItemSlotData.TryAddItemDataToReservedItemSlot(myReservedItemData, «nameOfItemSlot»);

  }

}


Or to make your item visible when wearing a holster:



Using ReservedItemSlotCore.Data


public static class ReservedItemSlotsCompat

{

  public static void AddItemsToReservedItemSlots()

  {

    // Arguments: ItemDisplayName, ParentBone(enum), PositionOffset, RotationOffset

    ReservedItemData myReservedItemData = new ReservedItemData(«ItemDisplayName», PlayerBone.Spine3, new Vector3(0.2f, 0.25f, 0), new Vector3(90, 0, 0));

   

    // It's okay if the mod that created this slot for the item is not enabled on the client. Nothing will break

    ReservedItemSlotData.TryAddItemDataToReservedItemSlot(myReservedItemData, «nameOfItemSlot»);

  }  

}


And in the Awake (or Start) method in the Plugin class, add this: (preferably after binding the configs)

If your mod doesn't depend on ReservedItemSlotCore, but only optionally adds your items to Reserved Item Slots, if they exist, then checking whether this mod is enabled is very important!


if (BepInEx.Bootstrap.Chainloader.PluginInfos.ContainsKey(«FlipMods.ReservedItemSlotCore»))

  ReservedItemSlotsCompat.AddItemsToReservedItemSlots(); // This will be a call to your function


Last but not least, add this SoftDependency header above your plugin class definition

If your mod depends on ReservedItemSlotCore, you can change BepInDependency.DependencyFlags.SoftDependency to BepInDependency.DependencyFlags.HardDependency.


[BepInDependency("FlipMods.ReservedItemSlotCore", BepInDependency.DependencyFlags.SoftDependency)] // Add this line

[BepInPlugin("EXAMPLE_MOD_GUID", "EXAMPLE_MOD_NAME", "1.0.0")] // YOU SHOULD HAVE THIS STRING UNDER THE DEFINITION OF YOUR PLUGIN CLASS.

public class Plugin : BaseUnityPlugin

{

  ...

}


Create Your Own ReservedItemSlot

An example of creating your own ReservedItemSlotData and adding your fashion items (or existing items in the game) to a slot items.

Include this code in the Awake (or Start) method of your Plugin class. You do not need to create a separate file or class to add this code.


using ReservedItemSlotCore.Data;


// MAKE SURE YOU PUT THIS HEADER OVER THE PLUGIN CLASS

[BepInDependency(«FlipMods.ReservedItemSlotCore», BepInDependency.DependencyFlags.HardDependency)]

[BepInPlugin("EXAMPLE_MOD_GUID", "EXAMPLE_MOD_NAME", "1.0.0")] // YOU SHOULD HAVE THIS STRING AFTER DEFINING YOUR PLUGIN CLASS.

public class Plugin : BaseUnityPlugin

{

  private void Awake()

  {

    // Your existing code...


     // This will register your ReservedItemSlotData and will be added to the game if the host is running mod.

    // Arguments: ItemSlotName (format not too important), ItemSlotPriority, ItemSlotPrice

    ReservedItemSlotData myReservedItemSlot = ReservedItemSlotData.CreateReservedItemSlotData(«my_item_slot_name», 20, 100);


    // Create ReservedItemData data for your item

    // You can also add extra arguments to allow this item to appear on players when it is in the holster. (see previous example)

    ReservedItemData myReservedItemData = new ReservedItemData(«ItemDisplayName»);


    // Add ReservedItemData to your ReservedItemSlotData, and you're done!

    myReservedItemSlot.AddItemToReservedItemSlot(myReservedItemData);

  }

}


Other API Functions

Here are a few examples of how you can receive and manage reserved player items.


PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;

for (int i = 0; i < SessionManager.numReservedItemSlotsUnlocked; i++)

{

  ReservedItemSlotData itemSlotData = SessionManager.GetUnlockedReservedItemSlot(i);

  if (itemSlotData != null)

  {

    // Gets the index of this item slot in the player's inventory

    int indexInPlayerInventory = itemSlotData.GetIndexInInventory(localPlayerController); // any gamer controller can be transferred



    // Gets the object that is currently held in this slot by the specified player or returns null

    GrabbableObject heldObjectInSlot = itemSlotData.GetHeldObjectInSlot(localPlayerController); 



    // Receives the item slot frame (image component in HUD) for this item slot. Applies to local player only

    Image itemSlotFrameHUD = itemSlotData.GetItemSlotFrameHUD();



    // To check if a reserved item slot will accept a certain item (item name as it looks in the game)

    // You can also pass the link to GrabbableObject

    if (itemSlotData.ContainsItem(«Flashlight»))

      Plugin.Log("This slot contains a flashlight");

  }

}


If you're creating your own ReservedItemSlotData, don't forget to also include this line in your manifest.json dependency list.

«FlipMods-ReservedItemSlotCore-2.0.7»



If you want to see more examples, feel free to take a look at my existing ReservedItemSlot fashion on github!

If you think I missed something, or faced any problems, please let me know! I'm quite active in the Lethal Company modding discod, so find me!

You can also leave a report of any problems on github for this fashion!

Similar Mods/Addons

Game Version *

2.0.37 (FlipMods-ReservedItemSlotCore-2.0.37.zip)