| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package aoi
- import (
- "f1-game/internal/types"
- "maps"
- )
- type (
- Objects map[int64]*Object
- )
- func (p Objects) Get(objectID int64) *Object {
- object := p[objectID]
- return object
- }
- func (p Objects) Contains(objectID int64) bool {
- _, found := p[objectID]
- return found
- }
- func (p Objects) Add(object *Object) {
- p[object.ObjectID] = object
- }
- func (p Objects) Adds(objects Objects) {
- maps.Copy(p, objects)
- }
- func (p Objects) Remove(objectID int64) {
- delete(p, objectID)
- }
- func (p Objects) IsEmpty() bool {
- return len(p) < 1
- }
- func (p Objects) OnwerIDs() types.Set[int64] {
- ownerIDs := types.NewSet[int64]()
- for _, object := range p {
- ownerIDs.Add(object.OwnerID())
- }
- return ownerIDs
- }
- func (p Objects) ObjectIDs() types.Set[int64] {
- objectIDs := types.NewSet[int64]()
- for _, object := range p {
- objectIDs.Add(object.ObjectID)
- }
- return objectIDs
- }
|