private void ResetVisibilityStateIfPartiallyVisible(ObscurePillar unused)
 {
     if (visibilityState == VisibilityState_old.partiallyVisible)
     {
         ResetVisibilityState();
     }
 }
        private void HandlePillarChanged(ObscurePillar unused)
        {
            pillarsFound.Clear();
            switch (findPillarsTechnique)
            {
            case FindPillarsTechnique.whitelist:
                foreach (var pillar in whitelist)
                {
                    pillarsFound.Add(pillar);
                }
                break;

            case FindPillarsTechnique.automaticSphere:
                SearchForPillarsInSphere(new List <ObscurePillar>());
                break;

            case FindPillarsTechnique.automaticSphereWithBlacklist:
                SearchForPillarsInSphere(blacklist);
                break;

            case FindPillarsTechnique.automaticBox:
                SearchForPillarsInBox(new List <ObscurePillar>());
                break;

            case FindPillarsTechnique.automaticBoxWithBlacklist:
                SearchForPillarsInBox(blacklist);
                break;
            }
            if (!overrideOnOffAngles && pillarsFound.Contains(ObscurePillar.activePillar))
            {
                RecalculateOnOffPositions();
            }
        }
 private void SearchForPillarsInBox(List <ObscurePillar> blacklist)
 {
     foreach (var pillarMaybe in Physics.OverlapBox(transform.position, pillarSearchBoxSize / 2f, new Quaternion()))
     {
         ObscurePillar pillar = pillarMaybe.GetComponent <ObscurePillar>();
         if (pillar != null && !blacklist.Contains(pillar))
         {
             pillarsFound.Add(pillar);
         }
     }
 }
 private void SearchForPillarsInSphere(List <ObscurePillar> blacklist)
 {
     foreach (var pillarMaybe in Physics.OverlapSphere(transform.position, pillarSearchRadius))
     {
         ObscurePillar pillar = pillarMaybe.GetComponent <ObscurePillar>();
         if (pillar != null && !blacklist.Contains(pillar))
         {
             pillarsFound.Add(pillar);
         }
     }
 }
 private void HandleActivePillarChanged(ObscurePillar previousPillar)
 {
     if (activePillar == this)
     {
         EnablePillar();
     }
     else
     {
         DisablePillar();
     }
 }
        private void RecalculateOnOffPositions(ObscurePillar unused)
        {
            if (ObscurePillar.activePillar == null)
            {
                onAngle = null; offAngle = null;
                return;
            }

            Vector3[] bounds  = new Vector3[] { thisRenderer.GetRendererBounds().min, thisRenderer.GetRendererBounds().max };
            Vector3[] corners = new Vector3[] {
                new Vector3(bounds[0].x, bounds[0].y, bounds[0].z),
                new Vector3(bounds[0].x, bounds[0].y, bounds[1].z),
                new Vector3(bounds[0].x, bounds[1].y, bounds[0].z),
                new Vector3(bounds[0].x, bounds[1].y, bounds[1].z),
                new Vector3(bounds[1].x, bounds[0].y, bounds[0].z),
                new Vector3(bounds[1].x, bounds[0].y, bounds[1].z),
                new Vector3(bounds[1].x, bounds[1].y, bounds[0].z),
                new Vector3(bounds[1].x, bounds[1].y, bounds[1].z)
            };

            Vector3 centerOfObject = thisRenderer.GetRendererBounds().center;
            Angle   baseAngle      = PolarCoordinate.CartesianToPolar(centerOfObject - ObscurePillar.activePillar.transform.position).angle;

            onAngle  = Angle.Radians(baseAngle.radians + .001f);
            offAngle = Angle.Radians(baseAngle.radians);
            foreach (var corner in corners)
            {
                PolarCoordinate cornerPolar = PolarCoordinate.CartesianToPolar(corner - ObscurePillar.activePillar.transform.position);
                if (!Angle.IsAngleBetween(cornerPolar.angle, offAngle, onAngle))
                {
                    Angle replaceOn  = Angle.AngleBetween(cornerPolar.angle, offAngle);
                    Angle replaceOff = Angle.AngleBetween(cornerPolar.angle, onAngle);
                    if (replaceOn.radians > replaceOff.radians)
                    {
                        onAngle = cornerPolar.angle;
                    }
                    else
                    {
                        offAngle = cornerPolar.angle;
                    }
                }
            }
            onAngle.Reverse();
            offAngle.Reverse();
        }