Package forgottentowns.mod.api
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 ClassesModifier and TypeInterfaceDescriptionstatic final recordOne complete bed footprint; adjacency means two footprints share an edge.static final recordA residence, barracks, guard house or other supported home.static final recordMod-owned citizen modifiers, recomputed on load; no effect stores live runtime objects.static final recordOne named recurring happiness modifier.static final recordImmutable citizen identity and projected state.static final recordA surface position at tile resolution.static final recordLocalized roster status, such as a relationship or a temporary absence from work.static interfaceRead-only bounded colony access tied to its creating callback and thread. -
Method Summary
Modifier and TypeMethodDescriptionbooleanassignHome(int citizenId, long homeId) Moves a citizen's home assignment through normal capacity and eligibility rules.intReturns a deterministic daily roll without consuming the game's random stream.default ColonyInventoryReturns scoped physical storage queries and conserving transfers.booleanmodify(int citizenId, ColonyContext.Modifiers modifiers) Replaces only this mod's modifiers for a living citizen.default booleannotifyPlayer(ColonyNotice notice) 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.intspawnCivilian(int near, boolean female, int appearanceVariant) Creates one civilian through normal identity allocation and walkable spawn placement.view()Returns the callback's cached citizen/home view.default ColonyWorkwork()Returns scoped native work and construction services.
-
Method Details
-
notifyPlayer
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 nullIllegalArgumentException- for an unknown/foreign key, oversized message or out-of-world focusIllegalStateException- outside the callback/thread or after its command budgetUnsupportedOperationException- if a custom context does not implement this operation
-
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 threadUnsupportedOperationException- if a custom context does not implement this operation
-
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 threadUnsupportedOperationException- if a custom context does not implement this operation
-
settlement
SettlementTrading.World settlement()Queries persistent settlement identity, calendar and campaign progress.- Returns:
- immutable town snapshot
- Throws:
IllegalStateException- outside the owning callback or thread
-
production
SettlementTrading.Production 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
ColonyContext.View 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
Replaces only this mod's modifiers for a living citizen. Other mods' modifiers remain intact.- Parameters:
citizenId- stable citizen identitymodifiers- immutable bounded effects;ColonyContext.Modifiers.NONEclears this mod's effects- Returns:
- whether the citizen exists and is alive
- Throws:
IllegalArgumentException- if a visual, label, household namespace or bed is invalidIllegalStateException- if the callback has ended or the caller uses another threadNullPointerException- 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 usedfemale- sex of the new citizenappearanceVariant- 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 identityhomeId- 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
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 identitybound- exclusive positive upper bound- Returns:
- integer in [0, bound)
- Throws:
IllegalArgumentException- if the key is null, blank, exceeds 256 characters, or bound is nonpositiveIllegalStateException- if the callback has ended or the caller uses another thread
-