home about the studio about the team luxe game engine

You've successfully subscribed to Studio Any Percent!

Subscribe to Studio Any Percent

Stay up to date! Get all the latest & greatest posts delivered straight to your inbox

mossfield origins - dev #5

population + more stock



Even more stock nonsense

Last time I mentioned some easy tasks I wanted to do, let's see how it went:

- ✔️ functional producer/consumer buildings set up
- ✔️'Residence' system, so that new people will arrive
- ✔️The stock pile building
- ✔️ Generating tasks to move stock from producers to stock piles

Aside from those, I also added some other things we'll see below. You'll notice in videos now the residents randomly shuffle around their spot, this is a placeholder for proper down time, but frees them up for other tasks. The hud also got cleaned up, the spacing is now based on the number of units displayed, and there's a bit of separation between concerns (resources vs residents). The number of residents is now displayed too.

Restocking from Producers

To move stock to the stockpile, the Producer modifier (which is attached to the entities producing resources), currently has a simple 'offload amount' value.

When a producer generates a resource, it checks if there's no pending task for this already, and that there's a stockpile in the world. if there is, it generates a StockPile task. The task wants a source `Stock` entity, i.e the pile of resources to pull from, and the StockPile system takes care of the rest like finding a destination.

Resource producers + stock piles

This video is a bit longer, but shows a wood resource + a stone resource producer being built, alongside a stock pile. You can see how the residents migrate the resources over onto the stock pile, and then use that stock pile to build from.

Nothing is balanced yet, but it's nice to be able to play and have to build producers before I can progress. Each type (wood + stone) also has 2 upgrade tiers, with more or faster production (they're meant to produce waste and require power, but that's coming later).

Resource Returns

One thing I wanted to do was return resources if you cancel a construction, as well as if you destroy a complete building. Since this game is all about upgradeable buildings, that means when you destroy a higher tier upgrade, you get all the resources used to build it along the way.

You can see that in action here, upon deconstruct it simply drops some Stock instances on the floor.

Construction Cancelling
This is also true for construction, except construction has a bit more nuance. For example, they might be on the way to fetch the resources, they don't even have them in hand yet. They might have them in hand but haven't delivered them. They might have delivered them and construction is underway.

This video shows how it works in each case, nothing surprising.

Loose resources

In both cases, dropping a resource because the task for it was cancelled, or dropping resources in the world when a building is cancelled, has some interesting side effects mechanically. I like how constructing a new building in place of the old building may not need to fetch any resources cos they're right there. And I like how there'll be resources laying around reflecting your choices.

I briefly spoke about a concept in #3, where a task is an entity, and a Fetch modifier is attached to it, and the task moves around the world physically. This "just drop the resource where you are" is a great example of why I like modular entity based workflows when making games. When the task is created, it's just able to exist, able to be cancelled, completed and that's all. When a Fetch or StockPile or other behaviour is added, the meaning of the task changes. For a fetch tasks like for construction it looks like this:

entity [ Task + Fetch + Stock ]

If I wanted to convert the task to a regular stock pile, I could simply remove the Task and Fetch and change the stock type, and that's all, the stock behaves like any other stock source in the world.

entity [ Stock ]

For now, since I like the lifetime of a task entity to be tied the task itself, I instead make a new entity, and the task is destroyed (along with the modifiers attached to it).

One other change now is that loose resources are considered first, when looking for a resource. They'll clean up any loose resources before drawing from a stock pile. The next step is to generate a task to migrate the loose ones to an actual stock pile.

Residence system

You now only start with one resident.

Each residential building now has a Residence modifier attached, which simply keeps track of how many beds it has, and how many residents are assigned there. When a space is available, the residence will request a new resident, one per day. The new resident will arrive at noon the next day.

There's a second part I haven't added yet, when a resident's residence is removed, if you don't give them a place to stay within some time frame (say 8 days), they'll leave.

Here you can see a house built, and after some days, the residence's status is updated, and new residents arrive.

next...

I still want to look at power, finish the residence system so they leave.

Rest and Social
There's another aspect for residents that hasn't been added yet, which is a "rest" and "social" value. This is a bit of personality randomness atm, until I can play with it to see how it feels.

Some activities or foods increase rest, some increase social. If you build someone a home for 1, they'll get better rest at night, but less social. The 2 person house has slightly less rest but a bit more social. This also ties into the resident life times conceptually, where if a resident isn't rested enough  or if they're too lonely, they'll leave.

Food and Water
This is one of the other big pieces. I've already figured out how food works (3 units per day based on factors like rest and activities), but I haven't thought too hard about water will work. The buildings to produce the water + food will be quick, but fitting it into the design is a key task.

Until next time!