Annotations
Annotations are special keywords that you can use to change or extend the behavior of existing methods and classes in the base game. You cannot use annotations to modify modded methods or classes.
You cannot use the following annotations on native functions.
@wrapMethod(class)
You can use this annotation to write a new function that supersedes an existing method with the same name and parameters on a specified class. Your function will execute instead of the original method whenever it is invoked, but you can still access the underlying method by using the wrappedMethod(…)
identifier. You would typically invoke the wrapped method in your newly defined function and forward all the arguments unchanged to preserve it's original behavior, but you can also modify the arguments or the final return value if you wish. Furthermore, this annotation can be applied multiple times to chain multiple functions that modify the same method. Each function in the chain wraps around the previous one. This helps to keep mods compatible even if they alter the same methods. For example, multiple mods can use this annotation to append new buttons to the main menu:
@addMethod(class)
You can use this annotation to create a new method and add it to an existing class. For example, you can write a new method to disassemble all junk items in your backpack and add it to the BackpackMainGameController
class:
@replaceMethod(class)
You can use this annotation to write a new function that has the same name and parameters as an existing method in the game. Your function will replace the original method and change its behavior.
@replaceGlobal()
You can use this annotation to write a new function that has the same name and parameters as an existing global function in the game. Your function will replace the original function and change its behavior.
@addField(class)
You can use this annotation to create a new field and add it to an existing class. For example, you can add a dummy field of type Int32
to the PlayerPuppet
class:
Last updated
Was this helpful?