items
This commit is contained in:
@ -13,6 +13,7 @@ const ArmsComponent = "arms"
|
||||
const RangedComponent = "ranged"
|
||||
const AmmoComponent = "ammo"
|
||||
const ArmorComponent = "armor"
|
||||
const BackpackComponent = "backpack"
|
||||
|
||||
type Component interface {
|
||||
Type() string
|
||||
|
@ -21,3 +21,18 @@ func TypeInSlice(a string, list []string) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func DeleteFromEntitySlice(haystack []Entity, needle Entity) ([]Entity, Entity) {
|
||||
var excluded Entity
|
||||
for i, _ := range haystack {
|
||||
if haystack[i] == needle {
|
||||
excluded = haystack[i]
|
||||
if len(haystack) - 1 > i {
|
||||
haystack = append(haystack[:i], haystack[i+1:] ...)
|
||||
} else {
|
||||
haystack = haystack[:i]
|
||||
}
|
||||
}
|
||||
}
|
||||
return haystack, excluded
|
||||
}
|
Reference in New Issue
Block a user