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; }
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; } }