From cc53757a37f49da4b7d0c0207bb635ec89fc5d18 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Fri, 31 Jan 2020 21:31:33 +0400 Subject: [PATCH] Don't activate/deactivate/remove entities when not needed --- core/src/com/me/common/ecs/Entity.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/com/me/common/ecs/Entity.java b/core/src/com/me/common/ecs/Entity.java index dd79c83..5345ffd 100644 --- a/core/src/com/me/common/ecs/Entity.java +++ b/core/src/com/me/common/ecs/Entity.java @@ -39,19 +39,25 @@ public final class Entity { } public void activate() { - active = true; - refresh(); + if (!active) { + active = true; + refresh(); + } } public void deactivate() { - active = false; - refresh(); + if (active) { + active = false; + refresh(); + } } public void remove() { - removed = true; - active = false; - refresh(); + if (!removed) { + removed = true; + active = false; + refresh(); + } } public Engine getEngine() {