public override void ProcessPacket(BeltUpdatePutItemOnPacket packet, NebulaConnection conn)
 {
     using (Multiplayer.Session.Factories.IsIncomingRequest.On())
     {
         CargoTraffic cargoTraffic = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic;
         if (cargoTraffic == null)
         {
             return;
         }
         if (packet.ItemCount == 1)
         {
             if (!cargoTraffic.PutItemOnBelt(packet.BeltId, packet.ItemId, packet.ItemInc))
             {
                 Log.Warn($"BeltUpdatePutItemOn: Cannot put item{packet.ItemId} on belt{packet.BeltId}, planet{packet.PlanetId}");
             }
         }
         else
         {
             bool ret = false;
             if (cargoTraffic.beltPool[packet.BeltId].id != 0 && cargoTraffic.beltPool[packet.BeltId].id == packet.BeltId)
             {
                 int index = cargoTraffic.beltPool[packet.BeltId].segIndex + cargoTraffic.beltPool[packet.BeltId].segPivotOffset;
                 ret = cargoTraffic.GetCargoPath(cargoTraffic.beltPool[packet.BeltId].segPathId).TryInsertItem(index, packet.ItemId, packet.ItemCount, packet.ItemInc);
             }
             if (!ret)
             {
                 Log.Warn($"BeltUpdatePutItemOn: Cannot put item{packet.ItemId} on belt{packet.BeltId}, planet{packet.PlanetId}");
             }
         }
     }
 }
示例#2
0
        public static bool SetBeltSelected(CargoTraffic __instance, int beltId)
        {
            int speed = __instance.beltPool[beltId].speed;

            if (speed == 12)
            {
                speed = 5;
            }
            __instance.SetBeltState(beltId, speed);
            return(false);
        }
示例#3
0
 public override void ProcessPacket(BeltSignalNumberPacket packet, NebulaConnection conn)
 {
     using (Multiplayer.Session.Factories.IsIncomingRequest.On())
     {
         CargoTraffic cargoTraffic = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic;
         if (cargoTraffic == null)
         {
             return;
         }
         cargoTraffic.SetBeltSignalNumber(packet.EntityId, packet.Number);
     }
 }
示例#4
0
 public override void ProcessPacket(ConnectToMonitorPacket packet, NebulaConnection conn)
 {
     using (Multiplayer.Session.Factories.IsIncomingRequest.On())
     {
         CargoTraffic cargoTraffic = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory?.cargoTraffic;
         if (cargoTraffic == null)
         {
             return;
         }
         cargoTraffic.ConnectToMonitor(packet.MonitorId, packet.BeltId, packet.Offset);
     }
 }
示例#5
0
        public static BeltRenderingBatch[] GetOrCreateBeltRenderingBatches(this CargoTraffic cargoTraffic)
        {
            var batches = GetBeltRenderingBatches(cargoTraffic);

            if (batches == null)
            {
                cargoTraffic.CreateRenderingBatches();
                batches = GetBeltRenderingBatches(cargoTraffic);
            }

            return(batches);
        }
示例#6
0
 public static bool InternalUpdate_Prefix(MonitorComponent __instance, CargoTraffic _traffic, EntityData[] _entityPool, SpeakerComponent[] _speakerPool, AnimData[] _animPool)
 {
     if (Multiplayer.IsActive && __instance.targetBeltId > _traffic.beltPool.Length)
     {
         if (Multiplayer.Session.LocalPlayer.IsHost)
         {
             _traffic.factory.RemoveEntityWithComponents(__instance.entityId);
             WarningManager.DisplayTemporaryWarning($"Broken Traffic Monitor detected on {_traffic.factory.planet.displayName}\nIt was removed, clients should reconnect!", 15000);
         }
         return(false);
     }
     return(true);
 }
示例#7
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);
                }
            }
        }
示例#8
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}");
                    }
                }
            }
        }
示例#10
0
        public static void FastDeleteEntities(PlanetFactory factory, List <int> targetIds, List <int> edgeIds)
        {
            Player player = GameMain.mainPlayer;

            using IDisposable toggle = UndoManager.IgnoreAllEvents.On();

            FactorySystem factorySystem = factory.factorySystem;
            CargoTraffic  cargoTraffic  = factory.cargoTraffic;
            PowerSystem   powerSystem   = factory.powerSystem;

            // Close all the build tools, so we don't have to worry about BuildTool.buildPreview
            foreach (BuildTool buildTool in player.controller.actionBuild.tools)
            {
                if (!(buildTool is DragRemoveBuildTool))
                {
                    buildTool._Close();
                }
            }

            powerConRemoval.Clear();

            if (powerConRemoval.Capacity < powerSystem.netCursor)
            {
                powerConRemoval.Capacity = powerSystem.netCursor;
            }

            // Close inspect
            player.controller.actionInspect.InspectNothing();

            for (int i = 0; i < powerSystem.netCursor; i++)
            {
                int maxConsumers = 10;
                if (powerSystem.netPool[i] != null)
                {
                    maxConsumers = powerSystem.netPool[i].consumers.Count;
                }

                powerConRemoval.Add(new HashSet <int>(maxConsumers));
            }

            foreach (int itemId in LDB.items.dataIndices.Keys)
            {
                takeBackCount[itemId] = 0;
                takeBackInc[itemId]   = 0;
            }

            PowerConsumerComponent[] consumerPool = powerSystem.consumerPool;
            InserterComponent[]      inserterPool = factorySystem.inserterPool;
            EntityData[]             entityPool   = factory.entityPool;

            void RemoveConsumerComponent(int id)
            {
                ref PowerConsumerComponent powerCon = ref consumerPool[id];

                if (powerCon.id != 0)
                {
                    if (powerCon.networkId >= powerConRemoval.Count)
                    {
                        //Debug.Log($"Power Net: {powerCon.networkId} is not in the list");
                        return;
                    }

                    if (powerConRemoval[powerCon.networkId].Contains(id))
                    {
                        return;
                    }

                    powerConRemoval[powerCon.networkId].Add(id);
                    powerCon.SetEmpty();
                    powerSystem.consumerRecycle[powerSystem.consumerRecycleCursor] = id;
                    powerSystem.consumerRecycleCursor++;
                }
            }
示例#11
0
        public static bool TankGameTickPatch(ref TankComponent __instance, PlanetFactory factory)
        {
            if (!__instance.isBottom)
            {
                return(false);
            }

            //添加对不同液体的分别设置

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

            if (HOverFlow.Value)
            {
                SpecialFluid.Add(1120);
            }
            if (ROilOverFlow.Value)
            {
                SpecialFluid.Add(1114);
            }
            if (DOverFlow.Value)
            {
                SpecialFluid.Add(1121);
            }
            if (SulOverFlow.Value)
            {
                SpecialFluid.Add(1116);
            }
            if (WaterOverFlow.Value)
            {
                SpecialFluid.Add(1000);
            }
            if (OilOverFlow.Value)
            {
                SpecialFluid.Add(1007);
            }

            CargoTraffic   cargoTraffic   = factory.cargoTraffic;
            FactoryStorage factoryStorage = factory.factoryStorage;

            if (__instance.belt0 > 0)
            {
                if (__instance.isOutput0 && __instance.outputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt0, __instance.fluidId))
                    {
                        __instance.currentCount--;
                    }
                }
                else if (!__instance.isOutput0 && __instance.inputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0)
                    {
                        __instance.currentCount++;
                    }
                    else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0)
                    {
                    }
                    if (__instance.fluidId == 0)
                    {
                        int num = cargoTraffic.TryPickItemAtRear(__instance.belt0, 0, ItemProto.fluids);
                        if (num > 0)
                        {
                            __instance.fluidId = num;
                            __instance.currentCount++;
                        }
                    }
                    if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt0) == __instance.fluidId && __instance.nextTankId > 0)
                    {
                        TankComponent tankComponent  = factoryStorage.tankPool[__instance.nextTankId];
                        TankComponent tankComponent2 = tankComponent;
                        while (tankComponent.currentCount >= tankComponent.fluidStorageCount)
                        {
                            if (!tankComponent.inputSwitch)
                            {
                                tankComponent2 = factoryStorage.tankPool[tankComponent2.lastTankId];
                                break;
                            }
                            if (tankComponent.nextTankId <= 0)
                            {
                                tankComponent2.id = __instance.id;
                                break;
                            }
                            tankComponent  = factoryStorage.tankPool[tankComponent.nextTankId];
                            tankComponent2 = tankComponent;
                        }
                        if (!tankComponent2.inputSwitch)
                        {
                            tankComponent2 = factoryStorage.tankPool[tankComponent2.lastTankId];
                        }
                        bool          flag           = true;
                        TankComponent tankComponent3 = factoryStorage.tankPool[tankComponent2.lastTankId];
                        if (((tankComponent2.id == __instance.id || tankComponent2.currentCount >= tankComponent2.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent3.outputSwitch)
                        {
                            flag = false;
                        }
                        if (flag && cargoTraffic.TryPickItemAtRear(__instance.belt0, __instance.fluidId, null) > 0)
                        {
                            if (factoryStorage.tankPool[tankComponent2.id].currentCount == 0)
                            {
                                factoryStorage.tankPool[tankComponent2.id].fluidId = __instance.fluidId;
                            }
                            TankComponent[] tankPool = factoryStorage.tankPool;
                            int             num2     = tankComponent2.id;
                            tankPool[num2].currentCount = tankPool[num2].currentCount + 1;
                            if (tankPool[num2].currentCount > tankPool[num2].fluidStorageCount)
                            {
                                tankPool[num2].currentCount = tankPool[num2].fluidStorageCount;
                            }
                        }
                    }
                }
            }
            if (__instance.belt1 > 0)
            {
                if (__instance.isOutput1 && __instance.outputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt1, __instance.fluidId))
                    {
                        __instance.currentCount--;
                    }
                }
                else if (!__instance.isOutput1 && __instance.inputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0)
                    {
                        __instance.currentCount++;
                    }
                    else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0)
                    {
                    }
                    if (__instance.fluidId == 0)
                    {
                        int num3 = cargoTraffic.TryPickItemAtRear(__instance.belt1, 0, ItemProto.fluids);
                        if (num3 > 0)
                        {
                            __instance.fluidId = num3;
                            __instance.currentCount++;
                        }
                    }
                    if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt1) == __instance.fluidId && __instance.nextTankId > 0)
                    {
                        TankComponent tankComponent4 = factoryStorage.tankPool[__instance.nextTankId];
                        TankComponent tankComponent5 = tankComponent4;
                        while (tankComponent4.currentCount >= tankComponent4.fluidStorageCount)
                        {
                            if (!tankComponent4.inputSwitch)
                            {
                                tankComponent5 = factoryStorage.tankPool[tankComponent5.lastTankId];
                                break;
                            }
                            if (tankComponent4.nextTankId <= 0)
                            {
                                tankComponent5.id = __instance.id;
                                break;
                            }
                            tankComponent4 = factoryStorage.tankPool[tankComponent4.nextTankId];
                            tankComponent5 = tankComponent4;
                        }
                        if (!tankComponent5.inputSwitch)
                        {
                            tankComponent5 = factoryStorage.tankPool[tankComponent5.lastTankId];
                        }
                        bool          flag2          = true;
                        TankComponent tankComponent6 = factoryStorage.tankPool[tankComponent5.lastTankId];
                        if (((tankComponent5.id == __instance.id || tankComponent5.currentCount >= tankComponent5.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent6.outputSwitch)
                        {
                            flag2 = false;
                        }
                        if (flag2 && cargoTraffic.TryPickItemAtRear(__instance.belt1, __instance.fluidId, null) > 0)
                        {
                            if (factoryStorage.tankPool[tankComponent5.id].currentCount == 0)
                            {
                                factoryStorage.tankPool[tankComponent5.id].fluidId = __instance.fluidId;
                            }
                            TankComponent[] tankPool2 = factoryStorage.tankPool;
                            int             num4      = tankComponent5.id;
                            tankPool2[num4].currentCount = tankPool2[num4].currentCount + 1;
                            if (tankPool2[num4].currentCount > tankPool2[num4].fluidStorageCount)
                            {
                                tankPool2[num4].currentCount = tankPool2[num4].fluidStorageCount;
                            }
                        }
                    }
                }
            }
            if (__instance.belt2 > 0)
            {
                if (__instance.isOutput2 && __instance.outputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt2, __instance.fluidId))
                    {
                        __instance.currentCount--;
                    }
                }
                else if (!__instance.isOutput2 && __instance.inputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0)
                    {
                        __instance.currentCount++;
                    }
                    else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0)
                    {
                    }
                    if (__instance.fluidId == 0)
                    {
                        int num5 = cargoTraffic.TryPickItemAtRear(__instance.belt2, 0, ItemProto.fluids);
                        if (num5 > 0)
                        {
                            __instance.fluidId = num5;
                            __instance.currentCount++;
                        }
                    }
                    if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt2) == __instance.fluidId && __instance.nextTankId > 0)
                    {
                        TankComponent tankComponent7 = factoryStorage.tankPool[__instance.nextTankId];
                        TankComponent tankComponent8 = tankComponent7;
                        while (tankComponent7.currentCount >= tankComponent7.fluidStorageCount)
                        {
                            if (!tankComponent7.inputSwitch)
                            {
                                tankComponent8 = factoryStorage.tankPool[tankComponent8.lastTankId];
                                break;
                            }
                            if (tankComponent7.nextTankId <= 0)
                            {
                                tankComponent8.id = __instance.id;
                                break;
                            }
                            tankComponent7 = factoryStorage.tankPool[tankComponent7.nextTankId];
                            tankComponent8 = tankComponent7;
                        }
                        if (!tankComponent8.inputSwitch)
                        {
                            tankComponent8 = factoryStorage.tankPool[tankComponent8.lastTankId];
                        }
                        bool          flag3          = true;
                        TankComponent tankComponent9 = factoryStorage.tankPool[tankComponent8.lastTankId];
                        if (((tankComponent8.id == __instance.id || tankComponent8.currentCount >= tankComponent8.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent9.outputSwitch)
                        {
                            flag3 = false;
                        }
                        if (flag3 && cargoTraffic.TryPickItemAtRear(__instance.belt2, __instance.fluidId, null) > 0)
                        {
                            if (factoryStorage.tankPool[tankComponent8.id].currentCount == 0)
                            {
                                factoryStorage.tankPool[tankComponent8.id].fluidId = __instance.fluidId;
                            }
                            TankComponent[] tankPool3 = factoryStorage.tankPool;
                            int             num6      = tankComponent8.id;
                            tankPool3[num6].currentCount = tankPool3[num6].currentCount + 1;
                            if (tankPool3[num6].currentCount > tankPool3[num6].fluidStorageCount)
                            {
                                tankPool3[num6].currentCount = tankPool3[num6].fluidStorageCount;
                            }
                        }
                    }
                }
            }
            if (__instance.belt3 > 0)
            {
                if (__instance.isOutput3 && __instance.outputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount <= __instance.fluidStorageCount && __instance.currentCount > 0 && cargoTraffic.TryInsertItemAtHead(__instance.belt3, __instance.fluidId))
                    {
                        __instance.currentCount--;
                    }
                }
                else if (!__instance.isOutput3 && __instance.inputSwitch)
                {
                    if (__instance.fluidId > 0 && __instance.currentCount < __instance.fluidStorageCount && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0)
                    {
                        __instance.currentCount++;
                    }
                    else if (__instance.fluidId > 0 && __instance.currentCount >= __instance.fluidStorageCount && SpecialFluid.Contains(__instance.fluidId) && __instance.nextTankId <= 0 && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0)
                    {
                    }
                    if (__instance.fluidId == 0)
                    {
                        int num7 = cargoTraffic.TryPickItemAtRear(__instance.belt3, 0, ItemProto.fluids);
                        if (num7 > 0)
                        {
                            __instance.fluidId = num7;
                            __instance.currentCount++;
                        }
                    }
                    if (__instance.currentCount >= __instance.fluidStorageCount && cargoTraffic.GetItemIdAtRear(__instance.belt3) == __instance.fluidId && __instance.nextTankId > 0)
                    {
                        TankComponent tankComponent10 = factoryStorage.tankPool[__instance.nextTankId];
                        TankComponent tankComponent11 = tankComponent10;
                        while (tankComponent10.currentCount >= tankComponent10.fluidStorageCount)
                        {
                            if (!tankComponent10.inputSwitch)
                            {
                                tankComponent11 = factoryStorage.tankPool[tankComponent11.lastTankId];
                                break;
                            }
                            if (tankComponent10.nextTankId <= 0)
                            {
                                tankComponent11.id = __instance.id;
                                break;
                            }
                            tankComponent10 = factoryStorage.tankPool[tankComponent10.nextTankId];
                            tankComponent11 = tankComponent10;
                        }
                        if (!tankComponent11.inputSwitch)
                        {
                            tankComponent11 = factoryStorage.tankPool[tankComponent11.lastTankId];
                        }
                        bool          flag4           = true;
                        TankComponent tankComponent12 = factoryStorage.tankPool[tankComponent11.lastTankId];
                        if (((tankComponent11.id == __instance.id || tankComponent11.currentCount >= tankComponent11.fluidStorageCount) && !SpecialFluid.Contains(__instance.fluidId)) || !tankComponent12.outputSwitch)
                        {
                            flag4 = false;
                        }
                        if (flag4 && cargoTraffic.TryPickItemAtRear(__instance.belt3, __instance.fluidId, null) > 0)
                        {
                            if (factoryStorage.tankPool[tankComponent11.id].currentCount == 0)
                            {
                                factoryStorage.tankPool[tankComponent11.id].fluidId = __instance.fluidId;
                            }
                            TankComponent[] tankPool4 = factoryStorage.tankPool;
                            int             num8      = tankComponent11.id;
                            tankPool4[num8].currentCount = tankPool4[num8].currentCount + 1;
                            if (tankPool4[num8].currentCount > tankPool4[num8].fluidStorageCount)
                            {
                                tankPool4[num8].currentCount = tankPool4[num8].fluidStorageCount;
                            }
                        }
                    }
                }
            }
            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);
        }