103 - Editor Placement Previews

January 24, 2021

I got back into routine this week after spending the end of last week and the first couple days of this week at my sister's house.

No big milestone this week, just steady progress on the important fronts.

Crafting Improvements

I'm making strides in the crafting system. All of the progress is still on the data structures, functions, unit and integration tests side of things so there isn't anything visual for me to share yet.

My approach to adding a new feature such as the crafting system is to first create an integration test for it where I simulate one or more players engaging with the gameplay.

I then bounce between adding an assertion to the integration test to implementing and unit testing all of the required new functionality to power that line.

This approach has been instrumental for me in a number of ways.

One example is that it gives me clear direction on exactly what needs to be built to support real game play.

Without a gameplay oriented integration test it can be difficult to know what functionality to focus on now as opposed to functionality that I can circle back to later.

For example, there are multiple unimplemented match expression branches within the function that checks to see if you meet the criteria for a recipe because I know that none of the things that you are currently able to craft touch those code paths.

When those code paths get hit by real crafting recipes, I will implement them.

Here's a snippet of the integration test for crafting a bow thus far:

// ... snippet ...

 #[test]
fn bowcraft_craft_bow() -> TestResult {
    let game_thread = GameThread::new_with_game_server_config_modifier(
        client_comps_source_new_player_at_pos(PLAYER_ID_1, PLAYER_POS),
        |config| {
            config.initial_entities = Some(InitialEntitiesConfig::new(initial_spawns()));
        },
    );
    let player = game_thread.connect_player_tick_until_in_world(PLAYER_ID_1)?;

    make_sharp_stone(&player, &game_thread)?;
    make_twisted_sinew(&player, &game_thread)?;
    make_sticky(&player, &game_thread)?;

	todo!();

    game_thread.shutdown()
}

// ... snippet ...

 fn make_sticky(player: &ConnectedPlayer, game_thread: &GameThread) -> TestResult {
    make_clay_bowl(player, game_thread)?;
    harvest_acacia_tree_sap(player, game_thread)?;

    player.pickup_entity(EntLookup::DisplayNameOne("Clay"));
    player.tick_until_has_item_with_quantity(ItemId::Clay, 1, &game_thread, 10);
    make_wet_clay(player, game_thread)?;

    let sticky_request = CraftingRequest::new(
        CraftingAction::Mix,
        &[ItemId::BowlOfAcaciaTreeSap, ItemId::WetClay],
    );
    player.send_crafting_request_wait_for_ack(sticky_request)?;

    player.tick_until_has_item_with_quantity(ItemId::BowlOfSticky, 1, &game_thread, 10);
    player.assert_has_item_with_id_and_quantity(ItemId::BowlOfAcaciaTreeSap, 0);

    Ok(())
}   

// ... snippet ...

This week I added support for stations. An entity can have a StationComponent that allows it to be used as a station during crafting.

For example, when you want to harden a clay bowl you need a station with a Fire {hotness: Tier} component with a hotness of at least Tier::Two.

One way to satisfy the requirement is by using a Fire Pit entity as a station, but any hot enough entity will do just fine.

Editor Improvements

Last week I simplified the editor's game pane by culling it down to two main modes, Play Mode and Edit Mode.

Within the Edit Mode there are the sub-modes of Object and Terrain, each geared to different editing activities.

While in GamePane -> Edit Mode -> Object Mode you are able to edit and place scenery and entities within the game world.

Towards the end of the week I added the ability to see a preview of what you are placing.

Renderables that the editor injects into the game's render descriptor can not be textured currently, so the previews are rendered as all red for now.

Rendering previews of scenery and entities that will be placed. I'll at some point want to fix the preview to take any tile-grid snapping into account so that you can see exactly where it will be placed.

Networking Improvements

While I was at my sister's I took a break from my usual work and worked on different operations related tasks.

The last of these was making the rate that client updates were sent out more consistent, which ended up running over into a couple of days after I came back from my sister's house.

Previously the amount of time between updates could vary based on how long a game tick took to run.

Before this change, if the game ticks were 600ms each and one tick took 5ms to complete then the next tick took 305ms to complete client updates would be sent 900ms apart.

After this change all updates would be sent 600ms apart, regardless of how long the tick took to run.

The advantage of this change is that it will make latency compensation easier on the client side.

As long as the variance in your ping isn't above some very forgiving threshold, the client can dynamically adjust different interpolation speeds so that you don't notice variations in latency.

I have not started on latency compensation on the client side. I will need to implement that at some point.

Other Notes / Progress

  • Bought a new laptop that will arrive in a couple of weeks. Going to use my current laptop for consulting work and my new laptop for working on Akigi. This was mainly motivated by the fact that I need to send my current laptop in to get the keyboard repaired and I don't want to go five days without a laptop. But, I don't plan to return the new one since I'm very interested in exploring how having multiple machines for different purposes can help to boost my focus. When I some day end consulting I may dedicate the older machine to art or sound or something else.

Next Journal Entry

By the next journal entry I plan to have finished implementing the ability to craft a bow on the code and data side of things.

From there I will need to add in the user interface for crafting as well as new models for all of the new resources and raw materials that I have added, which I will start working on but will not be finished by the next journal entry.

I will also continue making progress on the editor. I plan to add the ability to move and delete scenery.

I also plan to fix an issue with terrain editing where painting terrain is not working at the edges of terrain chunks.


I will be back next week. Goodbye for now.

- CFN