3
votes
Accepted
Make the components of an ECS polymorphic
Both your possible solutions are unnecessarily complicated or brittle: generally, ill-advised.
Polymorphism
Your question title is
Make the components of an ECS polymorphic
but then you don't ...
2
votes
RPG Item Design
Similar to the answer to the question referenced by Philipp, you might consider using a general system of events and flags for every item:
CanEquip, OnEquip/OnDeEquip
CanConsume, OnConsume
IsQuestItem,...
2
votes
2
votes
Accepted
What design pattern should I use for adding functionality
Composition over inheritance.
The basic idea that instead of having one specific class for each kind of entity in your game that is part of a long inheritance chain with "Entity" as the ...
1
vote
Accepted
How to replace if/else/switch with polymorphisim
I'll just cover the is_key_pressed I proposed in comments.
You could have a list of input handlers strategies. It would be a list of key-value pairs. Where they key ...
1
vote
How to replace if/else/switch with polymorphisim
The OOP way to do this, would be to give the class wall a method handleCollision(ball) (although instead of ...
1
vote
Accepted
Interact with inheriting class methods from "casted" base class (collisions, etc)
In Unity, I'd generally recommend working with the principle of composition over inheritance.
In this case, if player characters, enemies, and environment objects all need to take damage, then damage-...
1
vote
Accepted
Using polymorphism in an Entity-Component System without sacrificing data-oriented design
The way I approached this was to use a constexpr string-hash which I apply to my components at compile-time to assign each of them a unique id. I essentially do this with the use of a macro where I ...
1
vote
Accepted
How to: Duplicating and updating component data in systems
First of all, there is no such thing as a good pure ECS. Every ECS system is different, and all of them have their own advantages and disadvantages.
Problem #1
I'd go with the following setup. ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
polymorphism × 26c++ × 11
unity × 7
c# × 6
software-engineering × 6
architecture × 4
entity-system × 4
component-based × 3
oop × 3
inheritance × 3
optimization × 2
design-patterns × 2
opengl × 1
collision-detection × 1
rpg × 1
sfml × 1
rigidbody × 1
serialization × 1
entity-component × 1
objects × 1
levels × 1
json × 1
interface × 1
tweening × 1
effect × 1