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)``
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)``