Interface Context

All Known Implementing Classes:
EventContext, IntervalContext, LocationContext, MapMarkerOverrideContext, PrefabPasteContext, PrefabRemoveContext, TriggerVolumeContext, WorldContext

public interface Context
A typed value stored in a world event's ContextMap under a ContextKey. Context objects are the primary mechanism by which conditions and actions share data within a running event: a condition writes a value into the map and a later action reads it by the same key.

Each implementation must register itself with TYPE_CODEC using a unique string ID so that context entries can be persisted and restored across world reloads.

Most implementations do not need to override cleanup(CommandBuffer, WorldEvent). Override it only when the context holds a resource that must be released when the event ends, such as a reference to a child event that should be stopped (see EventContext) or a world snapshot that must be restored (see PrefabRemoveContext).

  • Field Details

  • Method Details

    • cleanup

      default void cleanup(@Nonnull CommandBuffer<EntityStore> buffer, @Nonnull WorldEvent event)
      Called when the owning event ends, whether by success or failure.

      Override to release resources or trigger compensating actions. Enqueue any ECS mutations through buffer rather than applying them directly. This method is only called for context entries that are still present in the map when the event ends; entries that were removed via consume earlier in the event's lifetime will not have cleanup invoked.

      Parameters:
      buffer - the command buffer for enqueuing ECS mutations
      event - the world event that just ended