// 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 iAutoEventTreeNodeAddChild interface {
	EventTreeNodeAddChild() event.IEvent
}

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

func _EmitEventTreeNodeAddChild(auto iAutoEventTreeNodeAddChild, self, child Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeAddChild()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventTreeNodeAddChild](subscriber).OnTreeNodeAddChild(self, child)
		return true
	})
}

func _EmitEventTreeNodeAddChildWithInterrupt(auto iAutoEventTreeNodeAddChild, interrupt func(self, child Entity) bool, self, child Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeAddChild()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(self, child) {
				return false
			}
		}
		iface.Cache2Iface[EventTreeNodeAddChild](subscriber).OnTreeNodeAddChild(self, child)
		return true
	})
}

func HandleEventTreeNodeAddChild(fun func(self, child Entity)) EventTreeNodeAddChildHandler {
	return EventTreeNodeAddChildHandler(fun)
}

type EventTreeNodeAddChildHandler func(self, child Entity)

func (h EventTreeNodeAddChildHandler) OnTreeNodeAddChild(self, child Entity) {
	h(self, child)
}

type iAutoEventTreeNodeRemoveChild interface {
	EventTreeNodeRemoveChild() event.IEvent
}

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

func _EmitEventTreeNodeRemoveChild(auto iAutoEventTreeNodeRemoveChild, self, child Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeRemoveChild()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventTreeNodeRemoveChild](subscriber).OnTreeNodeRemoveChild(self, child)
		return true
	})
}

func _EmitEventTreeNodeRemoveChildWithInterrupt(auto iAutoEventTreeNodeRemoveChild, interrupt func(self, child Entity) bool, self, child Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeRemoveChild()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(self, child) {
				return false
			}
		}
		iface.Cache2Iface[EventTreeNodeRemoveChild](subscriber).OnTreeNodeRemoveChild(self, child)
		return true
	})
}

func HandleEventTreeNodeRemoveChild(fun func(self, child Entity)) EventTreeNodeRemoveChildHandler {
	return EventTreeNodeRemoveChildHandler(fun)
}

type EventTreeNodeRemoveChildHandler func(self, child Entity)

func (h EventTreeNodeRemoveChildHandler) OnTreeNodeRemoveChild(self, child Entity) {
	h(self, child)
}

type iAutoEventTreeNodeEnterParent interface {
	EventTreeNodeEnterParent() event.IEvent
}

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

func _EmitEventTreeNodeEnterParent(auto iAutoEventTreeNodeEnterParent, self, parent Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeEnterParent()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventTreeNodeEnterParent](subscriber).OnTreeNodeEnterParent(self, parent)
		return true
	})
}

func _EmitEventTreeNodeEnterParentWithInterrupt(auto iAutoEventTreeNodeEnterParent, interrupt func(self, parent Entity) bool, self, parent Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeEnterParent()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(self, parent) {
				return false
			}
		}
		iface.Cache2Iface[EventTreeNodeEnterParent](subscriber).OnTreeNodeEnterParent(self, parent)
		return true
	})
}

func HandleEventTreeNodeEnterParent(fun func(self, parent Entity)) EventTreeNodeEnterParentHandler {
	return EventTreeNodeEnterParentHandler(fun)
}

type EventTreeNodeEnterParentHandler func(self, parent Entity)

func (h EventTreeNodeEnterParentHandler) OnTreeNodeEnterParent(self, parent Entity) {
	h(self, parent)
}

type iAutoEventTreeNodeLeaveParent interface {
	EventTreeNodeLeaveParent() event.IEvent
}

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

func _EmitEventTreeNodeLeaveParent(auto iAutoEventTreeNodeLeaveParent, self, parent Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeLeaveParent()).Emit(func(subscriber iface.Cache) bool {
		iface.Cache2Iface[EventTreeNodeLeaveParent](subscriber).OnTreeNodeLeaveParent(self, parent)
		return true
	})
}

func _EmitEventTreeNodeLeaveParentWithInterrupt(auto iAutoEventTreeNodeLeaveParent, interrupt func(self, parent Entity) bool, self, parent Entity) {
	if auto == nil {
		panic(fmt.Errorf("%w: %w: auto is nil", event.ErrEvent, event.ErrArgs))
	}
	event.UnsafeEvent(auto.EventTreeNodeLeaveParent()).Emit(func(subscriber iface.Cache) bool {
		if interrupt != nil {
			if interrupt(self, parent) {
				return false
			}
		}
		iface.Cache2Iface[EventTreeNodeLeaveParent](subscriber).OnTreeNodeLeaveParent(self, parent)
		return true
	})
}

func HandleEventTreeNodeLeaveParent(fun func(self, parent Entity)) EventTreeNodeLeaveParentHandler {
	return EventTreeNodeLeaveParentHandler(fun)
}

type EventTreeNodeLeaveParentHandler func(self, parent Entity)

func (h EventTreeNodeLeaveParentHandler) OnTreeNodeLeaveParent(self, parent Entity) {
	h(self, parent)
}
