Question about which system to use
See original GitHub issueHi,
I was wondering whether it would be better to use an IExecuteSystem or a ReactiveSystem? I think a ReactiveSystem is more optimised but I’m not sure.
using System.Collections.Generic;
using Entitas;
using Entitas.CodeGeneration.Attributes;
using UnityEngine;
namespace Assets.Sources.Physics.Logic
{
public class GravitySystem : ReactiveSystem<GameEntity>
{
private float m_gravity = .98f;
public GravitySystem(Contexts contexts) : base(contexts.game)
{
}
protected override ICollector<GameEntity> GetTrigger(IContext<GameEntity> context)
{
return context.CreateCollector(GameMatcher.OnGround.Removed(), GameMatcher.Velocity.Added());
}
protected override bool Filter(GameEntity entity)
{
return entity.isOnGround == false;
}
protected override void Execute(List<GameEntity> entities)
{
foreach (var entity in entities)
{
var velocity = Vector2.zero;
if (entity.hasVelocity)
{
velocity = new Vector2(entity.velocity.x,entity.velocity.y);
}
if (velocity.y < m_gravity)
{
velocity.y += m_gravity;
}
entity.ReplaceVelocity(velocity.x, velocity.y);
}
}
}
}
Cheers
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Questions to Ask About Systems - Project 2061
a. When this system is working, what does it do? b. For this system to work, must it receive any input? c. What,...
Read more >The collaboration system user interface:10 questions you ...
Here are 10 questions you can ask about a collaboration system you are considering to see if it will really capture the hearts...
Read more >9 questions to ask when implementing a new IT system
9 questions to ask when implementing a new IT system · 1. What problem are we planning to solve? · 2. What are...
Read more >7 Questions to Ask End Users Before Choosing a New ...
7 Questions to Ask End Users Before Choosing a New Software System · What do you like about our current system? · How...
Read more >Questionnaire for determining usability of a system
Using a rating system based on the Likert Scale is a very common and valid approach. Quoting Wikipedia:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Advantage of GetEntities() is that it’s always exactly up to date so there’s no need for the extra logic performed in .Filter() in an RS - presence of the components from your group is guarenteed as long as you consume the entities right after you call GetEntities().
Didn’t think of it like that, thanks man!