Introduction

The Village Framework is made to randomize data when creating a new day. This page will explain what is generated, how it is stored, and how to call this generation.

It will also explain how we handle the seed generation.

Content of a Day

All the days generated by the village framework are stored in the VillageManager.

Each DayInstance contains a list of information relative to the randomization of that day and the choices made by the player.

When a day is created, it is created with a date, that must be determined by the user, and a weather.

It then has a list of Destination Instances for all available destination on that day.

Each Destination has a list of opportunity slots, corresponding to each spawnpoint associated with that destination.

For each spawnpoint, it can have a villager, and an opportunity. When the user makes a choice in that opportunity, it will be saved on that opportunity slot.

graph LR
  d["`Day 1
  13/08/2026
  Weather : Sunny`"]
  d --> dest1[Destination 1 : Classroom]
  opp1["` Slot 1
  Spawnpoint  : Teacher's Desk
  Villager : Math Teacher
  Opportunity : Math Exam
  Choice Made :  null `"]
  dest1 --> opp1
  opp2["` Slot 2
  Spawnpoint  : Front Row
  Villager : Best Friend
  Opportunity : Offer to Cheat
  Choice Made :  Cheat `"]
  dest1 --> opp2
  d --> dest2[Destination 2 : Cafetaria]
  opp3["` Slot 1
  Spawnpoint  : Buffet
  Villager : Lunch Lady
  Opportunity : Day1 lunch
  Choice Made :  Ask for seconds `"]
  dest2 --> opp3

Generating a new day

Flowchart

flowchart TD
 Generate[Generate a new day] --> isFirstDay{{Is First Day}}
 isFirstDay -- No --> DestUpdate[Update Destination Enabling from previous day choices]
 isFirstDay -- Yes --> create[Create New Day Instance]
 DestUpdate --> create
 create --> weather[Randomize Weather]
 weather --> destination[Assign Visitable Destinations]
 destination --> toPlace{{Have available slot and villager to place?}}
 toPlace -- Yes --> selectSlot[Select Slot witht the least possible villager]
 selectSlot --> selectOpp[Select an opportunity with the highest possible rank for that slot]
 selectOpp --> toPlace
 toPlace -- No --> finish[Day Generation finished]
 
 

To create a new day, you need to call the line :

VillageManager.instance.GenerateNewDay(dateTime)

where dateTime is the DateTime you want the day to be on. This date will also be applied as the currentDateTime for the Village. Then it will execute this list of steps:

  1. Check if its the first time a day is created. If it is not, it will go through the current day instance, and apply the choices made that day to enable or disable Destinations.

    This check is made to delay the impact of choice enabling on destinations to the next day, in order to not block destination in the middle of a day.

  2. Create a new day instance at the new date, and assign that date as the current date.

  3. Select a random weather, based on its weight for the current month.

    The weather selection impact other randomization, and must be made first.

  4. Assign new Destination Instance to all available destinations.

    A destination is available when it is available for the current weather, is enabled, and is contained by the current chapter.

  5. List available Villager and Opportunities

    1. For each destination, list all spawnpoints
    2. For each spawnpoints, list opportunities that are available by checking , for both villager and opportunity :
      1. The current chapter
      2. The day of the week
      3. The month
      4. If the opportunity / villager is enabled
    3. If both are valid, add the villager and opportunity to a list
  6. First select the spawnpoint with the LEAST amount of possible villager,

  7. Then select the opportunity available with the highest type (main story opportunity takes precedent over filler, etc.)

  8. If an opportunity was selected, remove the villager from the list of available villagers, and the slot from the list of available slots.

  9. Repeat steps 6 to 8 until there is either no more villagers to place, or no slot to fill,.

  10. Call OnNewDayGenerated event

  11. Return the day created.

Randomization

When the village is initialized, it will create a VillageSeed.

This class contains a unique identifier, that is applied using its hashcode for randomization. Each time a decision is made using the village seed (like the day generation), a counter increments by 1.

The seed and the counter are saved , so that when we reload, we can go back to that counter.

<aside> 📌

If the counter goes up to the max int value, it goes back to 0.

</aside>