mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-31 00:49:06 +01:00
Ports the weather system from Nebula. (#18706)
* part 1 * compiles? * IT WORKS * vis contents * fixes * umbrelloid * umbrella 2 * dsasdd * stuff * lmao --------- Co-authored-by: Matt Atlas <liermattia@gmail.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// An individual state, defined as a `/singleton` to save memory.
|
||||
// On a directed graph, these would be the nodes themselves, connected to each other by unidirectional arrows.
|
||||
/singleton/state
|
||||
// Transition decl types, which get turned into refs to those types.
|
||||
// Note that the order DOES matter, as decls earlier in the list have higher priority
|
||||
// if more than one becomes 'open'.
|
||||
var/list/transitions = null
|
||||
|
||||
/singleton/state/Initialize()
|
||||
. = ..()
|
||||
for(var/i in 1 to LAZYLEN(transitions))
|
||||
var/singleton/state_transition/T = GET_SINGLETON(transitions[i])
|
||||
T.from += src
|
||||
transitions[i] = T
|
||||
|
||||
// Returns a list of transitions that a FSM could switch to.
|
||||
// Note that `holder` is NOT the FSM, but instead the thing the FSM is attached to.
|
||||
/singleton/state/proc/get_open_transitions(datum/holder)
|
||||
for(var/singleton/state_transition/T as anything in transitions)
|
||||
if(T.is_open(holder))
|
||||
LAZYADD(., T)
|
||||
|
||||
// Stub for child states to modify the holder when switched to.
|
||||
// Again, `holder` is not the FSM.
|
||||
/singleton/state/proc/entered_state(datum/holder)
|
||||
return
|
||||
|
||||
// Another stub for when leaving a state.
|
||||
/singleton/state/proc/exited_state(datum/holder)
|
||||
return
|
||||
@@ -0,0 +1,16 @@
|
||||
// Used to connect `/singleton/state`s together so the FSM knows what state to switch to, and on what conditions.
|
||||
// On a directed graph, these would be the arrows connecting the nodes representing states.
|
||||
/singleton/state_transition
|
||||
var/list/from = null
|
||||
var/singleton/state/target = null
|
||||
|
||||
// Called by one or more state decls acting as nodes in a directed graph.
|
||||
/singleton/state_transition/Initialize()
|
||||
. = ..()
|
||||
LAZYINITLIST(from)
|
||||
if(ispath(target))
|
||||
target = GET_SINGLETON(target)
|
||||
|
||||
// Tells the FSM if it should or should not be allowed to transfer to the target state.
|
||||
/singleton/state_transition/proc/is_open(datum/holder)
|
||||
return FALSE
|
||||
Reference in New Issue
Block a user