|
|
@ -6,6 +6,14 @@ use crate::tile::prelude::*;
|
|
|
|
use serde_with::{serde_as, DefaultOnNull};
|
|
|
|
use serde_with::{serde_as, DefaultOnNull};
|
|
|
|
use veccell::VecRef;
|
|
|
|
use veccell::VecRef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! macro_try {
|
|
|
|
|
|
|
|
( $instructions:block ) => {
|
|
|
|
|
|
|
|
(|| {
|
|
|
|
|
|
|
|
$instructions
|
|
|
|
|
|
|
|
})()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[serde_as]
|
|
|
|
#[serde_as]
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
|
|
|
pub struct Store {
|
|
|
|
pub struct Store {
|
|
|
@ -84,7 +92,7 @@ impl Reader {
|
|
|
|
impl Tile for Reader {
|
|
|
|
impl Tile for Reader {
|
|
|
|
fn update<'b>(&'b mut self, mut context: UpdateContext<'b>) {
|
|
|
|
fn update<'b>(&'b mut self, mut context: UpdateContext<'b>) {
|
|
|
|
if let Some(_signal) = context.take_signal() {
|
|
|
|
if let Some(_signal) = context.take_signal() {
|
|
|
|
let _: Option<()> = try {
|
|
|
|
let _: Option<()> = macro_try!({
|
|
|
|
let store_position = context.offset(self.0.opposite().into_offset())?;
|
|
|
|
let store_position = context.offset(self.0.opposite().into_offset())?;
|
|
|
|
let store = context.get(store_position).and_then(get_store)?;
|
|
|
|
let store = context.get(store_position).and_then(get_store)?;
|
|
|
|
let signal = store.signal.clone();
|
|
|
|
let signal = store.signal.clone();
|
|
|
@ -93,7 +101,9 @@ impl Tile for Reader {
|
|
|
|
let target_position = context.offset(self.0.into_offset())?;
|
|
|
|
let target_position = context.offset(self.0.into_offset())?;
|
|
|
|
|
|
|
|
|
|
|
|
let _ = context.send(target_position, self.0, signal);
|
|
|
|
let _ = context.send(target_position, self.0, signal);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Some(())
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if context.state() != State::Idle {
|
|
|
|
if context.state() != State::Idle {
|
|
|
|