Is there a good way ECS for creating variants of a behaviour like in Java interfaces?

In Java, there are interfaces – I’m not clear on the details (I don’t use Java) but from what I’ve learned, they seem to be "classes for classes": a way to effectively make individual classes "instances" of one overarching class. For example, a "Cup" interface could be implemented by a "Mug" class, a "Glass" class, a "Goblet" class etc. As long as they have the same I/O methods such as fill(), empty() or drink(), they can be used interchangeably.

In languages with duck typing, interfaces are not needed – the language allows for classes to be used interchangeably as long as no invalid properties of methods are referenced. This is another valid was of going about things in OOP. This is how I usually go about things.

My question: how can I create varied behaviour in an ECS if components are data-only? I like to think in terms of first-class functions, but that seems to be taboo since components are not supposed to hold behaviour.

Option 1, have a massive switch or if/else chain in my System:

For example, if I have an AI component with several different behaviours, I could use an integer to define which type of AI to use for that particular entity. It seems a bit convoluted and inelegant.

Option 2, have a separate Component and matching System for each behaviour:

This would be neater in each individual System but as a whole, the program would be a mess. This wouldn’t work because of the large amounts of variation such as hundreds of different guns in a shooter game.

Option 3, use a flyweight-like data structure independent of the Component:

This would mean storing all of the different behaviours elsewhere, and storing a key that a System can use to access the behaviour. This is basically a fancy version of the switch option above, but it seems neater as there wouldn’t be a massive dump of code in the System.

Option 4, creating a complex way of encoding a description of the desired behaviour which the System can interpret:

This seems to be the most overkill of the lot. Unless I have to, or there are significant advantages, I’m trying to stay away from this.

If there’s no other way, I’ll just adopt the methodology of first-class functions as I usually do and just ignore any guidelines about ECS I’ve heard, just for this one case. The problem is, it probably won’t just be one case in the future.

Have I missed any other good options? Is there an industry standard or recommendation? If not, what considerations should I make about which option to choose?

Gutenberg is there a way to know if the current block is reusable?

So I have developed some blocks using React, I save my css generated in the post meta, that’s works fine. In the case of reusable blocks:

  • Whene we set a block as reusable this block will saved as hidden CPT (wp_block) as the documentation. (
  • Since the block is reusable I wanted to save the css generated for the reusable block in one place (post meta for wp_block CPT for example), that’s will achieve the goal of reusable block, whene the reusable block changed, this will affect all place (posts/pages) that use this reusable block. For that I wanted to check if rendred block is reusable to handel some login?

How to tell MMA to transform a number to a factorial,Is there a native function?

I came across the need to transform a number into a factorial n, with positive integer n, I have searched in the MMA information but I can’t find anything like that.

I imagine an input, which verifies that it is a factorial, and if it is, prints the number in its n-form!

if there is no native function any idea how to implement it?

for example


51090942171709420000 does not correspond to a factorial.

Is there a way where we can verify if certain image is 3D or not [closed]

I wanted to understand – Is there a way where we can verify if certain image is 3D or not

So basically I want to automate the process where we can detect if certain given image is of 3D or not

Problem: In my application – I often detect few 3D images are showing as plain black image or sometimes 3D images are broken

So if I can find a way where I can check that certain image should not be completely black and should be 3D model and not 2D image

My Application is in C# – but I am open for any solution irrespective of language!!

Thanks in advance

Is there a RAW way to allow the PCs to recover only some of their spell slots etc?

My party were rather foolhardy and have got themselves knocked out and captured. Their captors want to keep them alive for a bit to question and then to sacrifice.

The party expended pretty much all their resources in the battle and so without a long rest are not going to have much chance of escape. However, it also feels wrong to say "you spend the night tied up in a stable and now you have all your spells and HP back". Which would make escape probably quite easy and anticlimactic.

Is there a way to reflect that they got some rest, but not a good night’s sleep?