예제 #1
0
 //Get all the codelocks on server start/plugin reload.
 void OnServerInitialized()
 {
     _cfgCodeForgetRate = Mathx.Clamp(_cfgCodeForgetRate, 0, 100);
     _cfgLockForgetRate = Mathx.Clamp(_cfgLockForgetRate, 0, 100);
     _codelocks         = UnityEngine.Object.FindObjectsOfType <CodeLock>().ToList();
     _isLoaded          = true;
 }
예제 #2
0
    public void Snapshot(Vector3 position, Quaternion rotation, float serverTime)
    {
        float num1 = (float)((double)this.target.GetInterpolationDelay() + (double)this.target.GetInterpolationSmoothing() + 1.0);
        float time = Time.get_time();

        this.timeOffset0 = this.timeOffset1;
        this.timeOffset1 = this.timeOffset2;
        this.timeOffset2 = this.timeOffset3;
        this.timeOffset3 = time - serverTime;
        float num2 = Mathx.Min(this.timeOffset0, this.timeOffset1, this.timeOffset2, this.timeOffset3);
        float num3 = serverTime + num2;

        if (PositionLerp.DebugLog && this.interpolator.list.Count > 0 && (double)serverTime < (double)this.lastServerTime)
        {
            Debug.LogWarning((object)(this.target.ToString() + " adding tick from the past: server time " + (object)serverTime + " < " + (object)this.lastServerTime));
        }
        else if (PositionLerp.DebugLog && this.interpolator.list.Count > 0 && (double)num3 < (double)this.lastClientTime)
        {
            Debug.LogWarning((object)(this.target.ToString() + " adding tick from the past: client time " + (object)num3 + " < " + (object)this.lastClientTime));
        }
        else
        {
            this.lastClientTime = num3;
            this.lastServerTime = serverTime;
            this.interpolator.Add(new TransformInterpolator.Entry()
            {
                time = num3,
                pos  = position,
                rot  = rotation
            });
        }
        this.interpolator.Cull(num3 - num1);
    }
예제 #3
0
        public void TestGreatestProduct()
        {
            string bigNumber =
                "73167176531330624919225119674426574742355349194934" +
                "96983520312774506326239578318016984801869478851843" +
                "85861560789112949495459501737958331952853208805511" +
                "12540698747158523863050715693290963295227443043557" +
                "66896648950445244523161731856403098711121722383113" +
                "62229893423380308135336276614282806444486645238749" +
                "30358907296290491560440772390713810515859307960866" +
                "70172427121883998797908792274921901699720888093776" +
                "65727333001053367881220235421809751254540594752243" +
                "52584907711670556013604839586446706324415722155397" +
                "53697817977846174064955149290862569321978468622482" +
                "83972241375657056057490261407972968652414535100474" +
                "82166370484403199890008895243450658541227588666881" +
                "16427171479924442928230863465674813919123162824586" +
                "17866458359124566529476545682848912883142607690042" +
                "24219022671055626321111109370544217506941658960408" +
                "07198403850962455444362981230987879927244284909188" +
                "84580156166097919133875499200524063689912560717606" +
                "05886116467109405077541002256983155200055935729725" +
                "71636269561882670428252483600823257530420752963450";

            Assert.AreEqual(1000, bigNumber.Length);

            long greatest = Mathx.GreatestProduct(bigNumber, 4);

            Assert.AreEqual(5832, greatest);

            long greatest2 = Mathx.GreatestProduct(bigNumber, 13);

            Assert.AreEqual(23514624000, greatest2);
        }
예제 #4
0
 void OnEntityDeath(BaseCombatEntity victim, HitInfo info)
 {
     if (victim?.ToPlayer()?.xp?.CurrentLevel != null && LevelLossOnDeath != 0)
     {
         SetLevel(victim.ToPlayer(), Mathx.Clamp(Convert.ToInt32(victim.ToPlayer().xp.CurrentLevel - (victim.ToPlayer().xp.CurrentLevel / 100) * LevelLossOnDeath), MinimalLevel, MaximalLevel));
     }
 }
예제 #5
0
        public static Vector2 GetFrustumSize(this Camera self, float distance)
        {
            var y = Mathx.SizeAtDistance(self.fieldOfView, distance);
            var x = y * self.aspect;

            return(new Vector2(x, y));
        }
예제 #6
0
    public static Bounds3Int MachinePlacementPosition(MachineInfo machineInfo, LandParcel landParcel)
    {
        // Iterate through all positions randomly
        Bounds3Int boundingBox = Bounds3Int.BoundingBox(landParcel.bounds);
        Vector3Int size        = boundingBox.size;

        int[] xPositions = new int[size.x];
        int[] zPositions = new int[size.z];
        Mathx.PopulateRange(xPositions, boundingBox.min.x);
        Mathx.PopulateRange(zPositions, boundingBox.min.z);
        xPositions.Shuffle();
        zPositions.Shuffle();
        int y = boundingBox.min.y;

        for (int i = 0, len = xPositions.Length; i < len; ++i)
        {
            for (int j = 0, jlen = zPositions.Length; j < jlen; ++j)
            {
                Vector3Int position = new Vector3Int(xPositions[i], y, zPositions[j]);
                Bounds3Int bounds   = Bounds3Int.Create(position, machineInfo.size);
                if (MachineSystem.instance.CanCreateMachine(machineInfo, bounds))
                {
                    return(bounds);
                }
            }
        }

        // Unlikely
        return(Bounds3Int.Create(new Vector3Int(0, 0, 0), machineInfo.size));
    }
예제 #7
0
        public void BakeLight(ref Vertex v)
        {
            _light.intensity = 5;
            Vector3 worldPoint    = v.point;
            Vector3 normal        = v.normal;
            Color32 emissiveColor = currentMaterial.emissive;
            Color32 ambientColor  = new Color32(0.2f, 0.2f, 0.3f);

            Vector3 inLightDir = (lightpos - worldPoint);
            float   diffuse    = Vector3.Dot(normal, inLightDir);

            if (diffuse < 0)
            {
                diffuse = 0;
            }
            Color32 diffuseColor = currentMaterial.diffuse * diffuse * _light.lightColor * _light.intensity;
            //
            Vector3 inViewDir = (SceneManager.Current.main_camera.transform.position - worldPoint);
            Vector3 h         = (inLightDir);
            float   specular  = 0;

            if (diffuse != 0)

            {
                specular = (float)System.Math.Pow(Mathx.Range(Vector3.Dot(h, normal), 0, 1), currentMaterial.shininess);
            }
            Color32 specularColor = currentMaterial.specular * specular * _light.lightColor;//镜面高光

            //
            v.lightingColor = emissiveColor + ambientColor + diffuseColor + specularColor;
        }
예제 #8
0
    static Bounds3Int[] PlaceAddonRadially(float radianAngle, Bounds3Int[] addon, SpatialHash <LandParcel> occupied, out Vector2Int position)
    {
        Vector2        direction = Mathx.RadianToVector2(radianAngle);
        PixelTraversal tracer    = new PixelTraversal(new Vector2(), direction);

        Bounds3Int[] placed = new Bounds3Int[addon.Length];
        bool         overlaps;

        do
        {
            tracer.Step();
            overlaps = false;

            for (int i = 0, len = addon.Length; i < len; ++i)
            {
                Bounds3Int translated = addon[i].Translate(tracer.position.ToVector3XZ());
                if (occupied.Overlaps(translated))
                {
                    overlaps = true;
                    break;
                }
                placed[i] = translated;
            }
        } while (overlaps);

        position = tracer.position;
        return(placed);
    }
예제 #9
0
        private double Trim(double sample)
        {
            switch (Type)
            {
            case ThresholdType.LessThan:
                return(Math.Min(UpperBoundary, sample));

            case ThresholdType.GreaterThan:
                return(Math.Max(LowerBoundary, sample));

            case ThresholdType.InRange:
                return(Mathx.Clip(LowerBoundary, UpperBoundary, sample));

            case ThresholdType.OutOfRange:
                if (sample > LowerBoundary && sample < LowerBoundary + (UpperBoundary - LowerBoundary) / 2)
                {
                    return(LowerBoundary);
                }

                if (sample < UpperBoundary && sample >= LowerBoundary + (UpperBoundary - LowerBoundary) / 2)
                {
                    return(UpperBoundary);
                }

                return(sample);

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException("Type", (int)Type, typeof(ThresholdType));
            }
        }
예제 #10
0
    void Update()
    {
        Camera camera = GetComponent <Camera>();

        if (!camera || !target)
        {
            return;
        }

        float distance = Vector3.Distance(camera.transform.position, target.position);

        // Calculate based on the smaller of frustum width and height
        float frustumDiameter = targetFrustumDiameter;
        float aspect          = camera.aspect;

        if (aspect > 1)
        {
            // Landscape screen, calculate vertical frustum
            frustumDiameter *= aspect;
        }

        float fov = Mathx.FovAtDistanceAndFrustumLength(distance, frustumDiameter);

        camera.fieldOfView = fov;
        camera.transform.LookAt(target);
    }
예제 #11
0
        public static Vector3 GetRelativePositionToVertex(Vector3 t, Vector3 zP, Vector3 zR, bool debug = false)
        {
            var   rot = zR / Mathx.Rad2Deg;
            float x = t.x, y = t.y, z = t.z;
            float y0 = y, x0 = x, z0 = z;
            //y
            var a = rot.y;

            z0 = z * Mathx.cos(a) - x * Mathx.sin(a);
            x0 = z * Mathx.sin(a) + x * Mathx.cos(a);
            y  = y0;
            z  = z0;
            //x
            a  = rot.x;
            y0 = y * Mathx.cos(a) - z * Mathx.sin(a);
            z0 = y * Mathx.sin(a) + z * Mathx.cos(a);
            x  = x0;
            y  = y0;
            //z
            a  = rot.z;
            x0 = x * Mathx.cos(a) - y * Mathx.sin(a);
            y0 = x * Mathx.sin(a) + y * Mathx.cos(a);
            if (debug)
            {
                Console.WriteLine("相对" + t + " 结果" + (new Vector3(x0, y0, z0) + zP));
            }
            return(new Vector3(x0, y0, z0) + zP);
        }
예제 #12
0
    public PixelTraversal(Vector2 origin, Vector2 direction)
    {
        // Cube containing origin point.
        position = Mathx.FloorToInt(origin);

        // Avoids an infinite loop.
        if (direction.x == 0 && direction.y == 0)
        {
            direction.x = 1;
        }

        // Direction to increment x,y,z when stepping.
        step = new Vector2Int(
            Sign(direction.x),
            Sign(direction.y));

        // See description above. The initial values depend on the fractional
        // part of the origin.
        tMaxX = Intbound(origin.x, direction.x);
        tMaxY = Intbound(origin.y, direction.y);

        // The change in t when taking a step (always positive).
        tDeltaX = step.x / direction.x;
        tDeltaY = step.y / direction.y;
    }
        private static void AddBoards(FlatMeshBuilder meshBuilder, BoardsInput input)
        {
            var vertices = Squares.Vertices();

            var boardVertices = new Vector3[vertices.Length];

            for (int i = 0; i < boardVertices.Length; ++i)
            {
                boardVertices[i] = Mathx.Multiply(vertices[i].X_Y(), input.extents) + input.offset;
            }

            var boardHeight = input.height / input.count;

            for (int i = 0; i < input.count; ++i)
            {
                var boardTop = input.top - boardHeight * i;

                var v0 = boardVertices[0] + boardTop;
                var v1 = boardVertices[1] + boardTop;
                var v2 = boardVertices[2] + boardTop;
                var v3 = boardVertices[3] + boardTop;

                var v4 = (v0 + v1) * 0.5f - boardHeight;
                var v5 = (v2 + v3) * 0.5f - boardHeight;

                meshBuilder.AddTriangle(v0, v1, v2);
                meshBuilder.AddTriangle(v0, v2, v3);

                meshBuilder.AddTriangle(v1, v4, v5);
                meshBuilder.AddTriangle(v1, v5, v2);

                meshBuilder.AddTriangle(v4, v0, v3);
                meshBuilder.AddTriangle(v4, v3, v5);
            }
        }
예제 #14
0
        public static Vector3 GetRelativePosition(Vector3 t, Vector3 zP, Vector3 zR, bool debug = false)
        {
            var rot = zR / Mathx.Rad2Deg;

            float x = t.x, y = t.y, z = t.z;
            float y0 = y, x0 = x, z0 = z;
            //y
            var a = rot.y;

            z0 = z * Mathx.cos(a) - x * Mathx.sin(a);
            x0 = z * Mathx.sin(a) + x * Mathx.cos(a);
            y  = y0;
            z  = z0;
            //x
            a  = rot.x;
            y0 = y * Mathx.cos(a) - z * Mathx.sin(a);
            z0 = y * Mathx.sin(a) + z * Mathx.cos(a);
            x  = x0;
            y  = y0;
            //z
            a  = rot.z;
            x0 = x * Mathx.cos(a) - y * Mathx.sin(a);
            y0 = x * Mathx.sin(a) + y * Mathx.cos(a);
            return(new Vector3(x0, y0, z0));
        }
예제 #15
0
 void OnValidate()
 {
     hour        = Mathx.Clamp(hour, 0, 23);
     minute      = Mathx.Clamp(minute, 0, 59);
     second      = Mathx.Clamp(second, 0, 59);
     millisecond = Mathx.Clamp(millisecond, 0, 999);
 }
예제 #16
0
        static void Main(string[] args)
        {
            BigInteger max = 4000000 - 1;
            BigInteger sum = Mathx.SumOfEvenFibonacci(max);

            Console.WriteLine("The sum of even valued Fibonacci numbers <= {0} is {1}", max, sum);
        }
예제 #17
0
    private void ForEachInternal(Vector2i v0, Vector2i v1, Vector2i v2, Vector2i v3, Action <int, int> action, Vector2i min, Vector2i max)
    {
        int      num      = Mathf.Max(min.x, Mathx.Min(v0.x, v1.x, v2.x, v3.x));
        int      num1     = Mathf.Min(max.x, Mathx.Max(v0.x, v1.x, v2.x, v3.x));
        int      num2     = Mathf.Max(min.y, Mathx.Min(v0.y, v1.y, v2.y, v3.y));
        int      num3     = Mathf.Min(max.y, Mathx.Max(v0.y, v1.y, v2.y, v3.y));
        int      num4     = v0.y - v1.y;
        int      num5     = v1.x - v0.x;
        int      num6     = v1.y - v2.y;
        int      num7     = v2.x - v1.x;
        int      num8     = v2.y - v0.y;
        int      num9     = v0.x - v2.x;
        int      num10    = v3.y - v2.y;
        int      num11    = v2.x - v3.x;
        int      num12    = v2.y - v1.y;
        int      num13    = v1.x - v2.x;
        int      num14    = v1.y - v3.y;
        int      num15    = v3.x - v1.x;
        Vector2i vector2i = new Vector2i(num, num2);
        int      num16    = (v2.x - v1.x) * (vector2i.y - v1.y) - (v2.y - v1.y) * (vector2i.x - v1.x);
        int      num17    = (v0.x - v2.x) * (vector2i.y - v2.y) - (v0.y - v2.y) * (vector2i.x - v2.x);
        int      num18    = (v1.x - v0.x) * (vector2i.y - v0.y) - (v1.y - v0.y) * (vector2i.x - v0.x);
        int      num19    = (v1.x - v2.x) * (vector2i.y - v2.y) - (v1.y - v2.y) * (vector2i.x - v2.x);
        int      num20    = (v3.x - v1.x) * (vector2i.y - v1.y) - (v3.y - v1.y) * (vector2i.x - v1.x);
        int      num21    = (v2.x - v3.x) * (vector2i.y - v3.y) - (v2.y - v3.y) * (vector2i.x - v3.x);

        vector2i.y = num2;
        while (vector2i.y <= num3)
        {
            int num22 = num16;
            int num23 = num17;
            int num24 = num18;
            int num25 = num19;
            int num26 = num20;
            int num27 = num21;
            vector2i.x = num;
            while (vector2i.x <= num1)
            {
                if ((num22 | num23 | num24) >= 0 || (num25 | num26 | num27) >= 0)
                {
                    action(vector2i.x, vector2i.y);
                }
                num22 += num6;
                num23 += num8;
                num24 += num4;
                num25 += num12;
                num26 += num14;
                num27 += num10;
                vector2i.x++;
            }
            num16 += num7;
            num17 += num9;
            num18 += num5;
            num19 += num13;
            num20 += num15;
            num21 += num11;
            vector2i.y++;
        }
    }
예제 #18
0
        static void Main(string[] args)
        {
            long testNum = 600851475143;

            long largestPrimeFactor = Mathx.LargestPrimeFactor(testNum);

            Console.WriteLine("Largest prime factor of {0} is {1}", testNum, largestPrimeFactor);
        }
        public GeneratorChunk GetChunk(IntVector2 gridPosition)
        {
            int        x          = Mathx.DivideRoundDown(gridPosition.x, _chunkSize);
            int        y          = Mathx.DivideRoundDown(gridPosition.y, _chunkSize);
            IntVector2 chunkIndex = new IntVector2(x, y);

            return(GetChunkByIndex(chunkIndex));
        }
        protected override Complex[] GetPoles(int filterOrder, double ripple)
        {
            Debug.Assert(ripple == 0);

            return(Enumerable.Range(0, filterOrder)
                   .Select(i => Mathx.Expj((filterOrder / 2.0 + 0.5 + i) * Math.PI / filterOrder))
                   .ToArray());
        }
예제 #21
0
 public static Vector3 GetMousePosition()
 {
     if (!Mathx.IsZero(m_MousePosition))
     {
         return(m_MousePosition);
     }
     return(Input.mousePosition);
 }
예제 #22
0
    private float GetShockHeightDelta(WheelCollider wheel)
    {
        RaycastHit raycastHit;
        int        mask = LayerMask.GetMask(new string[] { "Terrain", "World", "Construction" });

        Physics.Linecast(wheel.transform.position, wheel.transform.position - (Vector3.up * 10f), out raycastHit, mask);
        return(Mathx.RemapValClamped(raycastHit.distance, this.traceDistanceNeutralPoint - this.shockDistance, this.traceDistanceNeutralPoint + this.shockDistance, this.shockDistance * 0.75f, -0.75f * this.shockDistance));
    }
예제 #23
0
        public static SpheCoord ToSpheCoord(Vector3 v3)
        {
            var p = Mathx.sqrt(v3.x * v3.x + v3.y + v3.y + v3.z * v3.z);
            var r = Mathx.sqrt(v3.x * v3.x + v3.y + v3.y);
            var x = Mathx.atan(v3.y / v3.x);
            var y = Mathx.asin(r / p);

            return(new SpheCoord(r, x, y));
        }
    public Vector2i WorldToGridCoords(Vector3 worldPos)
    {
        int num  = Mathf.CeilToInt(worldPos.x * this.CellSizeInverse);
        int num1 = Mathf.CeilToInt(worldPos.z * this.CellSizeInverse);
        int num2 = Mathx.Clamp(num + this.CellCountHalf, 0, this.CellCount - 1);

        num1 = Mathx.Clamp(num1 + this.CellCountHalf, 0, this.CellCount - 1);
        return(new Vector2i(num2, num1));
    }
        private GeneratorChunk GetBiomeChunk(GeneratorChunk chunk, IntVector2 offset)
        {
            int        x          = Mathx.DivideRoundDown(chunk.ChunkIndex.x, _biomeSizeInChunks);
            int        y          = Mathx.DivideRoundDown(chunk.ChunkIndex.y, _biomeSizeInChunks);
            IntVector2 chunkIndex = new IntVector2(x, y);

            chunkIndex += offset;
            chunkIndex *= _biomeSizeInChunks;
            return(GetChunkByIndex(chunkIndex));
        }
예제 #26
0
    protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos)
    {
        bool flag = true;

        if (Vector3Ex.IsNaNOrInfinity(eyePos))
        {
            string shortPrefabName = this.ShortPrefabName;
            AntiHack.Log(player, AntiHackType.EyeHack, "Contains NaN (" + shortPrefabName + ")");
            player.stats.combat.Log(this, "eye_nan");
            flag = false;
        }
        if (ConVar.AntiHack.eye_protection > 0)
        {
            float  num1            = 1f + ConVar.AntiHack.eye_forgiveness;
            double eyeClientframes = (double)ConVar.AntiHack.eye_clientframes;
            float  eyeServerframes = ConVar.AntiHack.eye_serverframes;
            float  num2            = (float)(eyeClientframes / 60.0);
            float  num3            = eyeServerframes * Mathx.Max(Time.get_deltaTime(), Time.get_smoothDeltaTime(), Time.get_fixedDeltaTime());
            float  num4            = (player.desyncTime + num2 + num3) * num1;
            if (ConVar.AntiHack.eye_protection >= 1)
            {
                double  num5           = (double)player.MaxVelocity();
                Vector3 parentVelocity = player.GetParentVelocity();
                double  magnitude      = (double)((Vector3) ref parentVelocity).get_magnitude();
                float   num6           = (float)(num5 + magnitude);
                float   num7           = player.BoundsPadding() + num4 * num6;
                float   num8           = Vector3.Distance(player.eyes.position, eyePos);
                if ((double)num8 > (double)num7)
                {
                    string shortPrefabName = this.ShortPrefabName;
                    AntiHack.Log(player, AntiHackType.EyeHack, "Distance (" + shortPrefabName + " on attack with " + (object)num8 + "m > " + (object)num7 + "m)");
                    player.stats.combat.Log(this, "eye_distance");
                    flag = false;
                }
            }
            if (ConVar.AntiHack.eye_protection >= 2)
            {
                Vector3 center   = player.eyes.center;
                Vector3 position = player.eyes.position;
                Vector3 p2       = eyePos;
                if (!GamePhysics.LineOfSight(center, position, p2, 2162688, 0.0f))
                {
                    string shortPrefabName = this.ShortPrefabName;
                    AntiHack.Log(player, AntiHackType.EyeHack, "Line of sight (" + shortPrefabName + " on attack) " + (object)center + " " + (object)position + " " + (object)p2);
                    player.stats.combat.Log(this, "eye_los");
                    flag = false;
                }
            }
            if (!flag)
            {
                AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty);
            }
        }
        return(flag);
    }
예제 #27
0
    public static float RemapValClamped(float val, float A, float B, float C, float D)
    {
        if (A == B)
        {
            return(Mathx.fsel(val - B, D, C));
        }
        float single = (val - A) / (B - A);

        single = Mathf.Clamp(single, 0f, 1f);
        return(C + (D - C) * single);
    }
예제 #28
0
파일: Growth.cs 프로젝트: Tristyn/if_source
 public long At(float value, long count)
 {
     return(growthRate switch
     {
         GrowthRate.Constant => Constant(value, coefficient, count, rounding),
         GrowthRate.Linear => Linear(value, coefficient, count, rounding),
         GrowthRate.Log => Log(value, coefficient, count, rounding),
         GrowthRate.Quadratic => Quadratic(value, coefficient, count, rounding),
         GrowthRate.Exponential => Exponential(value, coefficient, count, rounding),
         _ => Mathx.RoundToInt(value, rounding),
     });
예제 #29
0
        public void TestLargestPrimeFactor()
        {
            Assert.AreEqual(0, Mathx.LargestPrimeFactor(-1));
            Assert.AreEqual(0, Mathx.LargestPrimeFactor(0));
            Assert.AreEqual(0, Mathx.LargestPrimeFactor(1));

            Assert.AreEqual(3, Mathx.LargestPrimeFactor(9));

            Assert.AreEqual(29, Mathx.LargestPrimeFactor(13195));

            Assert.AreEqual(6857, Mathx.LargestPrimeFactor(600851475143));
        }
예제 #30
0
    protected bool ValidateEyePos(BasePlayer player, Vector3 eyePos)
    {
        bool flag = true;

        if (eyePos.IsNaNOrInfinity())
        {
            string shortPrefabName = base.ShortPrefabName;
            AntiHack.Log(player, AntiHackType.EyeHack, "Contains NaN (" + shortPrefabName + ")");
            player.stats.combat.Log(this, "eye_nan");
            flag = false;
        }
        if (ConVar.AntiHack.eye_protection > 0)
        {
            float num = 1f + ConVar.AntiHack.eye_forgiveness;
            float eye_clientframes = ConVar.AntiHack.eye_clientframes;
            float eye_serverframes = ConVar.AntiHack.eye_serverframes;
            float num2             = eye_clientframes / 60f;
            float num3             = eye_serverframes * Mathx.Max(UnityEngine.Time.deltaTime, UnityEngine.Time.smoothDeltaTime, UnityEngine.Time.fixedDeltaTime);
            float num4             = (player.desyncTimeClamped + num2 + num3) * num;
            int   layerMask        = (ConVar.AntiHack.eye_terraincheck ? 10551296 : 2162688);
            if (ConVar.AntiHack.eye_protection >= 1)
            {
                float num5 = player.MaxVelocity() + player.GetParentVelocity().magnitude;
                float num6 = player.BoundsPadding() + num4 * num5;
                float num7 = Vector3.Distance(player.eyes.position, eyePos);
                if (num7 > num6)
                {
                    string shortPrefabName2 = base.ShortPrefabName;
                    AntiHack.Log(player, AntiHackType.EyeHack, "Distance (" + shortPrefabName2 + " on attack with " + num7 + "m > " + num6 + "m)");
                    player.stats.combat.Log(this, "eye_distance");
                    flag = false;
                }
            }
            if (ConVar.AntiHack.eye_protection >= 2)
            {
                Vector3 center   = player.eyes.center;
                Vector3 position = player.eyes.position;
                if (!GamePhysics.LineOfSight(center, position, eyePos, layerMask))
                {
                    string shortPrefabName3 = base.ShortPrefabName;
                    AntiHack.Log(player, AntiHackType.EyeHack, string.Concat("Line of sight (", shortPrefabName3, " on attack) ", center, " ", position, " ", eyePos));
                    player.stats.combat.Log(this, "eye_los");
                    flag = false;
                }
            }
            if (!flag)
            {
                AntiHack.AddViolation(player, AntiHackType.EyeHack, ConVar.AntiHack.eye_penalty);
            }
        }
        return(flag);
    }