|
@@ -92,15 +92,20 @@ pub struct EntityContext<'a> {
|
|
|
|
|
|
impl<'a> EntityVisitor for EntityContext<'a> {
|
|
|
fn visit<E: Entity>(&mut self) {
|
|
|
- let entry = self
|
|
|
- .container
|
|
|
- .states
|
|
|
- .entry((self.context, E::entity_name()));
|
|
|
// three cases:
|
|
|
// 1. we haven't seen this entity in this context before
|
|
|
// 2. we've seen this entity in this context before
|
|
|
// 3. we haven't seen this entity in this context before, but we've seen one with an identical name in the same context
|
|
|
|
|
|
+ if self.container.states.contains_key(&(self.context, E::entity_name())) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let entry = self
|
|
|
+ .container
|
|
|
+ .states
|
|
|
+ .entry((self.context, E::entity_name()));
|
|
|
+
|
|
|
let entry = entry.or_insert_with(|| EntityState::build::<E>(self.context));
|
|
|
// sanity-check
|
|
|
if entry.typeid != std::any::TypeId::of::<E>() {
|