• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Extending packages or class wrappers [Wurst]

Status
Not open for further replies.
Level 2
Joined
Aug 6, 2010
Messages
7
What's the best way to handle custom player attributes in Wurst? I went with the approach of creating a wrapper Player class that contains my custom attributes and also contains a native player object. This lead to some additional wrapper classes needing to be created like Team which contains n wrapper Player objects and my custom team attributes. It also meant I needed a way to convert from the native player type to my new wrapped Player type.


Is this the correct way to do it in Wurst, or is there a way to add variables + functions to a package? Will I also hit any type of performance issue with my simple wrappers?
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
There are many possible ways, and what you described is one possible one, yes.
It is usually a matter of taste whether you want to use custom data structures and wrap stuff in classes or not.
With the use of generics you don't need a separate class for everything though.
I often do something like this: wurstbin (missing some things like ondestroy, just for illustration)
As you can see the teams are simply lists.

Will I also hit any type of performance issue with my simple wrappers?
As a general rule: Worry about performance problems when you encounter them.
 
Level 2
Joined
Aug 6, 2010
Messages
7
This is sort of off topic, but is there a way to add scoping to pData?

If I have two packages that are imported with pData then I would like to be able to differentiate. PackageA::pData vs PackageB::pData.
 
Status
Not open for further replies.
Top