Sign in to follow this  

CBaseEntity Help!!!

This topic is 3839 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Say in a game you have a base entity class. What sort of variables and functions would be in it?

Share this post


Link to post
Share on other sites
ToString(), HashCode, uid perhaps. There's not much that's usefully required by everything.

Share this post


Link to post
Share on other sites
In my game i want all my objects like for eg the map every model etc... to derive from CBaseEntity and register with a manager for things like collision detection etc. Is this a good way to do it?

Share this post


Link to post
Share on other sites
Quote:
Original post by hahaha
In my game i want all my objects like for eg the map every model etc... to derive from CBaseEntity and register with a manager for things like collision detection etc. Is this a good way to do it?


An extension on model-view-controller might be more adapted. You use a controller object which sets up a model (a collision detection client object or a physics engine client object for instance) and a view (a model, a sprite).

Share this post


Link to post
Share on other sites
Ask: What sort of things do every entitity have in common?
What actions do each entitity have in common?

Share this post


Link to post
Share on other sites
Quote:
Original post by Nohup
A couple pointers for an intrusive double linked list.


What is an intrusive double linked list?

Share this post


Link to post
Share on other sites
Quote:
Original post by hahaha
Quote:
Original post by Nohup
A couple pointers for an intrusive double linked list.


What is an intrusive double linked list?


It's a violation of the single responsibility principle, which adds the responsibility of being part of a list to the responsibility of being an object.

This approach is generally shunned in all languages which have access to a standard library of containers (in practice, everything except C and assembly), because standard library containers are faster and lighter by default, provide more features and take less development time to use, in addition to respecting the single responsibility principle. The main reason is that you want to be free to make your entities part of zero, one or more containers, and you don't want to be forced to make your entities par of exactly one container (and to make that container a doubly linked list).

Share this post


Link to post
Share on other sites
Why have a base entity at all?

Why not define a single entity class, that uses component oriented design to specialize contents?

Or, if going for networked gameplay, an entity that is convenient to use with serialization (has UID, possible persistence ID) and is capable of serializing itself.

Or, have the class design mimic different types of entities, and have fields that reflect the functionality.

Or, not have the objects, and simply use arrays of structs to encapsulate functionality.

This question is akin to:"Suppose I want to drive. What kind of SUV would I use?" Well, not only is SUV not the best solution, but driving involves everything from unicycle, pogo stick, motor bike, tanks, airplanes, and, in some cases, SUVs.

In this case, the question is wrong. A better one would be describing the type of game design you want, what interactions you want, and implementation specific quirks, and then, the design of entity forms by itself.

Class design solves the problem - designing classes without context simply creates a solution looking for an answer. In this case, answering 42 would be perfectly valid. But you'd be stuck trying to figure out what the question is.

Share this post


Link to post
Share on other sites
I would have to agree with Antheus and ToohrVyk and I have recently converted from the traditional blob base entity to a design which uses MVC along with a component model. One of the absolute fields (besides id) is a translation matrix, as my definition of an entity is something which can effect game play, yet this does have an overhead for the rare entities which have no location and I can live with that.

Quote:
Original post by Antheus

Class design solves the problem - designing classes without context simply creates a solution looking for an answer. In this case, answering 42 would be perfectly valid. But you'd be stuck trying to figure out what the question is.


Is this jeopardy(is that the correct show?)
what is the number from which all meaning could be derived. :)


[edit] here is some reading material for you.
http://www.mine-control.com/zack/patterns/gamepatterns.html
http://www.gamasutra.com/features/20050414/rouwe_01.shtml

[Edited by - dmail on July 15, 2007 10:23:45 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Why have a base entity at all?

Why not define a single entity class, that uses component oriented design to specialize contents?

Or, if going for networked gameplay, an entity that is convenient to use with serialization (has UID, possible persistence ID) and is capable of serializing itself.

Or, have the class design mimic different types of entities, and have fields that reflect the functionality.

Or, not have the objects, and simply use arrays of structs to encapsulate functionality.

This question is akin to:"Suppose I want to drive. What kind of SUV would I use?" Well, not only is SUV not the best solution, but driving involves everything from unicycle, pogo stick, motor bike, tanks, airplanes, and, in some cases, SUVs.

In this case, the question is wrong. A better one would be describing the type of game design you want, what interactions you want, and implementation specific quirks, and then, the design of entity forms by itself.

Class design solves the problem - designing classes without context simply creates a solution looking for an answer. In this case, answering 42 would be perfectly valid. But you'd be stuck trying to figure out what the question is.


I want to make a First Person Shooter and its going to be networked. Please explain what a UID, persistance ID and what serializing itself means

Share this post


Link to post
Share on other sites
A unique identifier is used a lot in single player games also for multi player by the networking layers, it allows a machine to transmit data which corresponds to an individual entity (or type of entity).Local memory addresses have no meaningful representation on the other side of a connection therefore pointers can not be interpreted on the other side, so ids are used with serialisation. Serialising in this context is to take types of input and convert to a array of type(normally byte) to enable transition of the data from one side and allow de serialisation on the opposite side.

See the network forum faqs from details and examples.

Share this post


Link to post
Share on other sites
Sign in to follow this