Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Invalid Component Type error #16

@cchandel

Description

@cchandel

Hi,
I'm converting older code to the new ECS code.

I had a component like so

type Position struct {
	ecs.Component[Position]
	x float64
	y  float64
	routex  []float64
}

func (m *MoveSystem) Init(si ecs.SystemInitConstraint) {
	m.SetRequirements(si, &components.Position{})
}

When registering this system like so

ecs.RegisterSystem[systems.MoveSystem](utilities.World)

I'm getting errors like

panic: invalid component type

goroutine 20 [running]:
github.com/zllangct/ecs.(*Component[...]).check(0xc0001e8ea0?, {0xc0003243e0})
        /home/cc/ecs/component.go:253 +0xf8
github.com/zllangct/ecs.(*System[...]).setRequirements(0xc0001ba5a0, {0x40f507}, {0xc0000af220?, 0x4?, 0x203001})
        /home/cc/ecs/system.go:186 +0xf1
github.com/zllangct/ecs.(*System[...]).SetRequirements(0x17?, {0xc0003243e0?}, {0xc0000af220, 0x2a?, 0xca0e80?})
        /home/cc/ecs/system.go:161 +0x2d
ecs-server/systems.(*MoveNpcSystem).Init(0xc0001ba5a0, {0xc000100000?})
        /home/cc/ecs-server/systems/moveSystem.go.go:34 +0x112

Seems like there's an issue using slices in components.
Please help.

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