|
|
|
@ -145,12 +145,12 @@ impl Tile for StorageCount {
|
|
|
|
|
if let Some(target_position) = context.offset(signal.direction().into_offset()) {
|
|
|
|
|
let _ = context.send(target_position, signal.direction(), signal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if context.state() != State::Idle {
|
|
|
|
|
context.next_state();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw_simple(&self, ctx: DrawContext) -> TextChar {
|
|
|
|
|
TextChar::from_state('\u{2058}', ctx.state) // FOUR DOT PUNCTUATION
|
|
|
|
@ -231,6 +231,56 @@ impl Tile for Stacker {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
pub struct Debug {
|
|
|
|
|
value: Value,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for Debug {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
value: Value::Number(0.0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Tile for Debug {
|
|
|
|
|
fn update<'b>(&'b mut self, mut context: UpdateContext<'b>) {
|
|
|
|
|
if let Some(mut signal) = context.take_signal() {
|
|
|
|
|
if let Some(value) = signal.pop() {
|
|
|
|
|
self.value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if context.state() != State::Idle {
|
|
|
|
|
context.next_state();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn draw(&self, surface: &mut TextSurface, ctx: DrawContext<'_>) {
|
|
|
|
|
use palette::Srgb;
|
|
|
|
|
let text = format!("\"{}", self.value);
|
|
|
|
|
|
|
|
|
|
let y = ctx.surface_coords.1;
|
|
|
|
|
for (index, c) in text.chars().enumerate() {
|
|
|
|
|
let x = ctx.surface_coords.0 + index as i32;
|
|
|
|
|
if let (Ok(x), Ok(y)) = (x.try_into(), y.try_into()) {
|
|
|
|
|
let textchar = if index == 0 {
|
|
|
|
|
TextChar::from_state(c, ctx.state)
|
|
|
|
|
} else {
|
|
|
|
|
TextChar::new(c, Srgb::new(100, 100, 100), None)
|
|
|
|
|
};
|
|
|
|
|
surface.set(x, y, textchar);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn schema(&self) -> TileSchema {
|
|
|
|
|
TileSchema::map()
|
|
|
|
|
.add("value", TileSchema::value("Stored value", "Value"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Tries to convert a [`FullTile`] to a [`Store`]
|
|
|
|
|
fn get_store<'a>(full: VecRef<'a, FullTile>) -> Option<VecRef<'a, Store>> {
|
|
|
|
|
VecRef::try_map(full, |tile| {
|
|
|
|
|