deinit_entity
This commit is contained in:
@@ -456,9 +456,9 @@ generate_serialize_procedure_for_entity :: (code_struct: *Code_Struct) {
|
||||
deserialize : String_Builder;
|
||||
print_to_builder(*deserialize, "deserialize_entity :: (scene: *Scene, lines: [] string, e: *%) {\n", name);
|
||||
print_to_builder(*deserialize, "\tfor line: lines {\n");
|
||||
print_to_builder(*deserialize, "\t\tvalues := split(line, \":\");\n");
|
||||
print_to_builder(*deserialize, "\t\tvalues := split(line, \":\",, temp);\n");
|
||||
print_to_builder(*deserialize, "\t\tif values.count == 2 {\n");
|
||||
print_to_builder(*deserialize, "\t\t\tif trim(values[0], \" \") == {\n");
|
||||
print_to_builder(*deserialize, "\t\t\tif trim(values[0], \" \",, temp) == {\n");
|
||||
|
||||
generate_member_deserialization(code_struct.defined_type, *deserialize);
|
||||
|
||||
@@ -526,9 +526,15 @@ message_loop :: () {
|
||||
}
|
||||
|
||||
for typechecked.procedure_headers {
|
||||
for note: it.expression.notes {
|
||||
if to_lower_copy(note.text,, allocator = temp) == "newentity" {
|
||||
array_add(*new_entity_procs, it.expression.name);
|
||||
if it.expression.name == "deinit_entity" {
|
||||
//struct_type := cast(*Type_Info_Struct)it.expression.arguments[0].type_inst.pointer_to;
|
||||
struct_type := cast(*Type_Info_Struct)it.expression.arguments[0].type_inst.pointer_to.result;
|
||||
array_add(*deinit_entity_procs, struct_type.name);
|
||||
} else {
|
||||
for note: it.expression.notes {
|
||||
if to_lower_copy(note.text,, allocator = temp) == "newentity" {
|
||||
array_add(*new_entity_procs, it.expression.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -662,6 +668,17 @@ generate_code :: (w: Workspace) {
|
||||
add_build_string(build_string, w);
|
||||
}
|
||||
|
||||
{
|
||||
builder: String_Builder;
|
||||
|
||||
for deinit_entity_procs {
|
||||
print_to_builder(*builder, "\tcase %1; deinit_entity(cast(*%1)e);\n", it);
|
||||
}
|
||||
|
||||
build_string := sprint(DEINIT_ENTITY, builder_to_string(*builder));
|
||||
add_build_string(build_string, w);
|
||||
}
|
||||
|
||||
{
|
||||
builder: String_Builder;
|
||||
|
||||
@@ -691,6 +708,7 @@ generate_code :: (w: Workspace) {
|
||||
generated_code := false;
|
||||
entity_type_names: [..] string;
|
||||
new_entity_procs: [..] string;
|
||||
deinit_entity_procs: [..] string;
|
||||
|
||||
// INSERTION_STRING represents the code we want to add to the target program.
|
||||
// We'll use print to insert useful things where the % markers are.
|
||||
@@ -742,8 +760,8 @@ deserialize_entity :: (scene: *Scene, id: Entity_Id, path: string) -> *Entity {
|
||||
content := File.read_entire_file(path);
|
||||
if content.count == 0 return null;
|
||||
|
||||
lines := split(content, "\n");
|
||||
first_line := split(lines[0], ":");
|
||||
lines := split(content, "\n",, temp);
|
||||
first_line := split(lines[0], ":",, temp);
|
||||
|
||||
if first_line.count != 2 return null;
|
||||
|
||||
@@ -781,6 +799,16 @@ entity_ui :: (e: *Entity) {
|
||||
}
|
||||
DONE
|
||||
|
||||
DEINIT_ENTITY :: #string DONE
|
||||
#if EDITOR {
|
||||
call_correct_deinit_entity :: (e: *Entity) {
|
||||
if e.type == {
|
||||
%1
|
||||
}
|
||||
}
|
||||
}
|
||||
DONE
|
||||
|
||||
INIT_SCENE :: #string DONE
|
||||
init_scene :: (scene: *Scene) {
|
||||
%1
|
||||
@@ -803,8 +831,10 @@ PLACEHOLDER :: #string DONE
|
||||
#poke_name Coven Entity_Storage;
|
||||
#poke_name Coven delete_entity;
|
||||
#poke_name Coven deserialize_entity;
|
||||
#poke_name Coven deinit_entity;
|
||||
#poke_name Coven serialize_entity;
|
||||
#poke_name Coven new_mesh_entity;
|
||||
#poke_name Coven call_correct_deinit_entity;
|
||||
|
||||
#if EDITOR {
|
||||
#poke_name Coven editor_ui_entity_creation;
|
||||
|
||||
Reference in New Issue
Block a user