Compiles again
This commit is contained in:
@@ -5,6 +5,11 @@
|
|||||||
//
|
//
|
||||||
GAME_NAME :: "FPS";
|
GAME_NAME :: "FPS";
|
||||||
|
|
||||||
|
//
|
||||||
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:33.
|
||||||
|
//
|
||||||
|
#import "Bucket_Array";
|
||||||
|
|
||||||
//
|
//
|
||||||
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:246.
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:246.
|
||||||
//
|
//
|
||||||
@@ -20,14 +25,14 @@ serialize_entity :: (e: *Entity, path: string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write_entire_file(tprint("%/%.ent", path, e.id), builder_to_string(*builder));
|
File.write_entire_file(tprint("%/%.ent", path, e.id), builder_to_string(*builder));
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:257.
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:257.
|
||||||
//
|
//
|
||||||
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
||||||
content := read_entire_file(path);
|
content := File.read_entire_file(path);
|
||||||
if content.count == 0 return null;
|
if content.count == 0 return null;
|
||||||
|
|
||||||
lines := split(content, "\n");
|
lines := split(content, "\n");
|
||||||
@@ -55,19 +60,19 @@ deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
|||||||
//
|
//
|
||||||
new_block :: (scene: *Scene = null) -> *Block { _scene := scene;
|
new_block :: (scene: *Scene = null) -> *Block { _scene := scene;
|
||||||
if _scene == null {
|
if _scene == null {
|
||||||
_scene = game_state.current_scene; }
|
_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; }
|
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;
|
new_character :: (scene: *Scene = null) -> *Character { _scene := scene;
|
||||||
if _scene == null {
|
if _scene == null {
|
||||||
_scene = game_state.current_scene; }
|
_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; }
|
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;
|
new_item :: (scene: *Scene = null) -> *Item { _scene := scene;
|
||||||
if _scene == null {
|
if _scene == null {
|
||||||
_scene = game_state.current_scene; }
|
_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; }
|
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; }
|
||||||
new_pistol :: (scene: *Scene = null) -> *Pistol { _scene := scene;
|
new_pistol :: (scene: *Scene = null) -> *Pistol { _scene := scene;
|
||||||
if _scene == null {
|
if _scene == null {
|
||||||
_scene = game_state.current_scene; }
|
_scene = current_scene; }
|
||||||
p, locator := find_and_occupy_empty_slot(*_scene.by_type._Pistol); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }
|
p, locator := find_and_occupy_empty_slot(*_scene.by_type._Pistol); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -142,82 +147,6 @@ deserialize_entity :: (scene: *Scene, lines: [] string, e: *Item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:270.
|
|
||||||
//
|
|
||||||
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.grid_position.x: %\n", e.entity.grid_position.x);
|
|
||||||
print_to_builder(builder, "entity.grid_position.y: %\n", e.entity.grid_position.y);
|
|
||||||
print_to_builder(builder, "entity.grid_position.z: %\n", e.entity.grid_position.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/FPS/modules/Coven/metaprogram.jai:270.
|
|
||||||
//
|
|
||||||
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.grid_position.x";
|
|
||||||
scan2(values[1], "%", *e.entity.grid_position.x);
|
|
||||||
case "entity.grid_position.y";
|
|
||||||
scan2(values[1], "%", *e.entity.grid_position.y);
|
|
||||||
case "entity.grid_position.z";
|
|
||||||
scan2(values[1], "%", *e.entity.grid_position.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/FPS/modules/Coven/metaprogram.jai:270.
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:270.
|
||||||
//
|
//
|
||||||
@@ -311,6 +240,82 @@ deserialize_entity :: (scene: *Scene, lines: [] string, e: *Pistol) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:270.
|
||||||
|
//
|
||||||
|
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.grid_position.x: %\n", e.entity.grid_position.x);
|
||||||
|
print_to_builder(builder, "entity.grid_position.y: %\n", e.entity.grid_position.y);
|
||||||
|
print_to_builder(builder, "entity.grid_position.z: %\n", e.entity.grid_position.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/FPS/modules/Coven/metaprogram.jai:270.
|
||||||
|
//
|
||||||
|
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.grid_position.x";
|
||||||
|
scan2(values[1], "%", *e.entity.grid_position.x);
|
||||||
|
case "entity.grid_position.y";
|
||||||
|
scan2(values[1], "%", *e.entity.grid_position.y);
|
||||||
|
case "entity.grid_position.z";
|
||||||
|
scan2(values[1], "%", *e.entity.grid_position.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/FPS/modules/Coven/metaprogram.jai:270.
|
// String added via add_build_string() from c:/Personal/games/FPS/modules/Coven/metaprogram.jai:270.
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -81,6 +81,10 @@ operator - :: inline (a: Vector3i, b: Vector3i) -> Vector3i {
|
|||||||
return .{a.x - b.x, a.y - b.y, a.z - b.z};
|
return .{a.x - b.x, a.y - b.y, a.z - b.z};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transform_position :: (position: Vector3, matrix: Matrix4) -> Vector3 {
|
||||||
|
return to_v3(matrix * to_v4(position));
|
||||||
|
}
|
||||||
|
|
||||||
to_v4 :: (v3: Vector3) -> Vector4 {
|
to_v4 :: (v3: Vector3) -> Vector4 {
|
||||||
v4 : Vector4;
|
v4 : Vector4;
|
||||||
v4.x = v3.x;
|
v4.x = v3.x;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ Particle_System :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create_particle_system :: (pipeline: Pipeline_State_Handle, update_func: (*Particle_System, float), owning_entity: *Entity = null, scene: *Scene = null) -> *Particle_System {
|
create_particle_system :: (pipeline: Pipeline_State_Handle, update_func: (*Particle_System, float), owning_entity: *Entity = null, scene: *Scene = null) -> *Particle_System {
|
||||||
lvl := ifx scene == null then game_state.current_scene else scene;
|
lvl := ifx scene == null then current_scene else scene;
|
||||||
particle_system, locator := find_and_occupy_empty_slot(*scene.particle_systems);
|
particle_system, locator := find_and_occupy_empty_slot(*scene.particle_systems);
|
||||||
particle_system._locator = locator;
|
particle_system._locator = locator;
|
||||||
particle_system.vertex_buffer = create_vertex_buffer(renderer, null, size_of(Particle_Vertex) * MAX_PARTICLES, stride=size_of(Particle_Vertex), mappable=true);
|
particle_system.vertex_buffer = create_vertex_buffer(renderer, null, size_of(Particle_Vertex) * MAX_PARTICLES, stride=size_of(Particle_Vertex), mappable=true);
|
||||||
@@ -60,7 +60,7 @@ spawn_particle :: (system: *Particle_System, position: Vector3, velocity: Vector
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_particle_systems :: (dt: float) {
|
update_particle_systems :: (dt: float) {
|
||||||
for *system: game_state.current_scene.particle_systems {
|
for *system: current_scene.particle_systems {
|
||||||
if system.on_particle_update != null {
|
if system.on_particle_update != null {
|
||||||
system.on_particle_update(system, dt);
|
system.on_particle_update(system, dt);
|
||||||
}
|
}
|
||||||
@@ -71,9 +71,9 @@ update_particle_system :: (system: *Particle_System, dt: float) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
prepare_particle_system_for_rendering :: (system: Particle_System) {
|
prepare_particle_system_for_rendering :: (system: Particle_System) {
|
||||||
up := game_state.camera.up;
|
up := current_scene.camera.up;
|
||||||
right := game_state.camera.right;
|
right := current_scene.camera.right;
|
||||||
forward := game_state.camera.forward;
|
forward := current_scene.camera.forward;
|
||||||
|
|
||||||
rendering_data : [..] Particle_Vertex;
|
rendering_data : [..] Particle_Vertex;
|
||||||
rendering_data.allocator = temp;
|
rendering_data.allocator = temp;
|
||||||
@@ -140,7 +140,7 @@ prepare_particle_system_for_rendering :: (system: Particle_System) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render_particle_systems :: () {
|
render_particle_systems :: () {
|
||||||
for system: game_state.current_scene.particle_systems {
|
for system: current_scene.particle_systems {
|
||||||
prepare_particle_system_for_rendering(system);
|
prepare_particle_system_for_rendering(system);
|
||||||
|
|
||||||
if system.particles.count > 0 {
|
if system.particles.count > 0 {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
#load "particles.jai";
|
#load "particles.jai";
|
||||||
|
|
||||||
#placeholder Entity_Storage;
|
#placeholder Entity_Storage;
|
||||||
|
#placeholder serialize_entity;
|
||||||
|
#placeholder deserialize_entity;
|
||||||
|
|
||||||
MAX_CACHED_PILES :: 8;
|
MAX_CACHED_PILES :: 8;
|
||||||
|
|
||||||
@@ -12,8 +14,6 @@ Scene :: struct {
|
|||||||
|
|
||||||
particle_systems : Bucket_Array(Particle_System, 64);
|
particle_systems : Bucket_Array(Particle_System, 64);
|
||||||
|
|
||||||
bullet_impact_particle_systems : [..] *Particle_System;
|
|
||||||
|
|
||||||
by_type : Entity_Storage;
|
by_type : Entity_Storage;
|
||||||
|
|
||||||
pool : Flat_Pool;
|
pool : Flat_Pool;
|
||||||
@@ -58,7 +58,6 @@ load_scene :: (path: string) -> *Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
save_scene :: (scene: *Scene, path: string) {
|
save_scene :: (scene: *Scene, path: string) {
|
||||||
scene.camera = game_state.camera;
|
|
||||||
builder : String_Builder;
|
builder : String_Builder;
|
||||||
builder.allocator = temp;
|
builder.allocator = temp;
|
||||||
|
|
||||||
@@ -99,7 +98,6 @@ create_scene :: (name: string, max_entities: s64 = 256) -> *Scene {
|
|||||||
// Assign allocator to everything that needs allocations
|
// Assign allocator to everything that needs allocations
|
||||||
scene.entities.allocator = scene.allocator;
|
scene.entities.allocator = scene.allocator;
|
||||||
scene.particle_systems.allocator = scene.allocator;
|
scene.particle_systems.allocator = scene.allocator;
|
||||||
scene.bullet_impact_particle_systems.allocator = scene.allocator;
|
|
||||||
|
|
||||||
array_reserve(*scene.entities, max_entities);
|
array_reserve(*scene.entities, max_entities);
|
||||||
|
|
||||||
@@ -111,12 +109,6 @@ create_scene :: (name: string, max_entities: s64 = 256) -> *Scene {
|
|||||||
dir_light_data.direction = scene.directional_light.direction;
|
dir_light_data.direction = scene.directional_light.direction;
|
||||||
upload_data_to_buffer(renderer, directional_light_buffer, *dir_light_data, size_of(Directional_Light_Buffer_Data));
|
upload_data_to_buffer(renderer, directional_light_buffer, *dir_light_data, size_of(Directional_Light_Buffer_Data));
|
||||||
|
|
||||||
array_resize(*scene.bullet_impact_particle_systems, 32);
|
|
||||||
|
|
||||||
for 0..31 {
|
|
||||||
scene.bullet_impact_particle_systems[it] = create_particle_system(particle_pipeline, on_update_bullet_hit_particles, null, scene);
|
|
||||||
}
|
|
||||||
|
|
||||||
return scene;
|
return scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ Editor :: struct {
|
|||||||
menu_position: Vector2;
|
menu_position: Vector2;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor : Editor;
|
|
||||||
|
|
||||||
update_transform_gizmo :: (ray: Ray, mouse_position: Vector2) -> bool {
|
update_transform_gizmo :: (ray: Ray, mouse_position: Vector2) -> bool {
|
||||||
return false;
|
return false;
|
||||||
// selected_entity := engine.editor.selected_entity;
|
// selected_entity := engine.editor.selected_entity;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ pick_scene_view_at :: (coordinates: Vector2) {
|
|||||||
hit_entity : *Entity;
|
hit_entity : *Entity;
|
||||||
closest : float = 100000000;
|
closest : float = 100000000;
|
||||||
|
|
||||||
for game_state.current_scene.entities {
|
for current_scene.entities {
|
||||||
if !(it.flags & .RENDERABLE) continue;
|
if !(it.flags & .RENDERABLE) continue;
|
||||||
//if it.flags & Entity_Flags.DELETED || !it.selectable || it.parent != null continue;
|
//if it.flags & Entity_Flags.DELETED || !it.selectable || it.parent != null continue;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ editor_ui :: () {
|
|||||||
//if ui_button_with_texture(editor.icons.play) {
|
//if ui_button_with_texture(editor.icons.play) {
|
||||||
// play_current_editor_scene();
|
// play_current_editor_scene();
|
||||||
//}
|
//}
|
||||||
ui_label(tprint("Editing '%'", game_state.current_scene.name), .{1,1,1,1});
|
ui_label(tprint("Editing '%'", current_scene.name), .{1,1,1,1});
|
||||||
//}
|
//}
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ editor_ui :: () {
|
|||||||
ui_set_next_size_x(.PCT, 1.0);
|
ui_set_next_size_x(.PCT, 1.0);
|
||||||
ui_tab_title_bar("ENTITIES");
|
ui_tab_title_bar("ENTITIES");
|
||||||
|
|
||||||
for game_state.current_scene.entities {
|
for current_scene.entities {
|
||||||
ui_set_next_padding(20);
|
ui_set_next_padding(20);
|
||||||
clicked := false;
|
clicked := false;
|
||||||
if it.name.count == 0 {
|
if it.name.count == 0 {
|
||||||
@@ -124,7 +124,7 @@ editor_ui :: () {
|
|||||||
ui_set_next_size_x(.PCT, 1.0);
|
ui_set_next_size_x(.PCT, 1.0);
|
||||||
ui_set_next_size_y(.PCT, 0.9);
|
ui_set_next_size_y(.PCT, 0.9);
|
||||||
|
|
||||||
state := ui_interactable_texture(get_texture_from_pass("FXAA"));
|
state := ui_interactable_texture(get_texture_from_pass("UI Blend Pass"));
|
||||||
if state.left_mouse_down {
|
if state.left_mouse_down {
|
||||||
//pick_scene_view_at(.{state.normalized_local_mouse_coordinates.x, 1.0 - state.normalized_local_mouse_coordinates.y});
|
//pick_scene_view_at(.{state.normalized_local_mouse_coordinates.x, 1.0 - state.normalized_local_mouse_coordinates.y});
|
||||||
|
|
||||||
@@ -206,7 +206,7 @@ base_editor_update :: () {
|
|||||||
camera := *editor.camera;
|
camera := *editor.camera;
|
||||||
|
|
||||||
if key_pressed(.CTRL) && key_down(.S) {
|
if key_pressed(.CTRL) && key_down(.S) {
|
||||||
save_scene(game_state.current_scene, "../assets/scenes/");
|
save_scene(current_scene, "../assets/scenes/");
|
||||||
//show_message("Saved scene");
|
//show_message("Saved scene");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ base_editor_update :: () {
|
|||||||
// editor_undo();
|
// editor_undo();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if game_state.mode == .EDITING {
|
if mode == .EDITING {
|
||||||
if key_pressed(.MOUSE_RIGHT) {
|
if key_pressed(.MOUSE_RIGHT) {
|
||||||
set_show_cursor(false);
|
set_show_cursor(false);
|
||||||
// Update camera
|
// Update camera
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ build :: (main_path: string, game_name: string, working_dir: string = #filepath)
|
|||||||
|
|
||||||
opts.output_type = .EXECUTABLE;
|
opts.output_type = .EXECUTABLE;
|
||||||
opts.output_executable_name = game_name;
|
opts.output_executable_name = game_name;
|
||||||
opts.output_path = "bin/";
|
opts.output_path = "../../bin/";
|
||||||
|
|
||||||
new_path: [..] string;
|
new_path: [..] string;
|
||||||
array_add(*new_path, ..opts.import_path);
|
array_add(*new_path, ..opts.import_path);
|
||||||
@@ -30,6 +30,7 @@ build :: (main_path: string, game_name: string, working_dir: string = #filepath)
|
|||||||
|
|
||||||
set_build_options(opts, w);
|
set_build_options(opts, w);
|
||||||
add_build_string(tprint("GAME_NAME :: \"%\";", game_name), w);
|
add_build_string(tprint("GAME_NAME :: \"%\";", game_name), w);
|
||||||
|
add_build_string("#import \"Bucket_Array\";", w);
|
||||||
add_build_file(main_path, w);
|
add_build_file(main_path, w);
|
||||||
|
|
||||||
message_loop();
|
message_loop();
|
||||||
@@ -164,7 +165,6 @@ generate_serialize_procedure_for_entity :: (code_struct: *Code_Struct) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
note_struct :: (code_struct: *Code_Struct) {
|
note_struct :: (code_struct: *Code_Struct) {
|
||||||
print("Type: %\n", code_struct.defined_type.name);
|
|
||||||
if is_subclass_of(code_struct.defined_type, "Entity") {
|
if is_subclass_of(code_struct.defined_type, "Entity") {
|
||||||
name := code_struct.defined_type.name;
|
name := code_struct.defined_type.name;
|
||||||
|
|
||||||
@@ -260,7 +260,7 @@ generate_code :: (w: Workspace) {
|
|||||||
builder: String_Builder;
|
builder: String_Builder;
|
||||||
|
|
||||||
for entity_type_names {
|
for entity_type_names {
|
||||||
print_to_builder(*builder, "new_%1 :: (scene: *Scene = null) -> *%2 { _scene := scene;\nif _scene == null { \n_scene = game_state.current_scene; }\np, locator := find_and_occupy_empty_slot(*_scene.by_type._%2); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }\n", to_lower_copy_new(it,, allocator=temp), it);
|
print_to_builder(*builder, "new_%1 :: (scene: *Scene = null) -> *%2 { _scene := scene;\nif _scene == null { \n_scene = current_scene; }\np, locator := find_and_occupy_empty_slot(*_scene.by_type._%2); p._locator = locator; register_entity(_scene, p); p.transform = create_identity_transform(); init_entity(p); return p; }\n", to_lower_copy_new(it,, allocator=temp), it);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_build_string(builder_to_string(*builder), w);
|
add_build_string(builder_to_string(*builder), w);
|
||||||
@@ -308,13 +308,13 @@ serialize_entity :: (e: *Entity, path: string) {
|
|||||||
%1
|
%1
|
||||||
}
|
}
|
||||||
|
|
||||||
write_entire_file(tprint("%%/%%.ent", path, e.id), builder_to_string(*builder));
|
File.write_entire_file(tprint("%%/%%.ent", path, e.id), builder_to_string(*builder));
|
||||||
}
|
}
|
||||||
DONE
|
DONE
|
||||||
|
|
||||||
DESERIALIZE_ENTITY :: #string DONE
|
DESERIALIZE_ENTITY :: #string DONE
|
||||||
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
deserialize_entity :: (scene: *Scene, path: string) -> *Entity {
|
||||||
content := read_entire_file(path);
|
content := File.read_entire_file(path);
|
||||||
if content.count == 0 return null;
|
if content.count == 0 return null;
|
||||||
|
|
||||||
lines := split(content, "\n");
|
lines := split(content, "\n");
|
||||||
|
|||||||
40
module.jai
40
module.jai
@@ -9,48 +9,71 @@ DEBUG :: true;
|
|||||||
editor: Editor;
|
editor: Editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Engine_Mode :: enum {
|
||||||
|
PLAYING;
|
||||||
|
EDITING;
|
||||||
|
}
|
||||||
|
mode: Engine_Mode;
|
||||||
|
|
||||||
window: *Window;
|
window: *Window;
|
||||||
renderer: *Renderer;
|
renderer: *Renderer;
|
||||||
input : Input_State;
|
input : Input_State;
|
||||||
|
current_scene: *Scene;
|
||||||
|
|
||||||
|
camera_buffer : Buffer_Handle;
|
||||||
|
screen_data_buffer : Buffer_Handle;
|
||||||
|
directional_light_buffer : Buffer_Handle;
|
||||||
|
|
||||||
time: float;
|
time: float;
|
||||||
dt: float;
|
dt: float;
|
||||||
quit: bool;
|
quit: bool;
|
||||||
|
frame_index : u64 = 0;
|
||||||
|
|
||||||
coven_init :: (window_title: string, window_width: u32, window_height: u32, fullscreen: bool) {
|
coven_init :: (window_title: string, window_width: u32, window_height: u32, fullscreen: bool) {
|
||||||
window = create_window(GAME_NAME, 1400, xx (1400.0*aspect), true);
|
window = create_window(window_title, window_width, window_height, fullscreen);
|
||||||
renderer = create_renderer(window);
|
renderer = create_renderer(window);
|
||||||
renderer.vsync = true;
|
renderer.vsync = true;
|
||||||
|
|
||||||
init_input();
|
init_input();
|
||||||
init_audio_system();
|
init_audio_system();
|
||||||
init_console();
|
init_console();
|
||||||
|
|
||||||
|
ui_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
coven_run :: (update_func: (float)) {
|
coven_run :: (game_update_proc: (float)) {
|
||||||
time = xx seconds_since_init();
|
time = xx seconds_since_init();
|
||||||
|
|
||||||
while !quit {
|
while !quit {
|
||||||
//reset_temporary_storage();
|
//reset_temporary_storage();
|
||||||
|
|
||||||
frame_index += 1;
|
frame_index += 1;
|
||||||
|
|
||||||
update_input();
|
update_input();
|
||||||
|
|
||||||
quit = key_down(.ESCAPE);
|
|
||||||
|
// @Incomplete
|
||||||
|
if key_pressed(.SHIFT) && key_down(.ESCAPE) {
|
||||||
|
quit = true;
|
||||||
|
}
|
||||||
|
|
||||||
now : float = xx seconds_since_init();
|
now : float = xx seconds_since_init();
|
||||||
dt = now - time;
|
dt = now - time;
|
||||||
time = now;
|
time = now;
|
||||||
|
|
||||||
|
update_fps_counter(dt);
|
||||||
|
|
||||||
update_console();
|
update_console();
|
||||||
|
|
||||||
update_func(min(0.4, dt));
|
ui_begin();
|
||||||
|
|
||||||
|
game_update_proc(min(0.4, dt));
|
||||||
|
|
||||||
|
ui_end();
|
||||||
|
|
||||||
update_audio(dt);
|
update_audio(dt);
|
||||||
|
|
||||||
render();
|
render();
|
||||||
|
|
||||||
//SDL_Delay(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
@@ -75,6 +98,9 @@ coven_run :: (update_func: (float)) {
|
|||||||
#load "core/camera.jai";
|
#load "core/camera.jai";
|
||||||
#load "core/console.jai";
|
#load "core/console.jai";
|
||||||
#load "audio/audio.jai";
|
#load "audio/audio.jai";
|
||||||
|
#load "core/fps.jai";
|
||||||
|
|
||||||
|
#scope_export
|
||||||
|
|
||||||
#import "Bucket_Array";
|
#import "Bucket_Array";
|
||||||
#import "Basic";
|
#import "Basic";
|
||||||
@@ -82,6 +108,6 @@ coven_run :: (update_func: (float)) {
|
|||||||
#import "System";
|
#import "System";
|
||||||
#import "Flat_Pool";
|
#import "Flat_Pool";
|
||||||
#import "Hash_Table";
|
#import "Hash_Table";
|
||||||
#import "File";
|
File :: #import "File";
|
||||||
#import "File_Watcher";
|
#import "File_Watcher";
|
||||||
#import "File_Utilities";
|
#import "File_Utilities";
|
||||||
@@ -178,8 +178,8 @@ Player_Update_Data :: struct {
|
|||||||
pitch: float;
|
pitch: float;
|
||||||
}
|
}
|
||||||
|
|
||||||
message_mutex: Mutex;
|
message_mutex: Thread.Mutex;
|
||||||
update_mutex: Mutex;
|
update_mutex: Thread.Mutex;
|
||||||
|
|
||||||
net_init :: () {
|
net_init :: () {
|
||||||
net_log("Init\n");
|
net_log("Init\n");
|
||||||
@@ -190,17 +190,17 @@ net_init :: () {
|
|||||||
net_log("Couldn't initialize Lyn\n");
|
net_log("Couldn't initialize Lyn\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if thread_init(*thread, networking_thread_proc) {
|
if Thread.thread_init(*thread, networking_thread_proc) {
|
||||||
thread_start(*thread);;
|
Thread.thread_start(*thread);;
|
||||||
}
|
}
|
||||||
|
|
||||||
if thread_init(*message_thread, net_check_for_messages) {
|
if Thread.thread_init(*message_thread, net_check_for_messages) {
|
||||||
thread_start(*message_thread);;
|
Thread.thread_start(*message_thread);;
|
||||||
}
|
}
|
||||||
|
|
||||||
init(*update_mutex);
|
Thread.init(*update_mutex);
|
||||||
init(*message_mutex);
|
Thread.init(*message_mutex);
|
||||||
init(*internal_message_mutex);
|
Thread.init(*internal_message_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
net_get_state :: () -> Net_Networking_State {
|
net_get_state :: () -> Net_Networking_State {
|
||||||
@@ -275,7 +275,7 @@ net_log_error :: inline (message: string, args: .. Any) {
|
|||||||
log_error(tprint("NET: %", message), args);
|
log_error(tprint("NET: %", message), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
networking_thread_proc :: (thread: *Thread) -> s64 {
|
networking_thread_proc :: (thread: *Thread.Thread) -> s64 {
|
||||||
while true {
|
while true {
|
||||||
update_networking();
|
update_networking();
|
||||||
sleep_milliseconds(10);
|
sleep_milliseconds(10);
|
||||||
@@ -283,12 +283,12 @@ networking_thread_proc :: (thread: *Thread) -> s64 {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
net_check_for_messages :: (thread: *Thread) -> s64 {
|
net_check_for_messages :: (thread: *Thread.Thread) -> s64 {
|
||||||
while true {
|
while true {
|
||||||
success, message, address := net_read_message(net_data.socket);
|
success, message, address := net_read_message(net_data.socket);
|
||||||
if success {
|
if success {
|
||||||
lock(*internal_message_mutex);
|
Thread.lock(*internal_message_mutex);
|
||||||
defer unlock(*internal_message_mutex);
|
defer Thread.unlock(*internal_message_mutex);
|
||||||
|
|
||||||
pending: Internal_Pending_Message;
|
pending: Internal_Pending_Message;
|
||||||
pending.message = message;
|
pending.message = message;
|
||||||
@@ -460,29 +460,29 @@ on_message_received :: (message: Net_Message, address: Net_Address) {
|
|||||||
}
|
}
|
||||||
case .START_GAME; {
|
case .START_GAME; {
|
||||||
{
|
{
|
||||||
lock(*update_mutex);
|
Thread.lock(*update_mutex);
|
||||||
defer unlock(*update_mutex);
|
defer Thread.unlock(*update_mutex);
|
||||||
|
|
||||||
array_add(*pending_net_messages, message);
|
array_add(*pending_net_messages, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .SPAWN_ENTITY; {
|
case .SPAWN_ENTITY; {
|
||||||
{
|
{
|
||||||
lock(*update_mutex);
|
Thread.lock(*update_mutex);
|
||||||
defer unlock(*update_mutex);
|
defer Thread.unlock(*update_mutex);
|
||||||
|
|
||||||
array_add(*pending_net_messages, message);
|
array_add(*pending_net_messages, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case .TRANSFORM_UPDATE; {
|
case .TRANSFORM_UPDATE; {
|
||||||
lock(*update_mutex);
|
Thread.lock(*update_mutex);
|
||||||
defer unlock(*update_mutex);
|
defer Thread.unlock(*update_mutex);
|
||||||
|
|
||||||
array_add(*pending_net_messages, message);
|
array_add(*pending_net_messages, message);
|
||||||
}
|
}
|
||||||
case; {
|
case; {
|
||||||
lock(*update_mutex);
|
Thread.lock(*update_mutex);
|
||||||
defer unlock(*update_mutex);
|
defer Thread.unlock(*update_mutex);
|
||||||
|
|
||||||
array_add(*pending_net_messages, message);
|
array_add(*pending_net_messages, message);
|
||||||
}
|
}
|
||||||
@@ -493,8 +493,8 @@ update_networking :: () {
|
|||||||
reset_temporary_storage();
|
reset_temporary_storage();
|
||||||
|
|
||||||
{
|
{
|
||||||
lock(*message_mutex);
|
Thread.lock(*message_mutex);
|
||||||
defer unlock(*message_mutex);
|
defer Thread.unlock(*message_mutex);
|
||||||
|
|
||||||
for * messages_to_send {
|
for * messages_to_send {
|
||||||
if net_is_client() {
|
if net_is_client() {
|
||||||
@@ -507,8 +507,8 @@ update_networking :: () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
lock(*internal_message_mutex);
|
Thread.lock(*internal_message_mutex);
|
||||||
defer unlock(*internal_message_mutex);
|
defer Thread.unlock(*internal_message_mutex);
|
||||||
|
|
||||||
for internal_pending_messages {
|
for internal_pending_messages {
|
||||||
on_message_received(it.message, it.address);
|
on_message_received(it.message, it.address);
|
||||||
@@ -585,12 +585,12 @@ Internal_Pending_Message :: struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal_pending_messages : [..] Internal_Pending_Message;
|
internal_pending_messages : [..] Internal_Pending_Message;
|
||||||
internal_message_mutex: Mutex;
|
internal_message_mutex: Thread.Mutex;
|
||||||
|
|
||||||
thread : Thread;
|
thread : Thread.Thread;
|
||||||
message_thread : Thread;
|
message_thread : Thread.Thread;
|
||||||
state : Net_Networking_State;
|
state : Net_Networking_State;
|
||||||
|
|
||||||
#import "Thread";
|
Thread :: #import "Thread";
|
||||||
#import "Basic";
|
#import "Basic";
|
||||||
Socket :: #import "Socket";
|
Socket :: #import "Socket";
|
||||||
Reference in New Issue
Block a user