func Test_Camera_AddComponent(t *testing.T) { camera := NewCamera() input := new(components.Input) camera.AddComponent(input) assert.Equal(t, input, components.GetInput(camera.Entity)) }
// TearDownEntity :: EntityListener func (self *Input) TearDownEntity(entity *core.Entity) { input := components.GetInput(entity) if input.WantsPolling() { self.inputQueue.UnpollEvents(input.Polling) } }
func (self *Input) Update(deltaT float32) { var input *components.Input nextEvents := self.inputQueue.RecentEvents() for _, entity := range self.entitySet.Entities() { input = components.GetInput(entity) for _, event := range nextEvents { if callback, ok := input.Mapping[event.EventType]; ok { callback(entity, event) } } } }
func Test_Player_HasInput(t *testing.T) { player := NewPlayer() assert.NotNil(t, components.GetInput(player.GetEntity()), "No input component found") }