• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Extending packages or class wrappers [Wurst]

Status
Not open for further replies.

Taztingo

T

Taztingo

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?
 
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.
 
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.
Back
Top