feat: add cold-season scarcity that halves yields and pauses regrowth
This commit is contained in:
@@ -68,6 +68,10 @@ var _population_view := SimulationPopulationView.new()
|
||||
var speed_index := 2
|
||||
const SPEED_LEVELS := [0.25, 0.5, 1.0, 2.0, 4.0, 10.0]
|
||||
const KNOWLEDGE_COMMUNICATION_RADIUS := 2.5
|
||||
const SEASON_DAYS := 4
|
||||
const COLD_DAYS := 3
|
||||
const SEASON_COLD := &"cold"
|
||||
const SEASON_WARM := &"warm"
|
||||
signal speed_changed(multiplier: float)
|
||||
|
||||
const NPC_NAMES := ["Amina", "Tarik", "Jasmin", "Elma", "Mirza", "Lejla"]
|
||||
@@ -337,7 +341,9 @@ func _complete_resource_gather(npc: SimNPC, completed_task: StringName) -> void:
|
||||
release_npc_reservation(npc.id)
|
||||
return
|
||||
|
||||
var extracted := resource_state.extract()
|
||||
var extracted := resource_state.extract(
|
||||
resource_state.get_yield_per_action() * _gather_yield_multiplier()
|
||||
)
|
||||
if extracted > 0.0:
|
||||
var resource_id := resource_state.get_resource_id()
|
||||
npc.add_inventory(resource_id, extracted)
|
||||
@@ -1019,7 +1025,9 @@ func harvest_resource_node(node: ResourceNode) -> float:
|
||||
var resource_state := get_resource_state(node.node_id)
|
||||
if resource_state == null or not resource_state.can_player_use_resource():
|
||||
return 0.0
|
||||
var extracted := resource_state.extract(resource_state.get_yield_per_action())
|
||||
var extracted := resource_state.extract(
|
||||
resource_state.get_yield_per_action() * _gather_yield_multiplier()
|
||||
)
|
||||
if extracted <= 0.0:
|
||||
return 0.0
|
||||
var resource_id := resource_state.get_resource_id()
|
||||
@@ -1066,7 +1074,23 @@ func advance_player_needs() -> void:
|
||||
player_system.advance_needs(village.food_modifier)
|
||||
|
||||
|
||||
func get_season() -> StringName:
|
||||
var ticks_per_day := maxi(get_knowledge_review_interval(), 1)
|
||||
var season_day := int(clock.elapsed_ticks / ticks_per_day)
|
||||
return SEASON_COLD if season_day % SEASON_DAYS >= COLD_DAYS else SEASON_WARM
|
||||
|
||||
|
||||
func is_cold_season() -> bool:
|
||||
return get_season() == SEASON_COLD
|
||||
|
||||
|
||||
func _gather_yield_multiplier() -> float:
|
||||
return 0.5 if is_cold_season() else 1.0
|
||||
|
||||
|
||||
func _advance_resource_regrowth() -> void:
|
||||
if is_cold_season():
|
||||
return
|
||||
for resource_id in resource_states:
|
||||
var resource_state := resource_states[resource_id] as ResourceStateRecord
|
||||
resource_state.regrow()
|
||||
|
||||
Reference in New Issue
Block a user