Skip to content

Commit ff547e5

Browse files
committed
Fixing some cases of static meshes not updating in the editor
1 parent ca1b79f commit ff547e5

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

DelvEdit/src/com/interrupt/dungeoneer/editor/EditorFrame.java

+2
Original file line numberDiff line numberDiff line change
@@ -3314,6 +3314,7 @@ public void paste() {
33143314
}
33153315

33163316
level.entities.add(copy);
3317+
copy.init(level, Source.EDITOR);
33173318

33183319
markWorldAsDirty((int)copy.x, (int)copy.y, 4);
33193320
}
@@ -3854,6 +3855,7 @@ public void doPaint() {
38543855
public void doDelete() {
38553856
if(pickedEntity != null) {
38563857
level.entities.removeValue(pickedEntity, true);
3858+
markWorldAsDirty((int)pickedEntity.x, (int)pickedEntity.y, 4);
38573859

38583860
for(Entity selEntity : additionalSelected) {
38593861
level.entities.removeValue(selEntity, true);

DelvEdit/src/com/interrupt/dungeoneer/editor/EditorRightClickEntitiesMenu.java

+3
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,9 @@ else if(surface.edge == TileEdges.South) {
220220
}
221221

222222
editor.level.entities.add(entity);
223+
entity.init(editor.level, Level.Source.EDITOR);
224+
editor.markWorldAsDirty((int)entity.x, (int)entity.y, 4);
225+
223226
editor.refreshLights();
224227
editor.history.saveState(editor.level);
225228
}

DelvEdit/src/com/interrupt/dungeoneer/editor/EditorRightClickMenu.java

+6
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ public void actionPerformed (ActionEvent event) {
110110
newGroup.x = main.x;
111111
newGroup.y = main.y;
112112
newGroup.z = main.z;
113+
114+
editor.markWorldAsDirty((int)main.x, (int)main.y, 4);
113115

114116
for(Entity selected : additionalSelected) {
115117
selected.x = selected.x - main.x;
116118
selected.y = selected.y - main.y;
117119
selected.z = selected.z - main.z;
118120
newGroup.entities.add(selected);
121+
122+
editor.markWorldAsDirty((int)selected.x, (int)selected.y, 4);
119123

120124
level.entities.removeValue(selected, true);
121125
}
@@ -133,9 +137,11 @@ public void actionPerformed (ActionEvent event) {
133137
remove.addActionListener(new ActionListener() {
134138
public void actionPerformed (ActionEvent event) {
135139
level.entities.removeValue(main, true);
140+
editor.markWorldAsDirty((int)main.x, (int)main.y, 4);
136141

137142
for(Entity selected : additionalSelected) {
138143
level.entities.removeValue(selected, true);
144+
editor.markWorldAsDirty((int)selected.x, (int)selected.y, 4);
139145
}
140146

141147
editor.refreshLights();

Dungeoneer/src/com/interrupt/dungeoneer/gfx/WorldChunk.java

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.interrupt.dungeoneer.Art;
1515
import com.interrupt.dungeoneer.GameManager;
1616
import com.interrupt.dungeoneer.entities.Entity;
17+
import com.interrupt.dungeoneer.entities.Group;
1718
import com.interrupt.dungeoneer.game.Game;
1819
import com.interrupt.dungeoneer.game.Level;
1920
import com.interrupt.dungeoneer.game.OverworldChunk;
@@ -128,6 +129,19 @@ public void freeStaticMeshes() {
128129
staticMeshBatch.clear();
129130
}
130131
}
132+
133+
public void AddEntityForEditor(Entity e, Level level) {
134+
// Needed for static meshes in groups in the editor
135+
if(e instanceof Group) {
136+
e.init(level, Level.Source.EDITOR);
137+
for(Entity g : ((Group) e).entities) {
138+
AddEntityForEditor(g, level);
139+
}
140+
} else {
141+
entities.add(e);
142+
e.updateLight(level);
143+
}
144+
}
131145

132146
public void Tesselate(Level level, GlRenderer renderer)
133147
{
@@ -150,8 +164,7 @@ public void Tesselate(Level level, GlRenderer renderer)
150164
if(renderer.editorIsRendering) {
151165
for(Entity e : level.entities) {
152166
if(e.x >= xOffset && e.x < xOffset + width && e.y >= yOffset && e.y < yOffset + height) {
153-
entities.add(e);
154-
e.updateLight(level);
167+
AddEntityForEditor(e, level);
155168
}
156169
}
157170
}

0 commit comments

Comments
 (0)