Example #1
0
        // ReSharper disable once RedundantAssignment
        public static bool TryPickItemAtRear(CargoPath __instance, int[] needs, out int needIdx, out byte stack, out byte inc, ref int __result)
        {
            needIdx = -1;
            stack   = 1;
            inc     = 0;

            int num = __instance.bufferLength - 5 - 1;

            if (__instance.buffer[num] == 250)
            {
                int num2 = __instance.buffer[num + 1] - 1 + (__instance.buffer[num + 2] - 1) * 100 + (__instance.buffer[num + 3] - 1) * 10000 + (__instance.buffer[num + 4] - 1) * 1000000;
                int item = __instance.cargoContainer.cargoPool[num2].item;
                stack = __instance.cargoContainer.cargoPool[num2].stack;
                inc   = __instance.cargoContainer.cargoPool[num2].inc;

                for (int i = 0; i < needs.Length; i++)
                {
                    if (item == needs[i])
                    {
                        Array.Clear(__instance.buffer, num - 4, 10);
                        int num3 = num + 5 + 1;
                        if (__instance.updateLen < num3)
                        {
                            __instance.updateLen = num3;
                        }
                        __instance.cargoContainer.RemoveCargo(num2);
                        needIdx  = i;
                        __result = item;
                        return(false);
                    }
                }
            }
            __result = 0;
            return(false);
        }
        /// <summary>
        /// 根据线路获取实体
        /// </summary>
        public static List <EntityData> GetEntitysByPath(PlanetFactory factory, CargoPath path)
        {
            List <EntityData> entityList = new List <EntityData>();

            foreach (var entity in factory.entityPool)
            {
                if (path.belts.Contains(entity.beltId))
                {
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
Example #3
0
        // this should return the cargo node from a belt id
        public static CargoPath GetPathWithBeltId(PlanetFactory factory, int beltId)
        {
            CargoPath cargoLine = null;

            foreach (var cargoPath in factory.cargoTraffic.pathPool)
            {
                if (cargoPath != null && cargoPath.belts.Contains(beltId))// get the line of conveyor from the belt ID
                {
                    cargoLine = cargoPath;
                }
            }

            return(cargoLine);
        }
Example #4
0
        public void ProcessPacket(BeltUpdatePickupItemsPacket packet, NebulaConnection conn)
        {
            CargoTraffic traffic = GameMain.data.factories[packet.FactoryIndex].cargoTraffic;

            //Iterate though belt updates and remove target items
            for (int i = 0; i < packet.BeltUpdates.Length; i++)
            {
                CargoPath cargoPath = traffic.GetCargoPath(traffic.beltPool[packet.BeltUpdates[i].BeltId].segPathId);
                //Check if belt exists
                if (cargoPath != null)
                {
                    cargoPath.TryPickItem(packet.BeltUpdates[i].SegId - 4 - 1, 12);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 根据线路获取所有传送带
        /// </summary>
        public static List <EntityData> GetBletsByPath(PlanetFactory factory, CargoPath path)
        {
            List <EntityData> beltList = new List <EntityData>();

            foreach (var beltId in path.belts)
            {
                foreach (var entity in factory.entityPool)
                {
                    if (beltId == entity.beltId)
                    {
                        beltList.Add(entity);
                    }
                }
            }
            return(beltList);
        }
Example #6
0
        //this should return the list of the conveyors belts entities from a specific node
        public static List <EntityData> GetBeltsEntitiesByCargoPathBuildRange(
            PlanetFactory factory,
            CargoPath path)
        {
            var beltEntitiesList = new List <EntityData>();

            foreach (var entityData in factory.entityPool)
            {
                if (path.belts.Contains(entityData.beltId))
                {
                    if (CheckIfInBuildDistance(entityData.pos))
                    {
                        beltEntitiesList.Add(entityData);
                    }
                }
            }

            return(beltEntitiesList);
        }
Example #7
0
 public void ProcessPacket(BeltUpdatePickupItemsPacket packet, NebulaConnection conn)
 {
     if (GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic != null)
     {
         CargoTraffic traffic = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic;
         //Iterate though belt updates and remove target items
         for (int i = 0; i < packet.BeltUpdates.Length; i++)
         {
             if (packet.BeltUpdates[i].BeltId >= traffic.beltPool.Length)
             {
                 return;
             }
             CargoPath cargoPath = traffic.GetCargoPath(traffic.beltPool[packet.BeltUpdates[i].BeltId].segPathId);
             //Check if belt exists
             if (cargoPath != null)
             {
                 cargoPath.TryPickItem(packet.BeltUpdates[i].SegId - 4 - 1, 12);
             }
         }
     }
 }
        public override void ProcessPacket(BeltUpdatePickupItemsPacket packet, NebulaConnection conn)
        {
            CargoTraffic traffic = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic;

            if (traffic != null)
            {
                //Iterate though belt updates and remove target items
                for (int i = 0; i < packet.BeltUpdates.Length; i++)
                {
                    if (packet.BeltUpdates[i].BeltId >= traffic.beltPool.Length)
                    {
                        return;
                    }
                    BeltComponent beltComponent = traffic.beltPool[packet.BeltUpdates[i].BeltId];
                    CargoPath     cargoPath     = traffic.GetCargoPath(beltComponent.segPathId);
                    int           ItemId        = packet.BeltUpdates[i].ItemId;
                    //Check if belt exists
                    if (cargoPath != null)
                    {
                        // Search downstream for target item
                        for (int k = beltComponent.segIndex + beltComponent.segPivotOffset; k <= (beltComponent.segIndex + beltComponent.segLength - 1); k++)
                        {
                            if (cargoPath.TryPickItem(k - 4 - 1, 12, ItemId, out _, out _) != 0)
                            {
                                return;
                            }
                        }
                        // Search upstream for target item
                        for (int k = beltComponent.segIndex + beltComponent.segPivotOffset - 1; k >= beltComponent.segIndex; k--)
                        {
                            if (cargoPath.TryPickItem(k - 4 - 1, 12, ItemId, out _, out _) != 0)
                            {
                                return;
                            }
                        }
                        Log.Warn($"BeltUpdatePickupItem: Cannot pick item{ItemId} on belt{packet.BeltUpdates[i].BeltId}, planet{packet.PlanetId}");
                    }
                }
            }
        }
Example #9
0
            public static bool DetermineDestructPreviewsPatch(PlayerAction_Build __instance,
                                                              ref NearColliderLogic ___nearcdLogic,
                                                              ref PlanetFactory ___factory)
            {
                if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.LeftControl))
                {
                    if (!VFInput.onGUI)
                    {
                        UICursor.SetCursor(ECursor.Delete);
                    }
                }
                else
                {
                    return(true);
                }

                if (!Utils.CheckIfInBuildDistance(__instance.cursorTarget))
                {
                    // Out of reach
                    UnityEngine.Debug.Log("out of reach");
                    return(true);
                }

                List <EntityData> deleteEntitiesList = new List <EntityData>();
                ItemProto         itemProto          = Traverse.Create(__instance).Method(
                    "GetItemProto", __instance.castObjId).GetValue <ItemProto>();

                __instance.ClearBuildPreviews();

                if (VFInput.reformMinusKey.onDown)
                {
                    if (__instance.reformSize >= 0)
                    {
                        __instance.reformSize--;
                    }
                }

                if (VFInput.reformPlusKey.onDown)
                {
                    if (__instance.reformSize < _configDisassemblingRadiusMax.Value)
                    {
                        __instance.reformSize++;
                    }
                }

                // Management of the sphere delete
                if (Input.GetKey(KeyCode.LeftControl))
                {
                    int[] buildingIdsToDelete = new int[_maxArrayOfBuildingSize.Value];
                    if (itemProto != null)
                    {
                        ___nearcdLogic.GetBuildingsInAreaNonAlloc(__instance.castObjPos, __instance.reformSize, buildingIdsToDelete);
                    }
                    else
                    {
                        ___nearcdLogic.GetBuildingsInAreaNonAlloc(__instance.cursorTarget, __instance.reformSize, buildingIdsToDelete);
                    }

                    List <int> listBuildingIdsToDelete = new List <int>();

                    foreach (var id in buildingIdsToDelete)
                    {
                        if (id != 0)
                        {
                            listBuildingIdsToDelete.Add(id);
                        }
                    }

                    foreach (var item in listBuildingIdsToDelete)
                    {
                        deleteEntitiesList.Add(___factory.entityPool[item]);
                    }

                    // Management of both
                    if (Input.GetKey(KeyCode.LeftShift))
                    {
                        if (itemProto != null)
                        {
                            deleteEntitiesList = Utils.GetEntitySortedByTypeAndRadius(itemProto, deleteEntitiesList,
                                                                                      __instance.castObjPos, __instance.reformSize);
                        }
                    }
                }

                // Management of the Mass Item delete
                if (Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.LeftControl))
                {
                    __instance.previewPose.position = Vector3.zero;
                    __instance.previewPose.rotation = Quaternion.identity;
                    if ((uint)__instance.castObjId > 0U)
                    {
                        if (itemProto != null)
                        {
                            if ((uint)___factory.entityPool[__instance.castObjId].beltId > 0U)
                            {
                                CargoPath pathByBeltId = Utils.GetPathWithBeltId(___factory,
                                                                                 ___factory.entityPool[__instance.castObjId].beltId);
                                deleteEntitiesList = Utils.GetBeltsEntitiesByCargoPathBuildRange(___factory, pathByBeltId);
                            }
                            else
                            {
                                // deleteEntitiesList = Utils.GetEntitiesByProtoBuildRange(___factory, itemProto);
                                return(true);
                            }
                        }
                    }
                }


                foreach (var entityData in deleteEntitiesList)
                {
                    __instance.AddBuildPreview(new BuildPreview());
                }

                // Common Code
                for (int index = 0; index < __instance.buildPreviews.Count; ++index)
                {
                    BuildPreview buildPreview = __instance.buildPreviews[index];
                    ItemProto    itemProto2   = Traverse.Create(__instance).Method(
                        "GetItemProto", deleteEntitiesList[index].id).GetValue <ItemProto>();
                    buildPreview.item  = itemProto2;
                    buildPreview.desc  = itemProto2.prefabDesc;
                    buildPreview.lpos  = deleteEntitiesList[index].pos;
                    buildPreview.lrot  = deleteEntitiesList[index].rot;
                    buildPreview.objId = deleteEntitiesList[index].id;
                    int num = buildPreview.desc.lodCount <= 0
                        ? 0
                        : ((Object)buildPreview.desc.lodMeshes[0] != (Object)null ? 1 : 0);
                    buildPreview.needModel  = num != 0;
                    buildPreview.isConnNode = true;
                    if (buildPreview.desc.isInserter)
                    {
                        Pose pose = Traverse.Create(__instance).Method("GetObjectPose2", buildPreview.objId)
                                    .GetValue <Pose>();
                        buildPreview.lpos2 = pose.position;
                        buildPreview.lrot2 = pose.rotation;
                    }

                    if ((buildPreview.lpos - __instance.player.position).sqrMagnitude >
                        __instance.player.mecha.buildArea *
                        __instance.player.mecha.buildArea)
                    {
                        buildPreview.condition   = EBuildCondition.OutOfReach;
                        __instance.cursorText    = "目标超出范围".Translate();
                        __instance.cursorWarning = true;
                    }
                    else
                    {
                        buildPreview.condition = EBuildCondition.Ok;
                        __instance.cursorText  = "拆除".Translate() + buildPreview.item.name;
                    }

                    if (buildPreview.desc.multiLevel)
                    {
                        ___factory.ReadObjectConn(buildPreview.objId, 15, out bool _, out int otherObjId,
                                                  out int _);
                        if ((uint)otherObjId > 0U)
                        {
                            buildPreview.condition = EBuildCondition.Covered;
                            __instance.cursorText  = buildPreview.conditionText;
                        }
                    }
                }


                return(false);
            }
Example #10
0
        public static void CargoPath_TestBlankAtHead_Postfix(CargoPath __instance, ref bool __result)
        {
            if (__result)
            {
                return;
            }

            // See if we can make room...
            // Each slot takes up 10 bytes in the 'buffer'.
            // 'index' already contains the *10.
            // First 4 "bytes" are reserved for something.
            //    'index' is always >= 4
            //    'buffer' has no bytes for these 4
            // If an item isn't present, all ten bytes are zero.
            // If an item is present:
            //    [4 + index + 0-4] is 246, 247, 248, 249, 250
            //    [4 + index + 5,6,7,8] is the cargo number
            //    [4 + index + 9] is byte.MaxValue

            List <int> cargoIds  = new List <int>();
            int        zeroCount = 0;

            for (int index10 = 0; index10 < cargoSlotLookAhead; index10 += slotLength)
            {
                if (__instance.buffer[index10] == 0)
                {
                    for (; index10 < __instance.bufferLength && __instance.buffer[index10] == 0; ++index10)
                    {
                        zeroCount++;
                        if (zeroCount == slotLength)
                        {
                            Array.Clear(__instance.buffer, 0, index10);
                            int index = 4 + slotLength;
                            foreach (int cargoId_insert in cargoIds)
                            {
                                __instance.InsertCargoDirect(index, cargoId_insert);
                                index += slotLength;
                            }
                            if (index != index10 + 5)
                            {
                                Logger.LogError($"Splitter insert upgraded error. index10={index10}, index={index}");
                            }
                            __result = true;
                            return;
                        }
                    }
                }

                if (index10 + 9 >= __instance.bufferLength ||
                    __instance.buffer[index10 + 0] != 246 ||
                    __instance.buffer[index10 + 1] != 247 ||
                    __instance.buffer[index10 + 2] != 248 ||
                    __instance.buffer[index10 + 3] != 249 ||
                    __instance.buffer[index10 + 4] != 250 ||
                    __instance.buffer[index10 + 9] != byte.MaxValue)
                {
                    return;
                }

                int cargoId_extract = (int)
                                      (__instance.buffer[index10 + 5] - 1 +
                                       (__instance.buffer[index10 + 6] - 1) * 100) +
                                      (int)(__instance.buffer[index10 + 7] - 1) * 10000 +
                                      (int)(__instance.buffer[index10 + 8] - 1) * 1000000;
                cargoIds.Add(cargoId_extract);
            }
        }
        public static bool CargoPathPatch(CargoPath __instance)
        {
            var _this = __instance;

            if (_this.outputPath != null)
            {
                int Sign = _this.bufferLength - 5 - 1;
                if (_this.buffer[Sign] == 250)
                {
                    int cargoId = (int)(_this.buffer[Sign + 1] - 1 + (_this.buffer[Sign + 2] - 1) * 100) + (int)(_this.buffer[Sign + 3] - 1) * 10000 + (int)(_this.buffer[Sign + 4] - 1) * 1000000;
                    if (_this.closed) // 线路闭合
                    {
                        if (_this.outputPath.TryInsertCargoNoSqueeze(_this.outputIndex, cargoId))
                        {
                            Array.Clear(_this.buffer, Sign - 4, 10);
                            _this.updateLen = _this.bufferLength;
                        }
                    }
                    else if (_this.outputPath.TryInsertCargo(_this.outputIndex, cargoId))
                    {
                        Array.Clear(_this.buffer, Sign - 4, 10);
                        _this.updateLen = _this.bufferLength;
                    }
                }
            }
            else if (_this.bufferLength <= 10)
            {
                return(false);
            }
            if (!_this.closed)
            {
                int Rear = _this.bufferLength - 1;
                if (_this.buffer[Rear] != 255 && _this.buffer[Rear] != 0)
                {
                    Debug.Log($"传送带末尾异常! {_this.id} {Rear}");
                    // 清空异常数据
                    for (int i = Rear; i >= 0; i--)
                    {
                        if (_this.buffer[i] == 246)
                        {
                            _this.buffer[i] = 0;
                            break;
                        }
                        _this.buffer[i] = 0;
                    }
                    _this.updateLen = _this.bufferLength;
                }
            }
            for (int j = _this.updateLen - 1; j >= 0; j--)
            {
                if (_this.buffer[j] == 0)
                {
                    break;
                }
                _this.updateLen--;
            }
            if (_this.updateLen == 0)
            {
                return(false);
            }
            int len = _this.updateLen;

            for (int k = _this.chunkCount - 1; k >= 0; k--)
            {
                int begin = _this.chunks[k * 3];
                int speed = _this.chunks[k * 3 + 2];
                if (begin < len)
                {
                    if (_this.buffer[begin] != 0)
                    {
                        for (int l = begin - 5; l < begin + 4; l++)
                        {
                            if (l >= 0)
                            {
                                if (_this.buffer[l] == 250)
                                {
                                    if (l < begin)
                                    {
                                        begin = l + 5 + 1;
                                    }
                                    else
                                    {
                                        begin = l - 4;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    if (speed > 10) // 如果速度大于10,则进行长度判断处理,防止越界
                    {
                        for (int i = 10; i <= speed; i++)
                        {
                            if (begin + i + 10 >= _this.bufferLength) // 即将离开传送带尽头
                            {
                                speed = i;
                                break;
                            }
                            else
                            {
                                if (_this.buffer[begin + i] != 0) // 速度范围内不为空
                                {
                                    speed = i;
                                    break;
                                }
                            }
                        }
                        if (speed < 10)
                        {
                            speed = 10; // 如果速度减速到安全速度以内,设定为安全速度
                        }
                    }
                    int m = 0;
                    while (m < speed)
                    {
                        int num8 = len - begin;
                        if (num8 < 10) // 移动结束
                        {
                            break;
                        }
                        int num9 = 0;
                        for (int n = 0; n < speed - m; n++)
                        {
                            if (_this.buffer[len - 1 - n] != 0)
                            {
                                break;
                            }
                            num9++;
                        }
                        if (num9 > 0)
                        {
                            Array.Copy(_this.buffer, begin, _this.buffer, begin + num9, num8 - num9);
                            Array.Clear(_this.buffer, begin, num9);
                            m += num9;
                        }
                        for (int num11 = len - 1; num11 >= 0; num11--)
                        {
                            if (_this.buffer[num11] == 0)
                            {
                                break;
                            }
                            len--;
                        }
                    }
                    int num12 = begin + ((m != 0) ? m : 1);
                    if (len > num12)
                    {
                        len = num12;
                    }
                }
            }
            return(false);
        }
        public static bool ColorPath1(CargoTraffic __instance, int beltId)
        {
            var _this = __instance;

            if (beltId == 0)
            {
                return(false);
            }
            _this.RemoveBeltRenderer(beltId);
            CargoPath cargoPath = _this.GetCargoPath(_this.beltPool[beltId].segPathId);

            if (cargoPath == null)
            {
                return(false);
            }
            BeltComponent beltComponent = _this.beltPool[beltId];
            double        num           = (double)((float)beltComponent.segIndex - 0.5f);
            double        num2          = (double)((float)(beltComponent.segIndex + beltComponent.segLength) - 0.5f);

            if (cargoPath.closed)
            {
                if (num < 4.0)
                {
                    num = 4.0;
                }
                if (num2 + 9.0 + 1.0 >= (double)cargoPath.pathLength)
                {
                    num2 = (double)(cargoPath.pathLength - 5);
                }
            }
            else
            {
                if (num < 4.0)
                {
                    num = 4.0;
                }
                if (num2 + 5.0 >= (double)cargoPath.pathLength)
                {
                    num2 = (double)(cargoPath.pathLength - 5 - 1);
                }
            }
            int num3 = 1;
            int num4 = 0;

            if (beltComponent.mainInputId > 0 && beltComponent.outputId > 0)
            {
                Vector3 pos  = _this.factory.entityPool[_this.beltPool[beltComponent.mainInputId].entityId].pos;
                Vector3 pos2 = _this.factory.entityPool[beltComponent.entityId].pos;
                Vector3 pos3 = _this.factory.entityPool[_this.beltPool[beltComponent.outputId].entityId].pos;
                float   num5 = Vector3.Angle(pos - pos2, pos3 - pos2);
                if (num5 > 165f)
                {
                    num3 = 1;
                    num4 = 0;
                }
                else if (num5 > 135f)
                {
                    num3 = 2;
                    num4 = 1;
                }
                else if (num5 > 100f)
                {
                    num3 = 4;
                    num4 = 2;
                }
                else
                {
                    num3 = 8;
                    num4 = 3;
                }
                if (beltComponent.segIndex + beltComponent.segLength == cargoPath.pathLength && cargoPath.outputPath != null)
                {
                    num3 = 8;
                    num4 = 3;
                }
            }
            if (beltComponent.speed <= 1)
            {
            }
            else if (beltComponent.speed <= 2)
            {
                num4 += 4;
            }
            else if (beltComponent.speed <= 5)
            {
                num4 += 8;
            }
            else if (beltComponent.speed <= 10)
            {
                num4 += 12;
            }
            else
            {
                num4 += 16;
            }
            var tmpBeltAnchors = new BeltAnchor[9];

            for (int i = 0; i <= num3; i++)
            {
                double num6 = num + (num2 - num) / (double)num3 * (double)i;
                int    num7 = (int)(Math.Floor(num6) + 1E-06);
                double num8 = num6 - (double)num7;
                int    num9 = (num8 >= 1E-05) ? (num7 + 1) : num7;
                tmpBeltAnchors[i].t = (float)num6;
                if (num9 == num7)
                {
                    tmpBeltAnchors[i].pos = cargoPath.pointPos[num7];
                    tmpBeltAnchors[i].rot = cargoPath.pointRot[num7];
                }
                else
                {
                    tmpBeltAnchors[i].pos = Vector3.Lerp(cargoPath.pointPos[num7], cargoPath.pointPos[num9], (float)num8);
                    tmpBeltAnchors[i].rot = Quaternion.Slerp(cargoPath.pointRot[num7], cargoPath.pointRot[num9], (float)num8);
                }
            }
            _this.beltPool[beltId].modelBatchIndex = num4 + 1;
            _this.beltPool[beltId].modelIndex      = _this.beltRenderingBatch[num4].AddNode(tmpBeltAnchors);
            return(false);
        }
Example #13
0
        public static bool CargoPathPatch(CargoPath __instance)
        {
            var _this = __instance;

            if (_this.outputPath != null)
            {
                int num = _this.bufferLength - 5 - 1;
                if (_this.buffer[num] == 250)
                {
                    int cargoId = (int)(_this.buffer[num + 1] - 1 + (_this.buffer[num + 2] - 1) * 100) + (int)(_this.buffer[num + 3] - 1) * 10000 + (int)(_this.buffer[num + 4] - 1) * 1000000;
                    if (_this.closed)
                    {
                        if (_this.outputPath.TryInsertCargoNoSqueeze(_this.outputIndex, cargoId))
                        {
                            Array.Clear(_this.buffer, num - 4, 10);
                            _this.updateLen = _this.bufferLength;
                        }
                    }
                    else if (_this.outputPath.TryInsertCargo(_this.outputIndex, cargoId))
                    {
                        Array.Clear(_this.buffer, num - 4, 10);
                        _this.updateLen = _this.bufferLength;
                    }
                }
            }
            else if (_this.bufferLength <= 10)
            {
                return(false);
            }
            if (!_this.closed)
            {
                int num2 = _this.bufferLength - 1;
                if (_this.buffer[num2] != 255 && _this.buffer[num2] != 0)
                {
                    Assert.CannotBeReached(string.Concat(new object[]
                    {
                        "Corrupt cargo path rear! ", _this.id, " ", num2
                    }));
                    for (int i = num2; i >= 0; i--)
                    {
                        if (_this.buffer[i] == 246)
                        {
                            _this.buffer[i] = 0;
                            break;
                        }
                        _this.buffer[i] = 0;
                    }
                    _this.updateLen = _this.bufferLength;
                }
            }
            for (int j = _this.updateLen - 1; j >= 0; j--)
            {
                if (_this.buffer[j] == 0)
                {
                    break;
                }
                _this.updateLen--;
            }
            if (_this.updateLen == 0)
            {
                return(false);
            }
            int num3 = _this.updateLen;

            for (int k = _this.chunkCount - 1; k >= 0; k--)
            {
                int num4 = _this.chunks[k * 3];
                int num5 = _this.chunks[k * 3 + 2];
                if (num4 < num3)
                {
                    if (_this.buffer[num4] != 0)
                    {
                        for (int l = num4 - 5; l < num4 + 4; l++)
                        {
                            if (l >= 0)
                            {
                                if (_this.buffer[l] == 250)
                                {
                                    if (l < num4)
                                    {
                                        int num6 = l + 5 + 1;
                                        num4 = num6;
                                    }
                                    else
                                    {
                                        int num7 = l - 4;
                                        num4 = num7;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    int m = 0;
                    while (m < num5)
                    {
                        int num8 = num3 - num4;
                        if (num8 < 10)
                        {
                            break;
                        }
                        int num9 = 0;
                        for (int n = 0; n < num5 - m; n++)
                        {
                            int num10 = num3 - 1 - n;
                            if (num10 < 0 || num10 >= _this.buffer.Length)
                            {
                                break;
                            }
                            if (_this.buffer[num10] != 0)
                            {
                                break;
                            }
                            num9++;
                        }
                        if (num9 > 0)
                        {
                            if (num8 - num9 > 0)
                            {
                                Array.Copy(_this.buffer, num4, _this.buffer, num4 + num9, num8 - num9);
                            }
                            Array.Clear(_this.buffer, num4, num9);
                            m += num9;
                        }
                        for (int num11 = num3 - 1; num11 >= 0; num11--)
                        {
                            if (_this.buffer[num11] == 0)
                            {
                                break;
                            }
                            num3--;
                        }
                    }
                    int num12 = num4 + ((m != 0) ? m : 1);
                    if (num3 > num12)
                    {
                        num3 = num12;
                    }
                }
            }
            return(false);
        }