About Store Forum Documentation Contact



Post Reply 
setAreaClass
Author Message
fatcoder Offline
Member

Post: #1
setAreaClass
I have created my own custom area struct, like this.

Code:
STRUCT(CustomArea, Game::Area)
   CustomArea(C VecI2 &xy, Ptr grid_user) : Game::Area(xy, grid_user) {}
   ~CustomArea() {}
};

Then set it like this.

Code:
Game::World.setAreaClass<CustomArea>()

However, I cannot cast to it like this. It complains that Game::Area is not a ploymorphic class? Surely the lack of a virtual desctructor does not cause such a problem?

Code:
CustomArea *area = CAST(CustomArea, Game::World.areaActive(VecI2(x,y)));

Can there not be something like this in Game::World to allow us to get our custom area struct?

Code:
CustomArea *area = Game::World.areaActive<CustomArea>(VecI2(x,y));

Or am I doing this completly wrong?
12-07-2011 03:31 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: setAreaClass
Thanks for reporting this, I'll address this issue for next SDK.

However please check if it's not better to extend Game::Area::Data
World.setAreaData

Game::Area::Data gets unloaded from memory when away, while Game::Area does not.
12-07-2011 11:56 AM
Find all posts by this user Quote this message in a reply
fatcoder Offline
Member

Post: #3
RE: setAreaClass
Thanks very much.

I am already extending Game::Area::Data as well.

I just need to extend Game::Area to add a world position member to it so that I don't need to recalculate the world position of each area every frame.
12-07-2011 12:41 PM
Find all posts by this user Quote this message in a reply
Post Reply