-
Notifications
You must be signed in to change notification settings - Fork 88
@ByRef
erasels edited this page Feb 6, 2021
·
4 revisions
ByRef allows you to receive parameters to your patch method by-reference. ByRef parameters are encapsulated inside a single element array.
// Parameter i is of type int, when using @ByRef, it is passed as int[]
public static void Prefix(@ByRef int[] i, float f)
{
i[0] = 14; // i will be changed outside this method
f = 3.14; // f will NOT be changed outside this method
}
This is outdated, the above will work with non-primitive types as well.
When using ByRef on a parameter of type Object
that was not originally of type Object
, you must use the type
parameter to specify the original type of the parameter. The type
string must be the fully qualified class name, unless it is from the com.megacrit.cardcrawl
package, in which case you can leave off com.megacrit.cardcrawl
.
@SpireInsertPatch(loc=14, localvars={"p"})
// localvar 'p' is of type AbstractPlayer
public static void Insert(@ByRef(type="com.megacrit.cardcrawl.characters.AbstractPlayer") Object[] p) { ... }
// Or leave off com.megacrit.cardcrawl
public static void Insert(@ByRef(type="characters.AbstractPlayer") Object[] p) { ... }