Interface ColonyContext


public interface ColonyContext
Colony queries and commands restricted to their owning callback and thread. Inventory, work, and notice commands share a budget of 128 attempts per callback; citizen modifier, spawning, and home-assignment commands do not use that counter. Returned snapshot values can be retained, but the context and its service/view objects expire when the callback returns.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    One complete bed footprint; adjacency means two footprints share an edge.
    static final record 
    A residence, barracks, guard house or other supported home.
    static final record 
    Mod-owned citizen modifiers, recomputed on load; no effect stores live runtime objects.
    static final record 
    One named recurring happiness modifier.
    static final record 
    Immutable citizen identity and projected state.
    static final record 
    A surface position at tile resolution.
    static final record 
    Localized roster status, such as a relationship or a temporary absence from work.
    static interface 
    Read-only bounded colony access tied to its creating callback and thread.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    assignHome(int citizenId, long homeId)
    Moves a citizen's home assignment through normal capacity and eligibility rules.
    int
    dailyRoll(String eventKey, int bound)
    Returns a deterministic daily roll without consuming the game's random stream.
    Returns scoped physical storage queries and conserving transfers.
    boolean
    modify(int citizenId, ColonyContext.Modifiers modifiers)
    Replaces only this mod's modifiers for a living citizen.
    default boolean
    Adds a localized log entry and clickable transient alert.
    Queries completed packing records, chosen exports, and stored tradable inventory totals.
    Queries persistent settlement identity, calendar and campaign progress.
    int
    spawnCivilian(int near, boolean female, int appearanceVariant)
    Creates one civilian through normal identity allocation and walkable spawn placement.
    Returns the callback's cached citizen/home view.
    default ColonyWork
    Returns scoped native work and construction services.
  • Method Details

    • notifyPlayer

      default boolean notifyPlayer(ColonyNotice notice)
      Adds a localized log entry and clickable transient alert. At most eight notices per mod per game minute are admitted. A throttled notice adds neither a log entry nor an alert. This call consumes the shared 128-command budget. Messages are stored in the language active when posted, like native event-log messages.
      Parameters:
      notice - owning-mod translation key, bounded arguments, tone and optional in-world tile
      Returns:
      whether the notice was posted; false when the per-minute limit was reached
      Throws:
      NullPointerException - if notice is null
      IllegalArgumentException - for an unknown/foreign key, oversized message or out-of-world focus
      IllegalStateException - outside the callback/thread or after its command budget
      UnsupportedOperationException - if a custom context does not implement this operation
    • inventory

      default ColonyInventory inventory()
      Returns scoped physical storage queries and conserving transfers.
      Returns:
      inventory service sharing this callback's lifetime and command budget
      Throws:
      IllegalStateException - outside the owning callback or thread
      UnsupportedOperationException - if a custom context does not implement this operation
    • work

      default ColonyWork work()
      Returns scoped native work and construction services.
      Returns:
      work service sharing this callback's lifetime and command budget
      Throws:
      IllegalStateException - outside the owning callback or thread
      UnsupportedOperationException - if a custom context does not implement this operation
    • settlement

      Queries persistent settlement identity, calendar and campaign progress.
      Returns:
      immutable town snapshot
      Throws:
      IllegalStateException - outside the owning callback or thread
    • production

      Queries completed packing records, chosen exports, and stored tradable inventory totals. Reservations are not subtracted from these stock quantities. Retain the detached result when repeated policy decisions can use the same snapshot.
      Returns:
      immutable recorded-production snapshot; theoretical workstation or farm capacity is not included
      Throws:
      IllegalStateException - outside the owning callback or thread
    • view

      Returns the callback's cached citizen/home view. Citizen modifier, spawning, and home-assignment commands invalidate that cache when they reach their mutation step. Calling this method again then captures a replacement; a previously returned view retains its old roster and home values until the callback ends.
      Returns:
      scoped read-only view with detached citizen/home values
      Throws:
      IllegalStateException - outside the owning callback or thread
    • modify

      boolean modify(int citizenId, ColonyContext.Modifiers modifiers)
      Replaces only this mod's modifiers for a living citizen. Other mods' modifiers remain intact.
      Parameters:
      citizenId - stable citizen identity
      modifiers - immutable bounded effects; ColonyContext.Modifiers.NONE clears this mod's effects
      Returns:
      whether the citizen exists and is alive
      Throws:
      IllegalArgumentException - if a visual, label, household namespace or bed is invalid
      IllegalStateException - if the callback has ended or the caller uses another thread
      NullPointerException - if modifiers or one of its status translation keys is null
    • spawnCivilian

      int spawnCivilian(int near, boolean female, int appearanceVariant)
      Creates one civilian through normal identity allocation and walkable spawn placement.
      Parameters:
      near - living citizen whose nearby location should be used
      female - sex of the new citizen
      appearanceVariant - ordinary appearance index; temporary child art belongs in modifiers
      Returns:
      positive new identity, or -1 for an absent/nonliving origin citizen, invalid appearance, or unavailable spawn placement
      Throws:
      IllegalStateException - if the callback has ended or the caller uses another thread
    • assignHome

      boolean assignHome(int citizenId, long homeId)
      Moves a citizen's home assignment through normal capacity and eligibility rules.
      Parameters:
      citizenId - living citizen identity
      homeId - target home identity
      Returns:
      whether assignment succeeded; no existing assignment is lost on failure
      Throws:
      IllegalStateException - if the callback has ended or the caller uses another thread
    • dailyRoll

      int dailyRoll(String eventKey, int bound)
      Returns a deterministic daily roll without consuming the game's random stream. Repeating the same key, mod, world and day returns the same value, including after load.
      Parameters:
      eventKey - stable mod-local event identity
      bound - exclusive positive upper bound
      Returns:
      integer in [0, bound)
      Throws:
      IllegalArgumentException - if the key is null, blank, exceeds 256 characters, or bound is nonpositive
      IllegalStateException - if the callback has ended or the caller uses another thread