示例#1
0
        private void AddPresentLightCasters()
        {
            List <Entity> presentEntities = entityManager.Entities;

            for (int i = 0; i < presentEntities.Count; i++)
            {
                RegisterLightCaster(presentEntities[i]);
            }

            List <Entity> mapEntities = new List <Entity>();

            mapEntities.AddRange(mapManager.GetActors());
            mapEntities.AddRange(mapManager.GetProps());
            mapEntities.AddRange(mapManager.GetItems());

            for (int i = 0; i < mapEntities.Count; i++)
            {
                LightCaster lightCaster = mapEntities[i].GetComponent <LightCaster>();

                if (lightCaster != null)
                {
                    RefreshLightPoint(mapEntities[i]);
                }
            }
        }
示例#2
0
        protected void RefreshVisibility(Entity entity, int2 position)
        {
            if (mapManager.Map != null)
            {
                LightCaster lightCaster          = entity.GetComponent <LightCaster>();
                List <int>  rowTilesInsideRadius = GetTilesInsideRadius(position, lightCaster.LightRadius);

                for (int octant = 0; octant < 8; octant++)
                {
                    RefreshOctant(position, lightCaster.LightRadius, octant, rowTilesInsideRadius);
                }
            }
        }
示例#3
0
        private void RegisterLightCaster(Entity entity)
        {
            LightCaster lightCaster = entity.GetComponent <LightCaster>();

            if (lightCaster != null)
            {
                lightCasters.Add(entity);
                RefreshVisibility(entity, entity.CellTransform.Position);
                gameManager.Renderer.RefreshVisibility();

                entity.Events.AddListener(OnLightSourceAddToMap, EntityAddToMapEvent.EVENT_TYPE);
                entity.Events.AddListener(OnLightSourceStartMoving, EntityStartMovementEvent.EVENT_TYPE);
                entity.Events.AddListener(OnLightSourceFinishMoving, EntityFinishMovementEvent.EVENT_TYPE);
            }

            if (entity.Info.NameId == "Door")             // TODO: work a scriptableObject manager to access them via code
            {
                entity.Events.AddListener(OnDoorOpens, DoorOpenEvent.EVENT_TYPE);
            }
        }