<commit_before>package lbricks

import (
	"github.com/Rubentxu/lbricks/engi"
	"github.com/Rubentxu/lbricks/goflow"
)


type EventSystem struct {
	stepChan	 []chan *StepEvent
	mouseChan    []chan *MouseEvent
	keyboardChan []chan *KeyboardEvent
}

func (g *EventSystem) RegisterInputChannel(input flow.Port) {
	switch input.Port {
	case "StepEvent" :
		append(g.stepChan, input.Channel)
	case "MouseEvent" :
		append(g.mouseChan, input.Channel)
	case "KeyboardEvent" :
		append(g.keyboardChan, input.Channel)
	}
}

func (g *EventSystem) Preload() {}
func (g *EventSystem) Setup() {}
func (g *EventSystem) Close() {}
func (g *EventSystem) Update(dt float32) {}
func (g *EventSystem) Step(step float64, numStep uint32) {}
func (g *EventSystem) Render() {}
func (g *EventSystem) Resize(w, h int) {}

func (g *EventSystem) Mouse(x, y float32, action engi.MouseAction) {
	EventPacket := &EventPacket{1, &MouseEvent{x, y, 0.0, action}}
	for _, e := range g.mouseChan {
		e <- EventPacket
	}
}

func (g *EventSystem) Scroll(amount float32) {}

func (g *EventSystem) Key(key engi.Key, modifier engi.Modifier, action engi.KeyAction) {
	if key == engi.Escape {
		engi.Exit()
	}
	EventPacket := &EventPacket{1, &KeyboardEvent{key, modifier, action}}
	for _, e := range g.keyboardChan {
		e <- EventPacket
	}
}

func (g *EventSystem) Type(char rune) {}<commit_msg>añadido nuevos eventos en event_system<commit_after>package lbricks

import (
	"github.com/Rubentxu/lbricks/engi"
	"github.com/Rubentxu/lbricks/goflow"
)


type EventSystem struct {
	preloadChannnels	 []chan *PreloadEvent
	setupEventChannels	 []chan *SetupEvent
	closeEventChannels	 []chan *CloseEvent
	updateEventChannels	 []chan *UpdateEvent
	renderEventChannels	 []chan *RenderEvent
	resizeEventChannels	 []chan *ResizeEvent
	stepChannels []chan *StepEvent
	mouseChannels []chan *MouseEvent
	scrollEventChannels	 []chan *ScrollEvent
	keyChannels []chan *KeyEvent
	typeKeyEventChannels []chan *TypeKeyEvent
}

func (g *EventSystem) RegisterInputChannel(input flow.Port) {
	switch input.Port {
	case "PreloadEvent" :
		append(g.preloadChannnels, input.Channel)
	case "SetupEvent" :
		append(g.setupEventChannels, input.Channel)
	case "CloseEvent" :
		append(g.closeEventChannels, input.Channel)
	case "UpdateEvent" :
		append(g.updateEventChannels, input.Channel)
	case "RenderEvent" :
		append(g.renderEventChannels, input.Channel)
	case "ResizeEvent" :
		append(g.resizeEventChannels, input.Channel)
	case "StepEvent" :
		append(g.stepChannels, input.Channel)
	case "MouseEvent" :
		append(g.mouseChannels, input.Channel)
		append(g.scrollEventChannels, input.Channel)
	case "KeyboardEvent" :
		append(g.keyChannels, input.Channel)
		append(g.typeKeyEventChannels, input.Channel)
	}
}

func (g *EventSystem) Preload() {
	event := &PreloadEvent{}
	for _, e := range g.preloadChannnels {
		e <- event
	}
}

func (g *EventSystem) Setup() {
	event := &SetupEvent{}
	for _, e := range g.setupEventChannels {
		e <- event
	}
}

func (g *EventSystem) Close() {
	event := &CloseEvent{}
	for _, e := range g.closeEventChannels {
		e <- event
	}
}

func (g *EventSystem) Update(dt float32) {
	event := &UpdateEvent{dt}
	for _, e := range g.updateEventChannels {
		e <- event
	}
}

func (g *EventSystem) Step(step float64, numStep uint32) {
	event := &StepEvent{step, numStep}
	for _, e := range g.stepChannels {
		e <- event
	}
}

func (g *EventSystem) Render() {
	event := &RenderEvent{}
	for _, e := range g.renderEventChannels {
		e <- event
	}
}

func (g *EventSystem) Resize(w, h int) {
	event := &ResizeEvent{w, h}
	for _, e := range g.resizeEventChannels {
		e <- event
	}
}

func (g *EventSystem) Mouse(x, y float32, action engi.MouseAction) {
	event := &MouseEvent{x, y, 0.0, action}
	for _, e := range g.mouseChannels {
		e <- event
	}
}

func (g *EventSystem) Scroll(amount float32) {
	var action engi.MouseAction = engi.WHEEL_UP
	if amount < 0 {
		action = engi.WHEEL_DOWN
	}
	event := &MouseEvent{0, 0, amount, action}
	for _, e := range g.scrollEventChannels {
		e <- event
	}
}

func (g *EventSystem) Key(key engi.Key, modifier engi.Modifier, action engi.KeyAction) {
	if key == engi.Escape {
		engi.Exit()
	}
	event := &KeyEvent{key, modifier, action}
	for _, e := range g.keyChannels {
		e <- event
	}
}

func (g *EventSystem) Type(char rune) {
	event := &TypeKeyEvent{rune}
	for _, e := range g.typeKeyEventChannels {
		e <- event
	}
}
{'fraction_non_alphanumeric': 0.1364877161055505, 'fraction_numerical': 0.0065969062784349405, 'mean_word_length': 4.462111801242236, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4897984', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1613, 'n_words': 388}