Ejemplo n.º 1
0
        void UpdateLOS()
        {
            if (this.Environment == null)
            {
                return;
            }

            if (this.World.LivingVisionMode != LivingVisionMode.LOS)
            {
                throw new Exception();
            }

            if (m_losLocation == this.Location &&
                m_losMapVersion == this.Environment.Version &&
                m_visionMap != null)
            {
                return;
            }

            if (m_visionMap == null)
            {
                m_visionMap     = new VisionMap(this.VisionRange);
                m_losMapVersion = 0;
            }

            int z   = this.Z;
            var env = this.Environment;

            RayCastLerp.Calculate3(this.Location, this.VisionRange, m_visionMap, env.Size,
                                   p => !env.GetTileData(p).IsSeeThrough);

            m_losMapVersion = this.Environment.Version;
            m_losLocation   = this.Location;
        }
Ejemplo n.º 2
0
        public void CalculateSight()
        {
            var level = Entity.Get <GameObject>();

            if (_currLevel != level.Level)
            {
                _currLevel = level.Level;
                _vision    = new VisionMap(_currLevel.Size);
            }
            ShadowCastingFOV.ComputeRecursiveShadowcasting(_vision, _currLevel, level.X, level.Y, 32, true);
        }
Ejemplo n.º 3
0
        void UpdateLOS()
        {
            Debug.Assert(this.World.LivingVisionMode == LivingVisionMode.LOS);

            if (this.Environment == null)
            {
                return;
            }

            lock (m_visionMapLock)
            {
                if (m_losLocation == this.Location && m_losMapVersion == this.Environment.Version && m_visionMap != null)
                {
                    return;
                }

                int visionRange = this.VisionRange;

                if (m_visionMap == null)
                {
                    m_visionMap     = new VisionMap(visionRange);
                    m_losMapVersion = 0;
                }

                var env = this.Environment;
                var z   = this.Location.Z;

                RayCastLerp.Calculate3(this.Location, visionRange, m_visionMap, env.Size,
                                       p =>
                {
                    var td = env.GetTileData(p);
                    return(!td.IsUndefined && !td.IsSeeThrough);
                });

                m_losMapVersion = this.Environment.Version;
                m_losLocation   = this.Location;
            }
        }
Ejemplo n.º 4
0
        void UpdateLOS()
        {
            if (this.Environment == null)
                return;

            if (this.World.LivingVisionMode != LivingVisionMode.LOS)
                throw new Exception();

            if (m_losLocation == this.Location &&
                m_losMapVersion == this.Environment.Version &&
                m_visionMap != null)
                return;

            if (m_visionMap == null)
            {
                m_visionMap = new VisionMap(this.VisionRange);
                m_losMapVersion = 0;
            }

            int z = this.Z;
            var env = this.Environment;
            RayCastLerp.Calculate3(this.Location, this.VisionRange, m_visionMap, env.Size,
                p => !env.GetTileData(p).IsSeeThrough);

            m_losMapVersion = this.Environment.Version;
            m_losLocation = this.Location;
        }
Ejemplo n.º 5
0
        void UpdateLOS()
        {
            Debug.Assert(this.World.LivingVisionMode == LivingVisionMode.LOS);

            if (this.Environment == null)
                return;

            lock (m_visionMapLock)
            {
                if (m_losLocation == this.Location && m_losMapVersion == this.Environment.Version && m_visionMap != null)
                    return;

                int visionRange = this.VisionRange;

                if (m_visionMap == null)
                {
                    m_visionMap = new VisionMap(visionRange);
                    m_losMapVersion = 0;
                }

                var env = this.Environment;
                var z = this.Location.Z;

                RayCastLerp.Calculate3(this.Location, visionRange, m_visionMap, env.Size,
                    p =>
                    {
                        var td = env.GetTileData(p);
                        return !td.IsUndefined && !td.IsSeeThrough;
                    });

                m_losMapVersion = this.Environment.Version;
                m_losLocation = this.Location;
            }
        }