[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Slick Forums • View topic - Component inheritance

Slick Forums

Discuss the Slick 2D Library
It is currently Thu Jun 01, 2023 9:58 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Component inheritance
PostPosted: Sun Nov 03, 2013 10:45 am 
Offline

Joined: Mon Oct 28, 2013 10:41 am
Posts: 4


Top
 Profile  
 
PostPosted: Sun Nov 03, 2013 4:52 pm 
Offline

Joined: Sun Jun 03, 2012 9:21 pm
Posts: 49
Artemis - and Entity-Systems in general - don't have any notion of polymorphic components.

Components are mapped according to the index reported by ComponentType, which in turn is used for mapping component types to entities (componentBits field in Entity) and by the ComponentManager for tracking all component instances.

Conceptually, artemis provides a slot for each component type for every entity. When a component is inserted into an entity, it positions itself in the slot designated for that component (which is why an entity can only have one component per type).

So, when you add a Bullet to the entity, it's inserted into the Bullet slot - whereas the ComponentMapper goes looking for the component in the Projectile slot.

Why do you need to extend Projectile in the first place? Either make Projectile a concrete component or remove it altogether (but I'm guessing there's a reason why it's there).

_________________
: bytecode-weaving antiboilerplate lib for artemis. | : bugfixing and performance optimized fork.


Top
 Profile  
 
PostPosted: Sun Nov 03, 2013 9:06 pm 
Offline

Joined: Mon Oct 28, 2013 10:41 am
Posts: 4
Well, it's not a problem. I was just wondering why that is, and you've answered the question to my satisfaction.
I'm in a midst of converting from hierarchy based entity design to ECS, so I'm not thinking with ECS fully yet.

I have some properties like base damage that I've put in the top class Projectile before. But I'm now redesigning the classes so that I will have a single component that holds the aforementioned properties.
Hopefully, I'm heading toward the right direction.


Top
 Profile  
 
PostPosted: Tue Nov 05, 2013 11:56 am 
Offline

Joined: Sun Jun 03, 2012 9:21 pm
Posts: 49
Not sure if it helps, but on some theoretical level, an entity is a Thing made up of properties(/components) intrinsic to the world. As a rule of thumb (my thumb, at least), if something is a concrete thing, it's an entity. Position, Damage and so forth are properties used for describing Things.

You could model the Bullet as follows:
- Collidible
- HitPoints (when it collides, subtract health from the bullet, so that it too "dies")./
- Damage (inflict this on collision, if the other entity has HitPoints, in your Collision system or such)
- Position
- Velocity
- HasOwner (don't want it to collide with your avatar/ship)
- SpriteReference
- Size

So, none of the entities would need an actual Projectile component. In practice however, it sometimes makes sense though.

_________________
: bytecode-weaving antiboilerplate lib for artemis. | : bugfixing and performance optimized fork.


Top
 Profile  
 
PostPosted: Tue Nov 05, 2013 9:02 pm 
Offline

Joined: Mon Oct 28, 2013 10:41 am
Posts: 4
That makes sense, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group