Skip to main content
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 ...
Engineer's user avatar
  • 30.4k
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,...
jzx's user avatar
  • 3,845
2 votes

Problem with Parameters for polymorphism class

You aren't using generics correctly. ...
Kevin's user avatar
  • 6,976
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 ...
Philipp's user avatar
  • 123k
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 ...
Theraot's user avatar
  • 28.2k
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 ...
Philipp's user avatar
  • 123k
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-...
DMGregory's user avatar
  • 141k
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 ...
Naros's user avatar
  • 2,022
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. ...
Smilediver's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible