Class WorldRuntime

java.lang.Object
io.github.protasm.jvmud.engine.world.WorldRuntime

public final class WorldRuntime extends Object
Owns the core world ontology, place links, and containment rules for one JVMud world.

A WorldRuntime is the engine-level view of one running world. It deliberately models JVMud concepts directly: places are linked locations, entities are contained by exactly one immediate location, and movement is a containment update optionally driven by a place-to-place link. LPC objects can adapt into this model, but legacy LP driver terms are not required here.

Instances are identity-oriented. A Place or Entity must have been created by this runtime before it can be used as a location, link endpoint, movement target, or inventory container.

  • Constructor Details

    • WorldRuntime

      public WorldRuntime(World world)
      Creates a new runtime for a single world.
      Parameters:
      world - the world metadata owned by this runtime
  • Method Details

    • world

      public World world()
      Returns the world metadata for this runtime.
    • scheduler

      public WorldScheduler scheduler()
      Returns the deterministic scheduler associated with this world.
    • mudlibBoundary

      public MudlibBoundary mudlibBoundary()
      Returns the currently registered mudlib boundary, or an empty boundary if none is present.
    • registerMudlibBoundary

      public void registerMudlibBoundary(MudlibBoundary mudlibBoundary)
      Registers the mudlib boundary metadata used by higher-level engine and compiler adapters.
      Parameters:
      mudlibBoundary - boundary declarations read from JVMud-native mudlib configuration
    • createPlace

      public Place createPlace(String id, String displayName)
      Creates a place that can contain entities and act as a link endpoint.
      Parameters:
      id - stable world-local identifier
      displayName - player-facing or admin-facing label
      Returns:
      the created place
      Throws:
      IllegalArgumentException - if any known place or entity already has the same id
    • createEntity

      public Entity createEntity(String id, String displayName, Location initialLocation, Capability... capabilities)
      Creates an entity at an initial location.

      Every entity is immediately located. The initial location may be a place or another entity, but it must already belong to this runtime.

      Parameters:
      id - stable world-local identifier
      displayName - player-facing or admin-facing label
      initialLocation - known place or entity that will contain the new entity
      capabilities - optional engine-level capabilities
      Returns:
      the created entity
    • findLocation

      public Location findLocation(String id)
      Finds a place or entity by id, returning null when no matching location exists.
    • place

      public Place place(String id)
      Returns a known place by id, or null if the id does not name a place.
    • entity

      public Entity entity(String id)
      Returns a known entity by id, or null if the id does not name an entity.
    • translucent

      public boolean translucent(Entity entity)
      Returns whether light and other ambient perception can pass through an entity container.
    • setTranslucent

      public void setTranslucent(Entity entity, boolean translucent)
      Sets whether light and other ambient perception can pass through an entity container.
    • removeEntity

      public boolean removeEntity(String id)
      Removes a known entity from this world runtime.

      Any entities contained by the removed entity are removed first so the world never retains locations whose container no longer exists.

      Returns:
      true if an entity with the supplied id was present and removed
    • locationOf

      public Location locationOf(Entity entity)
      Returns the immediate location of an entity, or null if it has not been located.
    • contentsOf

      public List<Entity> contentsOf(Location location)
      Returns the entities immediately contained by a location.
      Throws:
      IllegalArgumentException - if the location was not created by this runtime
    • connect

      public Link connect(Place origin, String action, Place destination)
      Creates a visible link from one place to another.
    • connect

      public Link connect(Place origin, String action, Place destination, boolean visible)
      Creates or replaces a link from one place to another for a normalized action string.
      Parameters:
      origin - known place where traversal begins
      action - command/action that selects the link
      destination - known place reached by traversal
      visible - whether the link should be visible to ordinary perception
      Returns:
      the created link
    • connectBothWays

      public void connectBothWays(Place first, String firstAction, Place second, String secondAction)
      Creates two visible links that connect the supplied places in opposite directions.
    • linkFrom

      public Link linkFrom(Place origin, String action)
      Returns the link for an action from a place, or null when no such link exists.
    • linksFrom

      public List<Link> linksFrom(Place origin)
      Returns the currently registered outbound links from a place in insertion order.
    • placeOf

      public Place placeOf(Entity entity)
      Returns the containing place for an entity, walking through entity containers as needed.
      Returns:
      the nearest containing place, or null if the entity is not ultimately in one
    • traverse

      public boolean traverse(Entity entity, String action)
      Moves an entity across the link selected by an action from its containing place.
      Returns:
      true if a link was found and movement occurred
    • move

      public void move(Entity entity, Location destination)
      Moves an entity into a known destination location.

      Movement updates both the entity's immediate location and the contents lists of the old and new containers. Moving an entity into itself, directly or through nested containment, is rejected.