summaryrefslogtreecommitdiff
path: root/ecs/src/component.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/component.rs')
-rw-r--r--ecs/src/component.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/ecs/src/component.rs b/ecs/src/component.rs
index 4829050..8119e93 100644
--- a/ecs/src/component.rs
+++ b/ecs/src/component.rs
@@ -1,5 +1,6 @@
use std::any::{Any, TypeId};
use std::fmt::Debug;
+use std::ops::{Deref, DerefMut};
use seq_macro::seq;
@@ -112,3 +113,36 @@ macro_rules! inner {
seq!(C in 0..=64 {
inner!(C);
});
+
+/// Holds a component which is local to a single system.
+#[derive(Debug)]
+pub struct Local<'world, Value>
+{
+ value: &'world mut Value,
+}
+
+impl<'world, Value> Local<'world, Value>
+{
+ pub(crate) fn new(value: &'world mut Value) -> Self
+ {
+ Self { value }
+ }
+}
+
+impl<'world, Value> Deref for Local<'world, Value>
+{
+ type Target = Value;
+
+ fn deref(&self) -> &Self::Target
+ {
+ self.value
+ }
+}
+
+impl<'world, Value> DerefMut for Local<'world, Value>
+{
+ fn deref_mut(&mut self) -> &mut Self::Target
+ {
+ &mut self.value
+ }
+}