Skip to main content

WorldTime

Enum WorldTime 

Source
pub enum WorldTime {
    Day,
    Noon,
    Dusk,
    Night,
    Midnight,
    Dawn,
    Celestial(CelestialTime),
}
Expand description

A declared world time state (DSL v0.5, spec-0010; the celestial spelling spec-0081). The sole difference from vanilla is that the daylight cycle is frozen (advance_time false), so a set state persists for the whole delve until a set-time effect cuts to another.

Two spellings of one clock. A keyword — day, noon, dusk, night, midnight, dawn — states vanilla’s word with vanilla’s meaning: the hour, on day 0, so a keyword night shows a full moon. A celestial statement (CelestialTime, {"moon": "just-risen", "phase": "new-moon"}) names one body, where it stands and, where the moon shows, its phase, and the engine computes the tick count, day included. Both resolve to one Clock (WorldTime::clock); two values are equal when their clocks are.

Vanilla’s /time set primitive takes either one of four keywords or a raw tick count, and the tick form is the general one. dusk and dawn are the tick form exposed first-class, per the no-hack rule; a celestial statement is the same primitive reached from a designer’s sentence. A keyword on day 0 still emits its keyword verbatim (WorldTime::token), so existing campaigns are byte-identical.

There is no Default (spec-0061 §4). A default hour is a design decision wearing a mechanism’s clothes, and #[default] Noon is what let a delve whose whole approved look was night build, light-check and render under a blue noon sky. Removing the impl is what makes that unwritable rather than merely discouraged: WorldContent::time is required, and nothing can supply an hour the author did not.

Variants§

§

Day

Morning daylight (/time set day, 1000 ticks).

§

Noon

Midday, brightest (/time set noon, 6000 ticks).

§

Dusk

Sunset onset (/time set 12000).

§

Night

Night, sun fully down (/time set night, 13000 ticks).

§

Midnight

Deep night, darkest (/time set midnight, 18000 ticks).

§

Dawn

First light, just before sunrise (/time set 23000).

§

Celestial(CelestialTime)

A sky stated in a designer’s words (spec-0081).

Implementations§

Source§

impl WorldTime

Source

pub fn is_keyword(self) -> bool

Whether this is one of the six keywords.

Source

pub fn celestial(self) -> Option<CelestialTime>

The celestial statement, if this is one.

Source

pub fn stated_phase(self) -> Option<MoonPhase>

The phase this value states, if any.

Source

pub fn daytime_ticks(self) -> i64

The daytime tick value this state sets (the time query daytime read-back). Keywords: day=1000, noon=6000, dusk=12000 (sunset onset), night=13000, midnight=18000, dawn=23000; a celestial statement its position’s tick (crate::celestial::position_tick).

Source

pub fn world_day(self) -> i64

The day this value names as the world’s own time: a keyword is day 0; a celestial statement the day its phase names, or day 0 where it names none (the moon is below the horizon, so no phase is stated).

Source

pub fn clock(self, site: TimeSite, world: WorldTime) -> Clock

The clock this value sets, at a site whose world declares world (spec-0081 §3.3).

  • A celestial statement is its position’s tick on the day its phase names, or the world’s day where it states none — a cut changes the hour, and the moon keeps the phase the world declared.
  • A keyword is its table row on day 0 where it states a sky — the world’s own time, a design row, a camera (TimeSite::Sky) — and on the world’s day where it is a set-time cut (TimeSite::Cut), which changes the hour and keeps the moon.
Source

pub fn world_clock(self) -> Clock

The world’s own clock: WorldTime::clock at the world’s site.

Source

pub fn token(self, clock: Clock) -> String

The vanilla /time set argument for clock, the one token every time set the engine emits goes through: a keyword on day 0 emits its table argument verbatim (night, 12000), so no keyword campaign’s bytes move; any other clock emits the integer day × 24000 + daytime.

Source

pub fn keyword(self) -> String

What an author writes — this state’s spelling in a document: the keyword, or the canonical JSON of a celestial statement ({"moon":"high","phase":"new-moon"}).

Not WorldTime::token, which is the /time set argument and is a raw tick count for every state vanilla does not name. A diagnostic that asks an author to declare an hour has to say dusk, not 12000.

Trait Implementations§

Source§

impl Clone for WorldTime

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WorldTime

Source§

impl Debug for WorldTime

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for WorldTime

Source§

fn deserialize<D: Deserializer<'de>>(de: D) -> Result<WorldTime, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for WorldTime

Source§

impl From<TimeKeyword> for WorldTime

Source§

fn from(k: TimeKeyword) -> WorldTime

Converts to this type from the input type.
Source§

impl Hash for WorldTime

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonSchema for WorldTime

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn json_schema(g: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl PartialEq for WorldTime

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for WorldTime

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for WorldTime

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.