Skip to content

Commit b7d664d

Browse files
author
Builder
committed
Merge branch 'fix-worldcommits-showing-entities-they-shouldnt' into 'master'
[FIX][sdk] fix wolrdcommits showing entities they shouldn't See merge request codingame/game-engine!132
2 parents f2a41bf + a5f7c45 commit b7d664d

File tree

2 files changed

+8
-3
lines changed
  • engine/modules/entities/src/main

2 files changed

+8
-3
lines changed

engine/modules/entities/src/main/java/com/codingame/gameengine/module/entities/Entity.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class Entity<T extends Entity<?>> {
1717

1818
private int x, y, zIndex;
1919
private double scaleX = 1, scaleY = 1;
20-
private boolean visible = true;
20+
private boolean visible = false;
2121
private double rotation, alpha = 1;
2222
ContainerBasedEntity parent;
2323
Mask mask;
@@ -29,7 +29,12 @@ static enum Type {
2929
Entity() {
3030
id = ++GraphicEntityModule.ENTITY_COUNT;
3131
state = new EntityState();
32-
32+
33+
// World commits made before the creation of an entity should not affect that entity.
34+
// This is why we set `visible` to false by default and immediately setVisible(true),
35+
// this way the first commit of this entity will turn it into something visible.
36+
// All other properties have no impact while the entity is invisible so it is effectively non-existant until it's first commit.
37+
setVisible(true);
3338
}
3439

3540
@SuppressWarnings("unchecked")

engine/modules/entities/src/main/resources/view/entity-module/Entity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export class Entity {
1313
scaleY: 1,
1414
zIndex: 0,
1515
alpha: 1,
16-
visible: true,
16+
visible: false,
1717
rotation: 0,
1818
mask: -1
1919
}

0 commit comments

Comments
 (0)