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

View File

@ -13,6 +13,7 @@ const ArmsComponent = "arms"
const RangedComponent = "ranged"
const AmmoComponent = "ammo"
const ArmorComponent = "armor"
const BackpackComponent = "backpack"
type Component interface {
Type() string

View File

@ -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
}