Skip to content

is it reasonable for goword.GetSpace returing *space object instead of Ispace? #113

@MistarQ

Description

@MistarQ

here is the seene

type MySpace struct { goworld.Space // Space type should always inherit from entity.Space }

i create a space called mySpace, if i use
func GetSpace(id common.EntityID) *Space
i will get an *Space and i can not change it into mySpace unless use
mySpace := (*MySpace)(unsafe.Pointer(space))

and if i change GetSpace into
func GetSpace(id EntityID) entity.ISpace { return entity.GetSpaceI(id) }

then we can easily cast ISpace into mySpace

ms := goworld.GetSpaceI(monster.Space.ID).(*MySpace)``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions