Hey everyone,
I am thinking of extending Game_Actor class like this; it seems to work in a simple play-testing project without any dependencies. However, being a noob in Javascript and in RPG Maker, I am a bit worried this would conflict with the way some plugins are "injecting" their code into core scripts.
What do you think of this approach? Is this viable? Or perhaps I am overcomplicating things?
(for the reference, I am using an awesome project template from here: https://github.com/xuyanwen2012/rmmz-plugins-starter)
I am thinking of extending Game_Actor class like this; it seems to work in a simple play-testing project without any dependencies. However, being a noob in Javascript and in RPG Maker, I am a bit worried this would conflict with the way some plugins are "injecting" their code into core scripts.
What do you think of this approach? Is this viable? Or perhaps I am overcomplicating things?
(for the reference, I am using an awesome project template from here: https://github.com/xuyanwen2012/rmmz-plugins-starter)
JavaScript:
export class Game_Actor_Ex extends Game_Actor {
constructor(actorId: number){
super(actorId);
var windowDynamic = (window as any);
//this is needed so JsonEx.makeDeepCopy() will be able to properly instantiate the derived class
if(!windowDynamic["Game_Actor_Ex"])
windowDynamic["Game_Actor_Ex"] = Game_Actor_Ex;
}
public changeEquip(slotId: number, item: RPG.EquipItem): void {
super.changeEquip(slotId, item);
if(item)
console.log('hello from change Equip! equip event, slotId = ' + slotId + ' item = ' + item.name);
else
console.log('hello from change Equip! unequip event, slotId = ' + slotId);
}
}
export class Game_Actors_Ex extends Game_Actors {
actor(actorId: number): Game_Actor {
if ($dataActors[actorId]) {
if (!this._data[actorId]) {
this._data[actorId] = new Game_Actor_Ex(actorId);
}
return this._data[actorId];
}
return null as any;
}
}
Game_Actors.prototype = Game_Actors_Ex.prototype;