rendering items, pick up, iventory re-make in progress to aloow item drop/wear/whatever
This commit is contained in:
@ -30,4 +30,8 @@ func (b *Backpack) HasFreeSpace(Bulk, Mass int) bool {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Backpack) GetItems() []ecs.Entity {
|
||||
return b.items
|
||||
}
|
@ -50,6 +50,8 @@ func (c Carried) Pickup(who, what ecs.Entity) {
|
||||
//remove coords instead (does not exist on map anymore)
|
||||
Controller.RemoveComponent(what, ecs.CoordsComponent)
|
||||
bp.items = append(bp.items, what)
|
||||
//fuck that, we need to update constantly
|
||||
Controller.UpdateComponent(who, ecs.BackpackComponent, bp)
|
||||
}
|
||||
|
||||
func (c Carried) Drop(who, what ecs.Entity) {
|
||||
@ -87,11 +89,12 @@ func (c *Carried) GetBulk(what ecs.Entity) int {
|
||||
return c.Bulk
|
||||
}
|
||||
|
||||
func FindCarriedOnTile(coords types.Coords) []ecs.Entity {
|
||||
func FindCarriedUnder(who ecs.Entity) []ecs.Entity {
|
||||
coords := Controller.GetComponent(who, ecs.CoordsComponent).(types.Coords)
|
||||
carrieds := Controller.GetEntitiesWithComponent(ecs.CarriedComponent)
|
||||
result := make([]ecs.Entity, 0)
|
||||
for _, ent := range carrieds {
|
||||
car := Controller.GetComponent(ent, ecs.CarriedComponent)
|
||||
car := Controller.GetComponent(ent, ecs.CoordsComponent)
|
||||
if car == coords {
|
||||
result = append(result, ent)
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package items
|
||||
|
||||
import "lab.zaar.be/thefish/alchemyst-go/engine/ecs"
|
||||
|
||||
var Controller ecs.Controller
|
||||
var Controller *ecs.Controller
|
||||
|
||||
func Init(ctrl ecs.Controller) {
|
||||
func Init(ctrl *ecs.Controller) {
|
||||
Controller = ctrl
|
||||
}
|
Reference in New Issue
Block a user