City-building simulation video game
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB

7 months ago
package system
import (
"code.rocketnine.space/tslocum/citylimits/component"
"code.rocketnine.space/tslocum/citylimits/world"
"code.rocketnine.space/tslocum/gohan"
"github.com/hajimehoshi/ebiten/v2"
)
type TaxSystem struct {
}
func NewTaxSystem() *TaxSystem {
s := &TaxSystem{}
return s
}
func (s *TaxSystem) Needs() []gohan.ComponentID {
return []gohan.ComponentID{
component.PositionComponentID,
component.VelocityComponentID,
component.WeaponComponentID,
}
}
func (s *TaxSystem) Uses() []gohan.ComponentID {
return nil
}
func (s *TaxSystem) Update(_ *gohan.Context) error {
if world.World.Paused {
return nil
}
if world.World.Ticks%world.YearTicks != 0 {
return nil
}
7 months ago
taxCollectionAmount := 777.77
7 months ago
for _, zone := range world.World.Zones {
7 months ago
if zone.Population == 0 {
7 months ago
continue
}
7 months ago
taxRate := world.World.TaxR
if zone.Type == world.StructureCommercialZone {
taxRate = world.World.TaxC
} else if zone.Type == world.StructureIndustrialZone {
taxRate = world.World.TaxI
}
world.World.Funds += int(taxCollectionAmount * taxRate)
7 months ago
}
return nil
}
7 months ago
func (s *TaxSystem) Draw(_ *gohan.Context, _ *ebiten.Image) error {
7 months ago
return gohan.ErrSystemWithoutDraw
}