wxyz-abcd / node-haxball

The most powerful and lightweight API that allows you to develop your original Haxball(www.haxball.com) host, client, and standalone applications both on node.js and browser environments and also includes every possible hack and functionality that you can imagine.
MIT License
34 stars 13 forks source link

Custom player attributes #25

Closed wxyz-abcd closed 1 year ago

wxyz-abcd commented 1 year ago

We need functions to register/unregister custom properties inside original player objects that will add/remove the property for each player that is currently in the room, and for each player that joins the room later. This will improve bots in performance and memory aspects, and also make life easier for people. We should not have to define seperate player lists and listen to PlayerJoin and PlayerLeave events inside each plugin.

wxyz-abcd commented 1 year ago

I realized that we do not need such complicated logic. Original player objects can already be modified directly. From now on, onPlayerObjectCreated(playerObject) will be called whenever a new player object is created. No special action should be needed for destruction; if it is needed, we can use onPlayerLeave for that purpose. Other than that, if we need to define a new variable inside all player objects - we could need this especially inside onPluginActiveChange - , we can do that with a simple for loop. There is no need to complicate matters any more.