// Code generated by eventc event; DO NOT EDIT.

package ec

import (
	"fmt"
	event "git.golaxy.org/tiny/event"
	iface "git.golaxy.org/tiny/utils/iface"
)

type iAutoEventComponentMgrAddComponents interface {
	EventComponentMgrAddComponents() event.IEvent
}

func BindEventComponentMgrAddComponents(auto iAutoEventComponentMgrAddComponents, subscriber EventComponentMgrAddComponents, priority ...int32) event.Hook {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	return event.Bind[EventComponentMgrAddComponents](auto.EventComponentMgrAddComponents(), subscriber, priority...)
}

func _EmitEventComponentMgrAddComponents(auto iAutoEventComponentMgrAddComponents, entity Entity, components []Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrAddComponents()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventComponentMgrAddComponents](subscriber).OnComponentMgrAddComponents(entity, components)
		return true
	})
}

func _EmitEventComponentMgrAddComponentsWithInterrupt(auto iAutoEventComponentMgrAddComponents, interrupt func(entity Entity, components []Component) bool, entity Entity, components []Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrAddComponents()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(entity, components) {
				return false
			}
		}
		iface.Cache2Iface[EventComponentMgrAddComponents](subscriber).OnComponentMgrAddComponents(entity, components)
		return true
	})
}

func HandleEventComponentMgrAddComponents(fun func(entity Entity, components []Component)) EventComponentMgrAddComponentsHandler {
	return EventComponentMgrAddComponentsHandler(fun)
}

type EventComponentMgrAddComponentsHandler func(entity Entity, components []Component)

func (h EventComponentMgrAddComponentsHandler) OnComponentMgrAddComponents(entity Entity, components []Component) {
	h(entity, components)
}

type iAutoEventComponentMgrRemoveComponent interface {
	EventComponentMgrRemoveComponent() event.IEvent
}

func BindEventComponentMgrRemoveComponent(auto iAutoEventComponentMgrRemoveComponent, subscriber EventComponentMgrRemoveComponent, priority ...int32) event.Hook {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	return event.Bind[EventComponentMgrRemoveComponent](auto.EventComponentMgrRemoveComponent(), subscriber, priority...)
}

func _EmitEventComponentMgrRemoveComponent(auto iAutoEventComponentMgrRemoveComponent, entity Entity, component Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrRemoveComponent()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventComponentMgrRemoveComponent](subscriber).OnComponentMgrRemoveComponent(entity, component)
		return true
	})
}

func _EmitEventComponentMgrRemoveComponentWithInterrupt(auto iAutoEventComponentMgrRemoveComponent, interrupt func(entity Entity, component Component) bool, entity Entity, component Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrRemoveComponent()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(entity, component) {
				return false
			}
		}
		iface.Cache2Iface[EventComponentMgrRemoveComponent](subscriber).OnComponentMgrRemoveComponent(entity, component)
		return true
	})
}

func HandleEventComponentMgrRemoveComponent(fun func(entity Entity, component Component)) EventComponentMgrRemoveComponentHandler {
	return EventComponentMgrRemoveComponentHandler(fun)
}

type EventComponentMgrRemoveComponentHandler func(entity Entity, component Component)

func (h EventComponentMgrRemoveComponentHandler) OnComponentMgrRemoveComponent(entity Entity, component Component) {
	h(entity, component)
}

type iAutoEventComponentMgrFirstAccessComponent interface {
	EventComponentMgrFirstAccessComponent() event.IEvent
}

func BindEventComponentMgrFirstAccessComponent(auto iAutoEventComponentMgrFirstAccessComponent, subscriber EventComponentMgrFirstAccessComponent, priority ...int32) event.Hook {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	return event.Bind[EventComponentMgrFirstAccessComponent](auto.EventComponentMgrFirstAccessComponent(), subscriber, priority...)
}

func _EmitEventComponentMgrFirstAccessComponent(auto iAutoEventComponentMgrFirstAccessComponent, entity Entity, component Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrFirstAccessComponent()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventComponentMgrFirstAccessComponent](subscriber).OnComponentMgrFirstAccessComponent(entity, component)
		return true
	})
}

func _EmitEventComponentMgrFirstAccessComponentWithInterrupt(auto iAutoEventComponentMgrFirstAccessComponent, interrupt func(entity Entity, component Component) bool, entity Entity, component Component) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventComponentMgrFirstAccessComponent()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(entity, component) {
				return false
			}
		}
		iface.Cache2Iface[EventComponentMgrFirstAccessComponent](subscriber).OnComponentMgrFirstAccessComponent(entity, component)
		return true
	})
}

func HandleEventComponentMgrFirstAccessComponent(fun func(entity Entity, component Component)) EventComponentMgrFirstAccessComponentHandler {
	return EventComponentMgrFirstAccessComponentHandler(fun)
}

type EventComponentMgrFirstAccessComponentHandler func(entity Entity, component Component)

func (h EventComponentMgrFirstAccessComponentHandler) OnComponentMgrFirstAccessComponent(entity Entity, component Component) {
	h(entity, component)
}
