This commit is contained in:
2019-11-15 21:24:42 +03:00
parent b3c7beec2b
commit 62f45b920f
12 changed files with 144 additions and 21 deletions

33
engine/items/backpack.go Normal file
View File

@ -0,0 +1,33 @@
package items
import "lab.zaar.be/thefish/alchemyst-go/engine/ecs"
type Backpack struct {
MaxNumber int
MaxBulk int
MaxMass int
items []ecs.Entity
}
func (b Backpack) Type() string {
return ecs.BackpackComponent
}
func (b *Backpack) HasFreeSpace(Bulk, Mass int) bool {
totalBulk, totalMass := 0, 0
for i, _ := range b.items {
tmp := Controller.GetComponent(b.items[i], Carried{}.Type()).(Carried)
carried := tmp
totalBulk += carried.Bulk
totalMass += carried.Mass
}
if totalMass >= b.MaxMass {
//fixme return message along - 'too heavy'
return false
}
if totalBulk >= b.MaxMass {
//fixme return message along - 'doesnt fit to your backpack'
return false
}
return true
}