Hunter Registration API
Updated 8 months agoHunter Registration API
Registration
Before registration
- Add
BepInDependency
attribute to yourBaseUnityPlugin
class and fill the parameters with either"com.malco.lethalcompany.moreshipupgrades"
orMoreShipUpgrades.Misc.Metadata.GUID
andDependencyFlags.SoftDependency
- This way, you ensure that you load after this Lategame Upgrades has loaded can use its API correctly.
SoftDependency
is recommneded here as you won't be forced to have Lategame Upgrades as a dependency for your mod to load. However, if your mod is only intended to add items to the Hunter Upgrade, it would make sense to useDependencyFlags.HardDependency
instead (or not specify the type of dependency at all)
- The names used for each enemy are the names specified in
EnemyType.enemyName
.
Without a custom GrabbableObject script
- Use
HunterSamples.RegisterSample(Item sampleItem, string monsterName, int hunterLevel, bool registerNetworkPrefab = false, bool grabbableToEnemies = true, double weight = 50)
method fromMoreShipUpgrades.API
namespace.Item sampleItem
is the Scriptable Object meant to store relevant data about an item such as name, weight, scrap value, etc.string monsterName
is the name of the enemy you wish your item to spawn when killed. (There are alternatives of passing the name such asEnemyType monsterType
andEnemyAI monster
, use what you need)int hunterLevel
is the level of the Hunter upgrade in which allows spawning scrap items on specified enemy kill.bool registerNetworkPrefab
is a toggle for wether you want to register the associated spawn prefab or not. If it's already registered before calling this method, you can leave it atfalse
.bool grabbableToEnemies
is a toggle to wether you allow enemies to grab this sample such as Hoarding Bugs or other custom enemies who use this attribute.double weight
is the spawn weight of the item when an enemy is killed. This is used to pick what prefab to spawn (yes, you can register multiple samples on the same enemy, ultimately only one spawns per.)
- API is sophisticated (I hope so anyways) that will warn you of any errors/warnings when registering the sample to LGU's Hunter upgrade as descriptive as possible to help fix any issues that may arise if they were spawned as such.
With a custom GrabbableObject script
- Use
HunterSamples.RegisterSample<T>(Item sampleItem, string monsterName, int hunterLevel, bool registerNetworkPrefab = false, double weight = 50)
method fromMoreShipUpgrades.API
namespace.T
is your customGrabbableObject
script that you wish to add to your prefab.Item sampleItem
is the Scriptable Object meant to store relevant data about an item such as name, weight, scrap value, etc.string monsterName
is the name of the enemy you wish your item to spawn when killed. (There are alternatives of passing the name such asEnemyType monsterType
andEnemyAI monster
, use what you need)int hunterLevel
is the level of the Hunter upgrade in which allows spawning scrap items on specified enemy kill.bool registerNetworkPrefab
is a toggle for wether you want to register the associated spawn prefab or not. If it's already registered before calling this method, you can leave it atfalse
.double weight
is the spawn weight of the item when an enemy is killed. This is used to pick what prefab to spawn (yes, you can register multiple samples on the same enemy, ultimately only one spawns per.)
- You can also use the one where you don't specify the type if your
Item
scriptable object's spawn prefab already contains the customGrabbableObject
script - API is sophisticated (I hope so anyways) that will warn you of any errors/warnings when registering the sample to LGU's Hunter upgrade as descriptive as possible to help fix any issues that may arise if they were spawned as such.
Examples
Without custom GrabbableObject script
Item item = LoadItemFromAssetBundle();
// RegisterNetworkPrefab(item.spawnPrefab); if you're gonna register before hand, toggle registerNetworkPrefab to false
MoreShipUpgrades.API.HunterSamples.RegisterSample(sampleItem: item, monsterName: "Hoarding Bug", hunterLevel: 1, registerNetworkPrefab: true, grabbableToEnemies: true, weight: 50);
LoadItemFromAssetBundle()
is defined by you and the purpose of this method is to load anItem
Scriptable Object from outside resource such as an asset bundle.RegisterNetworkPrefab()
can be either defined by you or using some other API in which it registers the associated prefab to the game's network manager.- You don't need to specify the parameter names, it's just easier to understand what each value is corresponded to.
- This way, when the players have reached level 1 of Hunter upgrade, whenever a
Hoarding Bug
is killed, it has a 50/50 chance of either spawning your item or LGU's respective sample item. - If the
Item
scriptable object's spawn prefab already contains a GrabbableObject component, you can use this method instead.
With custom GrabbableObject script
Item item = LoadItemFromAssetBundle();
// RegisterNetworkPrefab(item.spawnPrefab); if you're gonna register before hand, toggle registerNetworkPrefab to false
MoreShipUpgrades.API.HunterSamples.RegisterSample<CustomGrabbableObject>(sampleItem: item, monsterName: "Crawler", hunterLevel: 2, registerNetworkPrefab: true, weight: 50);
LoadItemFromAssetBundle()
is defined by you and the purpose of this method is to load anItem
Scriptable Object from outside resource such as an asset bundle.RegisterNetworkPrefab()
can be either defined by you or using some other API in which it registers the associated prefab to the game's network manager.- You don't need to specify the parameter names, it's just easier to understand what each value is corresponded to.
- This way, when the players have reached level 2 of Hunter upgrade, whenever a
Thumper/Half
is killed, it has a 50/50 chance of either spawning your item or LGU's respective sample item.