public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
 {
     Common.ReadObjectConn(c0, out bool isOut0, out int Belt0, out int slot0);
     Common.ReadObjectConn(c1, out bool isOut1, out int Belt1, out int slot1);
     Common.ReadObjectConn(c2, out bool isOut2, out int Belt2, out int slot2);
     Common.ReadObjectConn(c3, out bool isOut3, out int Belt3, out int slot3);
     if ((Belt0 == 0 || preIdMap.ContainsKey(Belt0)) &&
         (Belt1 == 0 || preIdMap.ContainsKey(Belt1)) &&
         (Belt2 == 0 || preIdMap.ContainsKey(Belt2)) &&
         (Belt3 == 0 || preIdMap.ContainsKey(Belt3)))
     {
         if (Belt0 > 0)
         {
             factory.WriteObjectConn(preId, 0, isOut0, preIdMap[Belt0].preId, isOut0 ? 1 : 0);
         }
         if (Belt1 > 0)
         {
             factory.WriteObjectConn(preId, 1, isOut1, preIdMap[Belt1].preId, isOut1 ? 1 : 0);
         }
         if (Belt2 > 0)
         {
             factory.WriteObjectConn(preId, 2, isOut2, preIdMap[Belt2].preId, isOut2 ? 1 : 0);
         }
         if (Belt3 > 0)
         {
             factory.WriteObjectConn(preId, 3, isOut3, preIdMap[Belt3].preId, isOut3 ? 1 : 0);
         }
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
 {
     Common.ReadObjectConn(c0, out bool isOut0, out int Belt0, out int slot0);
     Common.ReadObjectConn(c1, out bool isOut1, out int Belt1, out int slot1);
     Common.ReadObjectConn(c2, out bool isOut2, out int Belt2, out int slot2);
     if ((Belt1 == 0 || preIdMap.ContainsKey(Belt1)) &&
         (Belt2 == 0 || preIdMap.ContainsKey(Belt2)) &&
         (Belt0 == 0 || preIdMap.ContainsKey(Belt0)))
     {
         int fId = factory.entityPool[newEId].fractionateId;
         if (Belt0 > 0)
         {
             var d = preIdMap[Belt0];
             factory.WriteObjectConn(preId, 0, isOut0, d.preId, isOut0 ? 1 : 0);
         }
         if (Belt1 > 0)
         {
             var d = preIdMap[Belt1];
             factory.WriteObjectConn(preId, 1, isOut1, d.preId, isOut1 ? 1 : 0);
         }
         if (Belt2 > 0)
         {
             var d = preIdMap[Belt2];
             factory.WriteObjectConn(preId, 2, isOut2, d.preId, isOut2 ? 1 : 0);
         }
         return(true);
     }
     return(false);
 }
    public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
    {
        bool isMissing = false;

        for (int i = 0; i < slots.Length; i++)
        {
            int oldBeltId = slots[i].beltId;
            if (oldBeltId > 0 && preIdMap.ContainsKey(oldBeltId))
            {
                var other = preIdMap[oldBeltId];
                if (slots[i].dir == IODir.Input)
                {
                    factory.WriteObjectConn(preId, i, false, other.preId, 0);
                }
                else if (slots[i].dir == IODir.Output)
                {
                    factory.WriteObjectConn(preId, i, true, other.preId, 1);
                }
            }
            else
            {
                isMissing = true;
            }
        }
        return(!isMissing);
    }
 public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
 {
     Common.ReadObjectConn(conn0, out bool isOut1, out int Belt1, out int slot);
     Common.ReadObjectConn(conn1, out bool isOut2, out int Belt2, out int slot2);
     if (Belt1 == 0 || preIdMap.ContainsKey(Belt1))
     {
         if (Belt2 == 0 || preIdMap.ContainsKey(Belt2))
         {
             if (Belt1 > 0)
             {
                 factory.WriteObjectConn(preId, 0, isOut1, preIdMap[Belt1].preId, isOut1 ? 1 : 0);
             }
             if (Belt2 > 0)
             {
                 factory.WriteObjectConn(preId, 1, isOut2, preIdMap[Belt2].preId, isOut2 ? 1 : 0);
             }
             return(true);
         }
     }
     return(false);
 }
Beispiel #5
0
        public void ProcessPacket(NewSetInserterInsertTargetPacket packet, NebulaConnection conn)
        {
            PlanetFactory factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;

            if (factory != null)
            {
                FactoryManager.TargetPlanet = factory.planetId;
                factory.WriteObjectConn(packet.ObjId, 1, false, packet.OtherObjId, -1);
                factory.factorySystem.SetInserterInsertTarget(packet.InserterId, packet.OtherObjId, packet.Offset);
                factory.factorySystem.inserterPool[packet.InserterId].pos2 = packet.PointPos.ToVector3();
                FactoryManager.TargetPlanet = FactoryManager.PLANET_NONE;
            }
        }
        public void ProcessPacket(NewSetInserterPickTargetPacket packet, NebulaConnection conn)
        {
            PlanetFactory factory = GameMain.data.factories[packet.FactoryIndex];

            if (factory != null)
            {
                FactoryManager.TargetPlanet = factory.planetId;
                factory.WriteObjectConn(packet.ObjId, 1, false, packet.OtherObjId, -1);
                factory.factorySystem.SetInserterPickTarget(packet.InserterId, packet.OtherObjId, packet.Offset);
                factory.entityPool[packet.ObjId].pos = packet.PointPos.ToVector3();
                FactoryManager.TargetPlanet          = FactoryManager.PLANET_NONE;
            }
        }
 public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
 {
     if (nextLab == 0)
     {
         return(true);
     }
     if (nextLab > 0)
     {
         if (preIdMap.ContainsKey(nextLab))
         {
             factory.WriteObjectConn(preId, 15, true, preIdMap[nextLab].preId, 14);
             return(true);
         }
     }
     return(false);
 }
 public override bool ConnPreBelt(PlanetFactory factory, Dictionary <int, MyPreBuildData> preIdMap)
 {
     if (beltOut == 0 || preIdMap.ContainsKey(beltOut))
     {
         if (beltOut > 0 && preIdMap.ContainsKey(beltOut))
         {
             var other = preIdMap[beltOut];
             if (other.isBelt)
             {
                 int otherSlot = Common.FindEmtryPreBeltConn(factory, -other.preId, 1);
                 if (otherSlot > 0)
                 {
                     factory.WriteObjectConn(preId, 0, true, other.preId, otherSlot);
                 }
             }
         }
     }
     return(false);
 }
Beispiel #9
0
        public override void ProcessPacket(NewSetInserterPickTargetPacket packet, NebulaConnection conn)
        {
            PlanetFactory factory = GameMain.galaxy.PlanetById(packet.PlanetId)?.factory;

            if (factory != null)
            {
                Multiplayer.Session.Factories.TargetPlanet = factory.planetId;
                factory.WriteObjectConn(packet.ObjId, 1, false, packet.OtherObjId, -1);

                // setting specifyPlanet here to avoid accessing a null object (see GPUInstancingManager activePlanet getter)
                PlanetData pData = GameMain.gpuiManager.specifyPlanet;

                GameMain.gpuiManager.specifyPlanet = GameMain.galaxy.PlanetById(packet.PlanetId);
                factory.factorySystem.SetInserterPickTarget(packet.InserterId, packet.OtherObjId, packet.Offset);
                GameMain.gpuiManager.specifyPlanet = pData;

                factory.entityPool[packet.ObjId].pos       = packet.PointPos.ToVector3();
                Multiplayer.Session.Factories.TargetPlanet = NebulaModAPI.PLANET_NONE;
            }
        }
        public static void AfterPrebuild_Postfix(PlayerAction_Build __instance, PlanetFactory ___factory, PlanetAuxData ___planetAux, NearColliderLogic ___nearcdLogic)
        {
            // Do we have cached inserters?
            var ci = cachedInserters;

            if (CopyInserters.copyEnabled && ci.Count > 0 && !__instance.multiLevelCovering)
            {
                foreach (var cachedInserter in ci)
                {
                    var protoId    = cachedInserter.protoId;
                    var modelIndex = (short)LDB.items.Select(cachedInserter.protoId).ModelIndex;

                    foreach (BuildPreview buildPreview in __instance.buildPreviews)
                    {
                        var positionData = GetPositions(__instance, ___factory, ___planetAux, ___nearcdLogic, buildPreview, cachedInserter);

                        if (positionData.otherId != 0)
                        {
                            // Create inserter Prebuild data
                            var pbdata = new PrebuildData
                            {
                                protoId    = (short)protoId,
                                modelIndex = modelIndex,

                                insertOffset = positionData.insertOffset,
                                pickOffset   = positionData.pickOffset,
                                filterId     = cachedInserter.filterId,

                                refCount = cachedInserter.refCount,

                                pos  = positionData.absoluteInserterPos,
                                pos2 = positionData.absoluteInserterPos2,

                                rot  = positionData.absoluteInserterRot,
                                rot2 = positionData.absoluteInserterRot2
                            };


                            // Check the player has the item in inventory, no cheating here
                            var pc        = CopyInserters.pc;
                            var itemcount = pc.player.package.GetItemCount(protoId);
                            // If player has none; skip this request, as we dont create prebuild ghosts, must avoid confusion
                            if (itemcount > 0)
                            {
                                var qty = 1;
                                pc.player.package.TakeTailItems(ref protoId, ref qty);
                                int pbCursor = ___factory.AddPrebuildDataWithComponents(pbdata); // Add the inserter request to Prebuild pool

                                if (cachedInserter.incoming)
                                {
                                    ___factory.WriteObjectConn(-pbCursor, 0, true, buildPreview.objId, positionData.endSlot);      // assembler connection
                                    ___factory.WriteObjectConn(-pbCursor, 1, false, positionData.otherId, positionData.startSlot); // other connection
                                }
                                else
                                {
                                    ___factory.WriteObjectConn(-pbCursor, 0, false, buildPreview.objId, positionData.startSlot); // assembler connection
                                    ___factory.WriteObjectConn(-pbCursor, 1, true, positionData.otherId, positionData.endSlot);  // other connection
                                }
                            }
                        }
                    }
                }
            }
        }