blades-engine fix data cloning

This commit is contained in:
2022-05-18 21:44:37 -04:00
parent 244d4aaa7b
commit f329baf18e
2 changed files with 15 additions and 8 deletions

View File

@@ -33,7 +33,7 @@ class FloorData {
public function clone():FloorData {
var fd = new FloorData();
for (field in FloorData.getClassFields()) {
for (field in FloorData.getInstanceFields()) {
fd.setField(field, this.field(field));
}
return fd;

View File

@@ -49,19 +49,25 @@ class ScenData {
var data:Dynamic = null;
interp.variables["data"] = null;
function mapFor(type:String):Map<Int,Dynamic> {
return switch (type) {
case "floor":
floorData;
case "terrain":
terrainData;
default:
null;
};
}
function commitData() {
data = interp.variables["data"];
if (data == null) return;
trace(data);
switch (defining) {
case "floor":
floorData[id] = data;
case "terrain":
terrainData[id] = data;
default:
}
mapFor(defining)[id] = data;
data = data.clone();
interp.variables["data"] = data;
}
function clear(?type:String) {
if (type == null) type = defining;
@@ -73,6 +79,7 @@ class ScenData {
default:
null;
};
interp.variables["data"] = data;
}
function beginDefine(type, tid) {
commitData();