mirror of
https://github.com/tonytins/citylimits
synced 2025-06-26 01:44:42 -04:00
Basic AI
- If a power plant is present, the zone animates. Just like the original. - Your budget also goes through the roof This is just a proof-of-concept right now, and will likely crash your machine if you leave it on too long.
This commit is contained in:
parent
5fa863114a
commit
239fa63a0c
9 changed files with 236 additions and 177 deletions
20
scripts/simtactics/has_power.gd
Normal file
20
scripts/simtactics/has_power.gd
Normal file
|
@ -0,0 +1,20 @@
|
|||
extends ConditionLeaf
|
||||
|
||||
export var cost: int = 10000
|
||||
export var income: int = 100
|
||||
export var expense: int = 0
|
||||
|
||||
func tick(actor, blackboard):
|
||||
if SimData.has_power:
|
||||
if SimData.budget >= expense:
|
||||
SimData.budget -= expense
|
||||
SimData.expenses = expense
|
||||
|
||||
if SimData.has_power:
|
||||
var total_income = SimData.res_tax * income
|
||||
SimData.budget += total_income
|
||||
SimData.res_income = total_income
|
||||
|
||||
return SUCCESS
|
||||
|
||||
return FAILURE
|
5
scripts/simtactics/turn_on.gd
Normal file
5
scripts/simtactics/turn_on.gd
Normal file
|
@ -0,0 +1,5 @@
|
|||
extends ConditionLeaf
|
||||
|
||||
func tick(actor, blackboard):
|
||||
SimData.has_power = true
|
||||
return RUNNING
|
18
scripts/simtactics/zone.gd
Normal file
18
scripts/simtactics/zone.gd
Normal file
|
@ -0,0 +1,18 @@
|
|||
extends ConditionLeaf
|
||||
|
||||
export var cost: int = 10000
|
||||
export var income: int = 100
|
||||
export var expense: int = 0
|
||||
|
||||
func tick(actor, blackboard):
|
||||
if SimData.has_power:
|
||||
if SimData.budget >= expense:
|
||||
SimData.budget -= expense
|
||||
SimData.expenses = expense
|
||||
|
||||
if SimData.has_power:
|
||||
var total_income = SimData.res_tax * income
|
||||
SimData.budget += total_income
|
||||
SimData.res_income = total_income
|
||||
|
||||
return RUNNING
|
Loading…
Add table
Add a link
Reference in a new issue