Skip to content

Commit

Permalink
Unit production (#563)
Browse files Browse the repository at this point in the history
* asset: Initial product map type

* asset: Add initial product map test

* game: Add dummy products map

* scene: Load global product map

* scene: Add production component

* asset: Disallow empty product sets

* scene: Initialize product queues

* scene: Store pointer to product asset

* scene: Fix retrieving product map after release

* scene: Clear product queues when hotloading map

* scene: Cleanup scene product header

* game: Production hud skeleton

* ui: Add groups shape

* game: Add hud production header

* game: Add background to production hud

* game: Move groups to right size of hud

* game: Skeleton of prod queue drawing

* game: Add name to products

* geo: Allow geo_nav_blocker_closest with from being blocked

* ui: Reduce font border radius

Better for high detail glyphs

* ui: Tweak scroll view handle

* game: Add ranger icons

* core: Fix typo

* game: Add icons to products

* game: Add product cost label

* game: Show hover on prod queue bg

* game: Refactor queue icon drawing

* game: Add feedback to queue btn activation

* game: Add queue count ui

* scene: Support product enqueuing

* scene: Support max queue size

* scene: Support prod queue canceling

* scene: Support product cancel all

* scene: Support product bulk enqueue

* gap: Add util for char representation of a key

* game: Basic product queue hotkeys

* gap: Support forward declaring GapKey enum

* gap: Use upper-case char for key chars

* input: Add api to query action primary key

* game: Add product queue hotkey ui

* ui: Minor optimization to cmd size

* ui: Cmd size optimization

* ui: Support right mouse interacts

* game: Support cancelling production with right mouse

* game: Product hotkey ui tweaks

* scene: Initial product queue processing logic

* game: Tweak product costs

* game: Visualize product queue state

* game: Show product queue progress

* scene: Add product queue cooldown

* scene: Add product ready sound

* game: Tweak product costs

* scene: Add unit spawn logic

* scene: Add unit spawn offset

* scene: Configurable soundReady gain

* game: Tweak product costs

* assets: Add unit-ready sound

* scene: Support nav request components

* scene: Support product rally point

* scene: Support updating rally points

* game: Tweak queue max sizes

* game: Tweak queue ui

* game: Tweak queue hud

* game: Tweak product queue tooltip

* scene: Spawn units on nav grid

* scene: Minor product queue restructure

* scene: Future prod queue refactor

* scene: Initial support for multi-unit spawns

* scene: Disable terrain snapping on unit spawns

* asset: Configurable product unit count

* game: Fix inconsistent ui ids after product ui drawing

* game: Move product queue tooltip to func

* game: Minor cleanup in hud code

* game: Tweaked prod cost ui

* game: Add count to product queue hud

* asset: Reduce size of AssetProduct struct

* asset: Fix typo

* asset: Restructure product map

* game: Increase vision radius of barracks
  • Loading branch information
BastianBlokland authored Aug 3, 2023
1 parent f1e7297 commit 9990045
Show file tree
Hide file tree
Showing 50 changed files with 1,865 additions and 99 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*.pfb linguist-language=JSON
*.pme linguist-language=JSON
*.prefs linguist-language=JSON
*.pro linguist-language=JSON
*.ptx linguist-language=JSON
*.vfx linguist-language=JSON
*.wea linguist-language=JSON
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"*.pfb": "json",
"*.pme": "json",
"*.prefs": "json",
"*.pro": "json",
"*.ptx": "json",
"*.vfx": "json",
"*.wea": "json",
Expand All @@ -45,6 +46,7 @@
{ "fileMatch": [ "*.lvl" ], "url": "./assets/schemas/lvl.schema.json" },
{ "fileMatch": [ "*.pfb" ], "url": "./assets/schemas/pfb.schema.json" },
{ "fileMatch": [ "*.pme" ], "url": "./assets/schemas/pme.schema.json" },
{ "fileMatch": [ "*.pro" ], "url": "./assets/schemas/pro.schema.json" },
{ "fileMatch": [ "*.ptx" ], "url": "./assets/schemas/ptx.schema.json" },
{ "fileMatch": [ "*.vfx" ], "url": "./assets/schemas/vfx.schema.json" },
{ "fileMatch": [ "*.wea" ], "url": "./assets/schemas/wea.schema.json" }
Expand Down
2 changes: 2 additions & 0 deletions apps/game/src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "scene_camera.h"
#include "scene_level.h"
#include "scene_prefab.h"
#include "scene_product.h"
#include "scene_register.h"
#include "scene_sound.h"
#include "scene_terrain.h"
Expand Down Expand Up @@ -613,6 +614,7 @@ void app_ecs_init(EcsWorld* world, const CliInvocation* invoc) {
scene_level_load(world, asset_lookup(world, assets, g_appLevel));
scene_prefab_init(world, string_lit("global/game-prefabs.pfb"));
scene_weapon_init(world, string_lit("global/game-weapons.wea"));
scene_product_init(world, string_lit("global/game-products.pro"));
scene_terrain_init(
world,
string_lit("graphics/scene/terrain.gra"),
Expand Down
17 changes: 17 additions & 0 deletions apps/game/src/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ecs_world.h"
#include "scene_brain.h"
#include "scene_faction.h"
#include "scene_product.h"
#include "scene_selection.h"
#include "scene_taunt.h"
#include "scene_transform.h"
Expand Down Expand Up @@ -96,6 +97,11 @@ ecs_view_define(BrainView) {
ecs_access_maybe_write(SceneTauntComp);
}

ecs_view_define(ProdView) {
ecs_access_read(SceneFactionComp);
ecs_access_write(SceneProductionComp);
}

ecs_view_define(TransformView) { ecs_access_read(SceneTransformComp); }

static void cmd_group_add_internal(CmdGroup* group, const EcsEntityId object) {
Expand Down Expand Up @@ -165,6 +171,15 @@ static void cmd_execute_move(EcsWorld* world, const CmdMove* cmdMove) {
if (taunt) {
scene_taunt_request(taunt, SceneTauntType_Confirm);
}
return;
}

EcsIterator* prodItr = ecs_view_maybe_at(ecs_world_view_t(world, ProdView), cmdMove->object);
if (prodItr && cmd_is_player_owned(prodItr)) {
SceneProductionComp* prod = ecs_view_write_t(prodItr, SceneProductionComp);
prod->rallySpace = SceneProductRallySpace_World;
prod->rallyPos = cmdMove->position;
return;
}
}

Expand Down Expand Up @@ -264,12 +279,14 @@ ecs_module_init(game_cmd_module) {

ecs_register_view(GlobalUpdateView);
ecs_register_view(BrainView);
ecs_register_view(ProdView);
ecs_register_view(TransformView);

ecs_register_system(
CmdControllerUpdateSys,
ecs_view_id(GlobalUpdateView),
ecs_view_id(BrainView),
ecs_view_id(ProdView),
ecs_view_id(TransformView));

ecs_order(CmdControllerUpdateSys, AppOrder_CommandUpdate);
Expand Down
Loading

0 comments on commit 9990045

Please sign in to comment.