//In familyExtend.js
export default class TestInstance extends globalThis.InstanceType.Tester
{
constructor()
{
super();
this._balls = 2;
}
}
//In familyExtend2.js
export default class TestInstance2 extends globalThis.InstanceType.qCollider
{
constructor()
{
super();
//add properties
this._balls = 2;
}
}
//In main.js
import TestInstance from "./familyExtend.js";
import TestInstance2 from "./familyExtend2.js";
runOnStartup(async runtime =>
{
//extend classes like so
runtime.objects.Tester.setInstanceClass(TestInstance);
runtime.objects.qCollider.setInstanceClass(TestInstance2);
//...
runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
});
In the above case, Tester is a family, and qCollider is a object. I can subclass the object, but not the family. I imagine this is expected -...
But what I don't understand then, is how do I add this functionality to every object in my game, short of redefining a subclass for every object type?
I understand I am essentially wanting functionality that multiple object types share, but adding it on as a subclass is backwards. Like defining rats and bats and then creating subclasses for mammals.