Innernet objects (INOs, or components) in Among Us allow you to netwok state between clients. There are many different INOs that are spawned with prefabs, which define a set of innernet objects to spawn as part of a group.
Some INOs can belong to individual players, and some can belong to the room itself - which can only be controlled by the host (or if in Server-as-a-Host, the server).
Note that objects defined and registered on Hindenburg only apply to server-side logic, and aren't by default handled on the client in any meaningful way - they'll just be discarded; the client doesn't know what to do with them.
Therefore, objects created on the server should simply be a re-creation of the ones on the client so as to provide an API for plugins. You can also implement the host logic for your INOs on the server, to protect some sensitive code that might otherwise be abused for cheating.
Since Hindenburg builds on-top of SkeldJS, you can follow the guide on the SkeldJS docs to create your own.
Once you've created your innernet objects, you can register them to Hindenburg (either to a room or to the server) with the RegisterPrefab decorator.
For example, if you had a way to spawn buttons using a prefab, you might have 2 components for graphical rendering and handling clicks, i.e. GraphicRenderer
and ClickBehaviour
:
export class GraphicRenderer<RoomType extends Hostable> extends Networkable<RoomType> {
...
}
export class ClickBehaviour<RoomType extends Hostable> extends Networkable<RoomType> {
...
}
export enum MyCustomSpawnTypes {
Button
}
@RegisterPrefab(MyCustomSpawnTypes.Button, [ GraphicRenderer, ClickBehaviour ])
@HindenburgPlugin("hbplugin-epic-role-mod")
export class EpicRoleModPlugin extends RoomPlugin {
}
Use spawnPrefabOfType to create a new baby into the world:
const spawnedButton = this.room.spawnPrefabOfType(MyCustomSpawnType.Button, player /* create the button belonging to the player */);
And to despawn an innernet object that you've created, simply call the .despawn()
method on it:
...
spawnedButton.despawn();
More often than not, you'll be despawning the entire prefab that you created, not just one or two of the components. For that, you can simply loop through the child components:
for (const component of spawnedButton.components) {
component.despawn();
}
Note that the components array contains the actual object itself, per how Unity's Entity-Component system works.
Generated using TypeDoc