Events are a useful feature that can be used for Cardinal to notify the game client of a certain event or information.

package systems

import "pkg.world.dev/world-engine/cardinal"

func AttackSystem(worldCtx cardinal.WorldContext) {
	// Attack system logic
	
	// ...
	
	// Broadcast the event to all players
    worldCtx.EmitEvent(fmt.Sprintf("player attacked: %s %d"))
}

EmitEvent

The EmitEvent method on cardinal.WorldContext will emit events to all clients under the subject “event”.

To see how to receive notifications go here: https://heroiclabs.com/docs/nakama/concepts/notifications/#receive-notifications (Unity)

func (worldCtx cardinal.WorldContext) EmitEvent(event string)
ParameterTypeDescription
eventstringThe string to emit as an event