fix GetEntitiesWuthComponent, pickup logic fixed accordingly
This commit is contained in:
@ -138,15 +138,20 @@ func (c *Controller) GetEntities() map[Entity]map[string]Component {
|
||||
}
|
||||
|
||||
// GetEntitiesWithComponent returns a list of all entities with a given component attached
|
||||
// TODO: Allow for passing a list of components
|
||||
func (c *Controller) GetEntitiesWithComponent(componentType string) []Entity {
|
||||
func (c *Controller) GetEntitiesWithComponent(componentTypes... string) []Entity {
|
||||
entitiesWithComponent := make([]Entity, 0)
|
||||
for entity := range c.entities {
|
||||
if c.HasComponent(entity, componentType) {
|
||||
mustAddThis := true
|
||||
for _, componentType := range componentTypes {
|
||||
if !c.HasComponent(entity, componentType) {
|
||||
mustAddThis = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if mustAddThis {
|
||||
entitiesWithComponent = append(entitiesWithComponent, entity)
|
||||
}
|
||||
}
|
||||
|
||||
return entitiesWithComponent
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user