323 lines
15 KiB
Plaintext
323 lines
15 KiB
Plaintext
// Workspace: Game
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:34.
|
|
//
|
|
GAME_NAME :: "OCT24";
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:35.
|
|
//
|
|
#import "Bucket_Array";
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:248.
|
|
//
|
|
serialize_entity :: (e: *Entity, path: string) {
|
|
builder: String_Builder;
|
|
builder.allocator = temp;
|
|
|
|
if e.type == {
|
|
case Block; serialize_entity(cast(*Block)e, *builder);
|
|
case Character; serialize_entity(cast(*Character)e, *builder);
|
|
case Item; serialize_entity(cast(*Item)e, *builder);
|
|
|
|
}
|
|
|
|
File.write_entire_file(tprint("%/%.ent", path, e.id), builder_to_string(*builder));
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:259.
|
|
//
|
|
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
|
content := File.read_entire_file(path);
|
|
if content.count == 0 return null;
|
|
|
|
lines := split(content, "\n");
|
|
first_line := split(lines[0], ":");
|
|
|
|
if first_line.count != 2 return null;
|
|
|
|
e: *Entity;
|
|
|
|
type := trim(first_line[1], " \n\r");
|
|
|
|
if type == {
|
|
case "Block"; p, locator := find_and_occupy_empty_slot(*scene.by_type._Block); p._locator = locator; e = p; register_entity(scene, p); init_entity(p); deserialize_entity(scene, lines, cast(*Block)e); update_matrix(*e.transform);
|
|
case "Character"; p, locator := find_and_occupy_empty_slot(*scene.by_type._Character); p._locator = locator; e = p; register_entity(scene, p); init_entity(p); deserialize_entity(scene, lines, cast(*Character)e); update_matrix(*e.transform);
|
|
case "Item"; p, locator := find_and_occupy_empty_slot(*scene.by_type._Item); p._locator = locator; e = p; register_entity(scene, p); init_entity(p); deserialize_entity(scene, lines, cast(*Item)e); update_matrix(*e.transform);
|
|
|
|
}
|
|
|
|
return e;
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:268.
|
|
//
|
|
new_block :: (scene: *Scene = null) -> *Block { _scene := scene;
|
|
if _scene == null {
|
|
_scene = current_scene; }
|
|
p, locator := find_and_occupy_empty_slot(*_scene.by_type._Block); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }
|
|
new_character :: (scene: *Scene = null) -> *Character { _scene := scene;
|
|
if _scene == null {
|
|
_scene = current_scene; }
|
|
p, locator := find_and_occupy_empty_slot(*_scene.by_type._Character); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }
|
|
new_item :: (scene: *Scene = null) -> *Item { _scene := scene;
|
|
if _scene == null {
|
|
_scene = current_scene; }
|
|
p, locator := find_and_occupy_empty_slot(*_scene.by_type._Item); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
serialize_entity :: (e: *Item, builder: *String_Builder) {
|
|
print_to_builder(builder, "type: Item\n");
|
|
print_to_builder(builder, "entity.enabled: %\n", e.entity.enabled);
|
|
print_to_builder(builder, "entity.flags: %\n", e.entity.flags);
|
|
print_to_builder(builder, "entity.transform.position.x: %\n", e.entity.transform.position.x);
|
|
print_to_builder(builder, "entity.transform.position.y: %\n", e.entity.transform.position.y);
|
|
print_to_builder(builder, "entity.transform.position.z: %\n", e.entity.transform.position.z);
|
|
print_to_builder(builder, "entity.transform.orientation.x: %\n", e.entity.transform.orientation.x);
|
|
print_to_builder(builder, "entity.transform.orientation.y: %\n", e.entity.transform.orientation.y);
|
|
print_to_builder(builder, "entity.transform.orientation.z: %\n", e.entity.transform.orientation.z);
|
|
print_to_builder(builder, "entity.transform.orientation.w: %\n", e.entity.transform.orientation.w);
|
|
print_to_builder(builder, "entity.transform.scale.x: %\n", e.entity.transform.scale.x);
|
|
print_to_builder(builder, "entity.transform.scale.y: %\n", e.entity.transform.scale.y);
|
|
print_to_builder(builder, "entity.transform.scale.z: %\n", e.entity.transform.scale.z);
|
|
print_to_builder(builder, "entity.snap_offset.x: %\n", e.entity.snap_offset.x);
|
|
print_to_builder(builder, "entity.snap_offset.y: %\n", e.entity.snap_offset.y);
|
|
print_to_builder(builder, "entity.snap_offset.z: %\n", e.entity.snap_offset.z);
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
deserialize_entity :: (scene: *Scene, lines: [] string, e: *Item) {
|
|
for line: lines {
|
|
values := split(line, ":");
|
|
if values.count == 2 {
|
|
if trim(values[0], " ") == {
|
|
case "entity.enabled";
|
|
scan2(values[1], "%", *e.entity.enabled);
|
|
case "entity.transform.position.x";
|
|
scan2(values[1], "%", *e.entity.transform.position.x);
|
|
case "entity.transform.position.y";
|
|
scan2(values[1], "%", *e.entity.transform.position.y);
|
|
case "entity.transform.position.z";
|
|
scan2(values[1], "%", *e.entity.transform.position.z);
|
|
case "entity.transform.orientation.x";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.x);
|
|
case "entity.transform.orientation.y";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.y);
|
|
case "entity.transform.orientation.z";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.z);
|
|
case "entity.transform.orientation.w";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.w);
|
|
case "entity.transform.scale.x";
|
|
scan2(values[1], "%", *e.entity.transform.scale.x);
|
|
case "entity.transform.scale.y";
|
|
scan2(values[1], "%", *e.entity.transform.scale.y);
|
|
case "entity.transform.scale.z";
|
|
scan2(values[1], "%", *e.entity.transform.scale.z);
|
|
case "entity.snap_offset.x";
|
|
scan2(values[1], "%", *e.entity.snap_offset.x);
|
|
case "entity.snap_offset.y";
|
|
scan2(values[1], "%", *e.entity.snap_offset.y);
|
|
case "entity.snap_offset.z";
|
|
scan2(values[1], "%", *e.entity.snap_offset.z);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
serialize_entity :: (e: *Block, builder: *String_Builder) {
|
|
print_to_builder(builder, "type: Block\n");
|
|
print_to_builder(builder, "entity.enabled: %\n", e.entity.enabled);
|
|
print_to_builder(builder, "entity.flags: %\n", e.entity.flags);
|
|
print_to_builder(builder, "entity.transform.position.x: %\n", e.entity.transform.position.x);
|
|
print_to_builder(builder, "entity.transform.position.y: %\n", e.entity.transform.position.y);
|
|
print_to_builder(builder, "entity.transform.position.z: %\n", e.entity.transform.position.z);
|
|
print_to_builder(builder, "entity.transform.orientation.x: %\n", e.entity.transform.orientation.x);
|
|
print_to_builder(builder, "entity.transform.orientation.y: %\n", e.entity.transform.orientation.y);
|
|
print_to_builder(builder, "entity.transform.orientation.z: %\n", e.entity.transform.orientation.z);
|
|
print_to_builder(builder, "entity.transform.orientation.w: %\n", e.entity.transform.orientation.w);
|
|
print_to_builder(builder, "entity.transform.scale.x: %\n", e.entity.transform.scale.x);
|
|
print_to_builder(builder, "entity.transform.scale.y: %\n", e.entity.transform.scale.y);
|
|
print_to_builder(builder, "entity.transform.scale.z: %\n", e.entity.transform.scale.z);
|
|
print_to_builder(builder, "entity.snap_offset.x: %\n", e.entity.snap_offset.x);
|
|
print_to_builder(builder, "entity.snap_offset.y: %\n", e.entity.snap_offset.y);
|
|
print_to_builder(builder, "entity.snap_offset.z: %\n", e.entity.snap_offset.z);
|
|
print_to_builder(builder, "block_type: %\n", e.block_type);
|
|
print_to_builder(builder, "debug_id: %\n", e.debug_id);
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
deserialize_entity :: (scene: *Scene, lines: [] string, e: *Block) {
|
|
for line: lines {
|
|
values := split(line, ":");
|
|
if values.count == 2 {
|
|
if trim(values[0], " ") == {
|
|
case "entity.enabled";
|
|
scan2(values[1], "%", *e.entity.enabled);
|
|
case "entity.transform.position.x";
|
|
scan2(values[1], "%", *e.entity.transform.position.x);
|
|
case "entity.transform.position.y";
|
|
scan2(values[1], "%", *e.entity.transform.position.y);
|
|
case "entity.transform.position.z";
|
|
scan2(values[1], "%", *e.entity.transform.position.z);
|
|
case "entity.transform.orientation.x";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.x);
|
|
case "entity.transform.orientation.y";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.y);
|
|
case "entity.transform.orientation.z";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.z);
|
|
case "entity.transform.orientation.w";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.w);
|
|
case "entity.transform.scale.x";
|
|
scan2(values[1], "%", *e.entity.transform.scale.x);
|
|
case "entity.transform.scale.y";
|
|
scan2(values[1], "%", *e.entity.transform.scale.y);
|
|
case "entity.transform.scale.z";
|
|
scan2(values[1], "%", *e.entity.transform.scale.z);
|
|
case "entity.snap_offset.x";
|
|
scan2(values[1], "%", *e.entity.snap_offset.x);
|
|
case "entity.snap_offset.y";
|
|
scan2(values[1], "%", *e.entity.snap_offset.y);
|
|
case "entity.snap_offset.z";
|
|
scan2(values[1], "%", *e.entity.snap_offset.z);
|
|
case "debug_id";
|
|
scan2(values[1], "%", *e.debug_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
serialize_entity :: (e: *Character, builder: *String_Builder) {
|
|
print_to_builder(builder, "type: Character\n");
|
|
print_to_builder(builder, "entity.enabled: %\n", e.entity.enabled);
|
|
print_to_builder(builder, "entity.flags: %\n", e.entity.flags);
|
|
print_to_builder(builder, "entity.transform.position.x: %\n", e.entity.transform.position.x);
|
|
print_to_builder(builder, "entity.transform.position.y: %\n", e.entity.transform.position.y);
|
|
print_to_builder(builder, "entity.transform.position.z: %\n", e.entity.transform.position.z);
|
|
print_to_builder(builder, "entity.transform.orientation.x: %\n", e.entity.transform.orientation.x);
|
|
print_to_builder(builder, "entity.transform.orientation.y: %\n", e.entity.transform.orientation.y);
|
|
print_to_builder(builder, "entity.transform.orientation.z: %\n", e.entity.transform.orientation.z);
|
|
print_to_builder(builder, "entity.transform.orientation.w: %\n", e.entity.transform.orientation.w);
|
|
print_to_builder(builder, "entity.transform.scale.x: %\n", e.entity.transform.scale.x);
|
|
print_to_builder(builder, "entity.transform.scale.y: %\n", e.entity.transform.scale.y);
|
|
print_to_builder(builder, "entity.transform.scale.z: %\n", e.entity.transform.scale.z);
|
|
print_to_builder(builder, "entity.snap_offset.x: %\n", e.entity.snap_offset.x);
|
|
print_to_builder(builder, "entity.snap_offset.y: %\n", e.entity.snap_offset.y);
|
|
print_to_builder(builder, "entity.snap_offset.z: %\n", e.entity.snap_offset.z);
|
|
print_to_builder(builder, "look_direction.x: %\n", e.look_direction.x);
|
|
print_to_builder(builder, "look_direction.y: %\n", e.look_direction.y);
|
|
print_to_builder(builder, "look_direction.z: %\n", e.look_direction.z);
|
|
print_to_builder(builder, "target_look_direction.x: %\n", e.target_look_direction.x);
|
|
print_to_builder(builder, "target_look_direction.y: %\n", e.target_look_direction.y);
|
|
print_to_builder(builder, "target_look_direction.z: %\n", e.target_look_direction.z);
|
|
print_to_builder(builder, "current_yaw: %\n", e.current_yaw);
|
|
print_to_builder(builder, "current_direction.x: %\n", e.current_direction.x);
|
|
print_to_builder(builder, "current_direction.y: %\n", e.current_direction.y);
|
|
print_to_builder(builder, "current_direction.z: %\n", e.current_direction.z);
|
|
print_to_builder(builder, "last_footstep_audio: %\n", e.last_footstep_audio);
|
|
print_to_builder(builder, "animation_time: %\n", e.animation_time);
|
|
print_to_builder(builder, "jump_press_time: %\n", e.jump_press_time);
|
|
print_to_builder(builder, "last_grounded_time: %\n", e.last_grounded_time);
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:272.
|
|
//
|
|
deserialize_entity :: (scene: *Scene, lines: [] string, e: *Character) {
|
|
for line: lines {
|
|
values := split(line, ":");
|
|
if values.count == 2 {
|
|
if trim(values[0], " ") == {
|
|
case "entity.enabled";
|
|
scan2(values[1], "%", *e.entity.enabled);
|
|
case "entity.transform.position.x";
|
|
scan2(values[1], "%", *e.entity.transform.position.x);
|
|
case "entity.transform.position.y";
|
|
scan2(values[1], "%", *e.entity.transform.position.y);
|
|
case "entity.transform.position.z";
|
|
scan2(values[1], "%", *e.entity.transform.position.z);
|
|
case "entity.transform.orientation.x";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.x);
|
|
case "entity.transform.orientation.y";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.y);
|
|
case "entity.transform.orientation.z";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.z);
|
|
case "entity.transform.orientation.w";
|
|
scan2(values[1], "%", *e.entity.transform.orientation.w);
|
|
case "entity.transform.scale.x";
|
|
scan2(values[1], "%", *e.entity.transform.scale.x);
|
|
case "entity.transform.scale.y";
|
|
scan2(values[1], "%", *e.entity.transform.scale.y);
|
|
case "entity.transform.scale.z";
|
|
scan2(values[1], "%", *e.entity.transform.scale.z);
|
|
case "entity.snap_offset.x";
|
|
scan2(values[1], "%", *e.entity.snap_offset.x);
|
|
case "entity.snap_offset.y";
|
|
scan2(values[1], "%", *e.entity.snap_offset.y);
|
|
case "entity.snap_offset.z";
|
|
scan2(values[1], "%", *e.entity.snap_offset.z);
|
|
case "look_direction.x";
|
|
scan2(values[1], "%", *e.look_direction.x);
|
|
case "look_direction.y";
|
|
scan2(values[1], "%", *e.look_direction.y);
|
|
case "look_direction.z";
|
|
scan2(values[1], "%", *e.look_direction.z);
|
|
case "target_look_direction.x";
|
|
scan2(values[1], "%", *e.target_look_direction.x);
|
|
case "target_look_direction.y";
|
|
scan2(values[1], "%", *e.target_look_direction.y);
|
|
case "target_look_direction.z";
|
|
scan2(values[1], "%", *e.target_look_direction.z);
|
|
case "current_yaw";
|
|
scan2(values[1], "%", *e.current_yaw);
|
|
case "current_direction.x";
|
|
scan2(values[1], "%", *e.current_direction.x);
|
|
case "current_direction.y";
|
|
scan2(values[1], "%", *e.current_direction.y);
|
|
case "current_direction.z";
|
|
scan2(values[1], "%", *e.current_direction.z);
|
|
case "last_footstep_audio";
|
|
scan2(values[1], "%", *e.last_footstep_audio);
|
|
case "animation_time";
|
|
scan2(values[1], "%", *e.animation_time);
|
|
case "jump_press_time";
|
|
scan2(values[1], "%", *e.jump_press_time);
|
|
case "last_grounded_time";
|
|
scan2(values[1], "%", *e.last_grounded_time);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// String added via add_build_string() from c:/Personal/games/onegameamonth/oct24/modules/Coven/metaprogram.jai:280.
|
|
//
|
|
|
|
// NUM_ENTITY_TYPES tells the target program how many entity types there are.
|
|
NUM_ENTITY_TYPES :: 3;
|
|
|
|
// entity_types is an array containing all the entity types.
|
|
entity_types : [3] Type : .[ Block, Character, Item ];
|
|
|
|
Entity_Storage :: struct {
|
|
_Block: Bucket_Array(Block, 20, true);
|
|
_Character: Bucket_Array(Character, 20, true);
|
|
_Item: Bucket_Array(Item, 20, true);
|
|
|
|
}
|