public void OnEntityRegistered(object sender, EntityRegistryComponent.EntityEventArgs e)
        {
            this.Log(e.Entity.Map
            ? $"Location registering {e.Entity}"
            : $"Location spawning {e.Entity}");

            e.Entity.SetLocation(this);

            if (!e.Entity.Map)
            {
                e.Entity.SetCell(EntryCell);
            }

            if (AssociatedMap)
            {
                AssociatedMap.EntityRegistry.Register(e.Entity);
            }

            if (!e.Entity.Map)
            {
                EntitySpawned?.Invoke(this, new EntityRegistryComponent.EntityEventArgs(e.Entity));
                return;
            }

            EntityArrived?.Invoke(this, new EntityRegistryComponent.EntityEventArgs(e.Entity));
        }
        public void OnEntityUnregistered(object sender, EntityRegistryComponent.EntityEventArgs e)
        {
            this.Log($"Location unregistering {e.Entity}");

            e.Entity.SetLocation(null);

            if (AssociatedMap)
            {
                this.Log($"Location relocating {e.Entity} from {AssociatedMap} to {ContainingMap}");

                AssociatedMap.EntityRegistry.Unregister(e.Entity);
                ContainingMap.EntityRegistry.Register(e.Entity);
            }

            EntityLeft?.Invoke(this, new EntityRegistryComponent.EntityEventArgs(e.Entity));
        }
        /// <summary>
        /// Callback for the <see cref = "LocationComponent.EntityLeft">EntityLeft</see> event
        /// of the company's <see cref = "LocationComponent">LocationComponent</see><br/>
        /// Invokes the <see cref = "CartLeft">CartLeft</see> or <see cref = "EmployeeLeft">EmployeeLeft</see> event.
        /// </summary>
        public void OnEntityLeft(object sender, EntityRegistryComponent.EntityEventArgs e)
        {
            var employee = e.Entity.GetComponent <EmployeeComponent>();
            var cart     = e.Entity.GetComponent <CartComponent>();

            if (IsEmployed(employee))
            {
                this.Log($"Employee {employee} left company");
                EmployeeLeft?.Invoke(this, new EmployeeLeftEventArgs(employee));
            }

            if (IsEmployed(cart))
            {
                this.Log($"Cart {cart} left company");
                CartLeft?.Invoke(this, new CartLeftEventArgs(cart));
            }
        }
Example #4
0
        public void OnEntityUnregistered(object sender, EntityRegistryComponent.EntityEventArgs e)
        {
            this.Log($"Map unregistering {e.Entity}");

            e.Entity.SetMap(null);
        }
Example #5
0
        void OnEntitySpawned(object sender, EntityRegistryComponent.EntityEventArgs e)
        {
            this.Log($"Map spawning {e.Entity}");

            EntityRegistry.Register(e.Entity);
        }