:D
This commit is contained in:
commit
09ade10207
117 changed files with 2153 additions and 0 deletions
88
eastern flames/scripts/deep_copy/deep_copy.gml
Normal file
88
eastern flames/scripts/deep_copy/deep_copy.gml
Normal file
|
@ -0,0 +1,88 @@
|
|||
function deep_copy(struct, antiwhiletrue=[]) {
|
||||
var newone = {};
|
||||
var oldstuff = variable_struct_get_names(struct);
|
||||
var i;
|
||||
for (i=0; i<array_length(oldstuff); i++) {
|
||||
switch typeof(struct[$oldstuff[i]]) {
|
||||
case "struct":
|
||||
if !array_contains(antiwhiletrue, struct[$oldstuff[i]]) {
|
||||
array_push(antiwhiletrue, struct[$oldstuff[i]]);
|
||||
newone[$oldstuff[i]] = deep_copy(struct[$oldstuff[i]], antiwhiletrue);
|
||||
} else {
|
||||
newone[$oldstuff[i]] = struct[$oldstuff[i]];
|
||||
}
|
||||
break;
|
||||
case "array":
|
||||
newone[$oldstuff[i]] = [];
|
||||
var len = array_length(struct[$oldstuff[i]])
|
||||
array_copy(newone[$oldstuff[i]], 0, struct[$oldstuff[i]], 0, len);
|
||||
break;
|
||||
case "method":
|
||||
if method_get_self(struct[$oldstuff[i]]) == struct {
|
||||
newone[$oldstuff[i]] = method(newone, struct[$oldstuff[i]]);
|
||||
} else {
|
||||
newone[$oldstuff[i]] = struct[$oldstuff[i]];
|
||||
//log("it's someone else!");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
newone[$oldstuff[i]] = struct[$oldstuff[i]];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return newone;
|
||||
}
|
||||
|
||||
function deep_copy_instance(instance) {
|
||||
var farts = instance_create(instance.x, instance.y, instance.object_index);
|
||||
var oldstuff = variable_struct_get_names(instance);
|
||||
var i;
|
||||
for (i=0; i<array_length(oldstuff); i++) {
|
||||
if is_struct(variable_instance_get(instance, oldstuff[i])) {
|
||||
variable_instance_set(farts, oldstuff[i], deep_copy(variable_instance_get(instance, oldstuff[i])));
|
||||
} else {
|
||||
variable_instance_set(farts, oldstuff[i], variable_instance_get(instance, oldstuff[i]));
|
||||
}
|
||||
}
|
||||
|
||||
return farts;
|
||||
}
|
||||
|
||||
function deep_copy_into(struct, targetstruct, antiwhiletrue=[]) {
|
||||
var oldstuff = variable_struct_get_names(struct);
|
||||
|
||||
var i;
|
||||
log(11);
|
||||
for (i=0; i<array_length(oldstuff); i++) {
|
||||
log(string(22) + string(i));
|
||||
if is_struct(struct[$oldstuff[i]]) {
|
||||
if !array_contains(antiwhiletrue, struct[$oldstuff[i]]) {
|
||||
log(string(99) + oldstuff[i]);
|
||||
array_push(antiwhiletrue, struct[$oldstuff[i]]);
|
||||
targetstruct[$oldstuff[i]] = deep_copy(struct[$oldstuff[i]], antiwhiletrue);
|
||||
|
||||
} else {
|
||||
log("WASNT" + oldstuff[i]);
|
||||
targetstruct[$oldstuff[i]] = struct[$oldstuff[i]];
|
||||
}
|
||||
} else {
|
||||
log(string(33) + oldstuff[i]);
|
||||
|
||||
targetstruct[$oldstuff[i]] = struct[$oldstuff[i]];
|
||||
}
|
||||
}
|
||||
log(string(44) + string(i));
|
||||
log(irandom(999));
|
||||
}
|
||||
|
||||
function deep_copy_instance_into(instance, targetinstance) {
|
||||
var oldstuff = variable_struct_get_names(instance);
|
||||
var i;
|
||||
for (i=0; i<array_length(oldstuff); i++) {
|
||||
if is_struct(variable_instance_get(instance, oldstuff[i])) {
|
||||
variable_instance_set(targetinstance, oldstuff[i], deep_copy(variable_instance_get(instance, oldstuff[i])));
|
||||
} else {
|
||||
variable_instance_set(targetinstance, oldstuff[i], variable_instance_get(instance, oldstuff[i]));
|
||||
}
|
||||
}
|
||||
}
|
12
eastern flames/scripts/deep_copy/deep_copy.yy
Normal file
12
eastern flames/scripts/deep_copy/deep_copy.yy
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"isDnD": false,
|
||||
"isCompatibility": false,
|
||||
"parent": {
|
||||
"name": "data",
|
||||
"path": "folders/Scripts/data.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "deep_copy",
|
||||
"tags": [],
|
||||
"resourceType": "GMScript",
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue