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 { public function clone():FloorData {
var fd = new FloorData(); var fd = new FloorData();
for (field in FloorData.getClassFields()) { for (field in FloorData.getInstanceFields()) {
fd.setField(field, this.field(field)); fd.setField(field, this.field(field));
} }
return fd; return fd;

View File

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