Exemplo n.º 1
0
 public static void UpdateSlotData(ILSUpdateSlotData packet)
 {
     // PLS
     if (packet.PlanetId != 0)
     {
         PlanetData pData = GameMain.galaxy.PlanetById(packet.PlanetId);
         if (pData?.factory?.transport != null && packet.StationGId < pData.factory.transport.stationPool.Length)
         {
             StationComponent stationComponent = pData.factory.transport.stationPool[packet.StationGId];
             if (stationComponent != null && stationComponent.slots != null)
             {
                 stationComponent.slots[packet.Index].storageIdx = packet.StorageIdx;
             }
         }
     }
     else // ILS
     {
         if (packet.StationGId < GameMain.data.galacticTransport.stationPool.Length)
         {
             StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.StationGId];
             if (stationComponent != null && stationComponent.slots != null)
             {
                 stationComponent.slots[packet.Index].storageIdx = packet.StorageIdx;
             }
         }
     }
 }
 public override void ProcessPacket(RemoteOrderUpdate packet, NebulaConnection conn)
 {
     if (IsHost)
     {
         StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.StationGId];
         StationStore[]   storage          = stationComponent?.storage;
         if (stationComponent == null || storage == null)
         {
             return;
         }
         int[] remoteOrder = new int[storage.Length];
         for (int i = 0; i < stationComponent.storage.Length; i++)
         {
             remoteOrder[i] = storage[i].remoteOrder;
         }
         packet.RemoteOrder = remoteOrder;
         conn.SendPacket(packet);
     }
     if (IsClient)
     {
         StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.StationGId];
         StationStore[]   storage          = stationComponent?.storage;
         if (stationComponent == null || storage == null)
         {
             return;
         }
         for (int i = 0; i < storage.Length; i++)
         {
             storage[i].remoteOrder = packet.RemoteOrder[i];
         }
     }
 }
Exemplo n.º 3
0
        public static void AddWarperRequestToLastSlot(
            this StationComponent component,
            PlanetTransport planetTransport
            )
        {
            if (!component.isStellar)
            {
                return;
            }
            if (!AspConfig.ILS.WarperInLastItemSlot.Value)
            {
                return;
            }
            if (component.HasItemInAnySlot(ItemIds.Warper))
            {
                return;
            }

            planetTransport.SetStationStorage(
                component.id,
                component.storage.Length - 1,
                ItemIds.Warper,
                AspConfig.ILS.WarperDemand.Value * 100,
                AspConfig.ILS.WarperLocalMode.Value,
                AspConfig.ILS.WarperRemoteMode.Value,
                GameMain.mainPlayer
                );

            planetTransport.gameData.galacticTransport.RefreshTraffic(component.gid);
        }
Exemplo n.º 4
0
        // ReSharper disable once RedundantAssignment
        public static bool AddItemPrefix(StationComponent __instance, int itemId, int count, int inc, ref int __result)
        {
            __result = 0;
            if (itemId <= 0)
            {
                return(false);
            }

            StationStore[] obj = __instance.storage;
            lock (obj)
            {
                for (int i = 0; i < __instance.storage.Length; i++)
                {
                    if (__instance.storage[i].itemId != itemId)
                    {
                        continue;
                    }

                    StationStore[] array = __instance.storage;
                    array[i].count += count;
                    array[i].inc   += inc;

                    __result = count;
                    return(false);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        [HarmonyPatch(typeof(StationComponent), "Init")]                                                                                                                               // maybe swap with normal VFPreload if not supporting modded tesla towers? or later preloadpostpatch LDBTool one again if already done
        public static void StationComponentInitPostfix(StationComponent __instance, ref int _id, ref int _entityId, ref int _pcId, ref PrefabDesc _desc, ref EntityData[] _entityPool) // Do when LDB is done
        {
            __instance.needs = new int[13];

            if (_entityPool[_entityId].protoId != GigaStationsPlugin.ils.ID && _entityPool[_entityId].protoId != GigaStationsPlugin.pls.ID && _entityPool[_entityId].protoId != GigaStationsPlugin.collector.ID) // not my stations
            {
                return;
            }

            if (!__instance.isStellar && !__instance.isCollector) //pls
            {
                _desc.stationMaxEnergyAcc = Convert.ToInt64(GigaStationsPlugin.plsMaxAcuMJ * 1000000);
                __instance.energyMax      = GigaStationsPlugin.plsMaxAcuMJ * 1000000;
                __instance.storage        = new StationStore[GigaStationsPlugin.plsMaxSlots];
                __instance.energyPerTick  = 1000000;
            }
            else if (__instance.isStellar && !__instance.isCollector)
            {
                _desc.stationMaxEnergyAcc = Convert.ToInt64(GigaStationsPlugin.ilsMaxAcuGJ * 1000000000);

                __instance.energyMax      = GigaStationsPlugin.ilsMaxAcuGJ * 1000000000;
                __instance.warperMaxCount = GigaStationsPlugin.ilsMaxWarps;
                __instance.storage        = new StationStore[GigaStationsPlugin.ilsMaxSlots];
                __instance.energyPerTick  = 1000000;
            }
        }
Exemplo n.º 6
0
        public static void AddWarperRequestToLastSlot(
            this StationComponent component,
            PlanetTransport planetTransport
            )
        {
            if (!component.isStellar)
            {
                return;
            }
            if (!Config.ILS.WarperInLastItemSlot.Value)
            {
                return;
            }

            planetTransport.SetStationStorage(
                component.id,
                component.storage.Length - 1,
                1210, // Item ID for Warpers
                100,
                Config.ILS.WarperLocalMode.Value,
                Config.ILS.WarperRemoteMode.Value,
                GameMain.mainPlayer.package
                );

            planetTransport.gameData.galacticTransport.RefreshTraffic(component.gid);
        }
Exemplo n.º 7
0
        public static bool FixDuplicateWarperStores(this StationComponent component, int stationId, PlanetFactory factory)
        {
            if (!component.isStellar)
            {
                return(false);
            }

            var duplicateStores = component.storage
                                  .Select((storage, idx) => new KeyValuePair <int, StationStore>(idx, storage))
                                  .Where(kv => kv.Value.itemId == ItemIds.Warper)
                                  .Skip(1)
                                  .ToArray();

            if (duplicateStores.Length < 1)
            {
                return(false);
            }

            foreach (var kv in duplicateStores)
            {
                factory.transport.SetStationStorage(
                    stationId,
                    kv.Key,
                    0,
                    0,
                    ELogisticStorage.None,
                    ELogisticStorage.None,
                    factory.gameData.mainPlayer
                    );
            }

            factory.transport.RefreshTraffic();
            return(true);
        }
Exemplo n.º 8
0
        public static bool CollectPatch(ref StationComponent __instance, float collectSpeedRate, int[] productRegister)
        {
            var _this = __instance;

            if (_this.collectionPerTick == null)
            {
                return(false);
            }
            for (int i = 0; i < _this.collectionIds.Length; i++)
            {
                if (_this.storage[i].count < _this.storage[i].max)
                {
                    _this.currentCollections[i] += _this.collectionPerTick[i] * collectSpeedRate;
                    int num = (int)_this.currentCollections[i];
                    if (_this.storage[i].max == 10000)
                    {
                        if (i == 0)
                        {
                            num = 0;
                        }
                    }
                    StationStore[] array = _this.storage;
                    int            num2  = i;
                    array[num2].count = array[num2].count + num;
                    productRegister[_this.storage[i].itemId] += num;
                    _this.currentCollections[i] -= (float)num;
                }
            }

            return(false);
        }
        public override void ProcessPacket(ILSUpdateSlotData packet, NebulaConnection conn)
        {
            if (IsHost)
            {
                PlanetData pData = null;
                // PLS
                if (packet.StationGId == 0)
                {
                    pData = GameMain.galaxy.PlanetById(packet.PlanetId);
                }
                else // ILS
                {
                    if (packet.StationGId < GameMain.data.galacticTransport.stationPool.Length)
                    {
                        StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.StationGId];
                        if (stationComponent != null)
                        {
                            pData = GameMain.galaxy.PlanetById(stationComponent.planetId);
                        }
                    }
                }

                if (pData != null)
                {
                    playerManager.SendPacketToStar(packet, pData.star.id);
                }

                Multiplayer.Session.Ships.UpdateSlotData(packet);
            }

            if (IsClient)
            {
                Multiplayer.Session.Ships.UpdateSlotData(packet);
            }
        }
Exemplo n.º 10
0
        public void ProcessPacket(ILSShipDock packet, NebulaConnection conn)
        {
            // a fake entry should already have been created
            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGId];

            stationComponent.shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);
            stationComponent.shipDockRot = DataStructureExtensions.ToQuaternion(packet.shipDockRot);

            for (int i = 0; i < ILSShipManager.ILSMaxShipCount; i++)
            {
                stationComponent.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)ILSShipManager.ILSMaxShipCount * (float)i, 0f);
                stationComponent.shipDiskPos[i] = stationComponent.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f);
            }
            for (int j = 0; j < ILSShipManager.ILSMaxShipCount; j++)
            {
                stationComponent.shipDiskRot[j] = stationComponent.shipDockRot * stationComponent.shipDiskRot[j];
                stationComponent.shipDiskPos[j] = stationComponent.shipDockPos + stationComponent.shipDockRot * stationComponent.shipDiskPos[j];
            }

            // sync the current position of the ships as they might have been calculated wrong while we did not have the correct dock position and rotation.
            for (int i = 0; i < packet.shipOtherGId.Length; i++)
            {
                stationComponent = GameMain.data.galacticTransport.stationPool[packet.shipOtherGId[i]];

                stationComponent.workShipDatas[packet.shipIndex[i]].uPos     = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].uRot     = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pPosTemp = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pRotTemp = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);
            }
        }
Exemplo n.º 11
0
        public override void Update(float frameTime)
        {
            base.Update(frameTime);

            if (!Started || !Running)
            {
                return;
            }

            _timeUntilPulse -= frameTime;

            if (_timeUntilPulse <= 0.0f)
            {
                var mapManager = IoCManager.Resolve <IMapManager>();
                // Account for split stations by just randomly picking a piece of it.
                var possibleTargets = _entityManager.EntityQuery <StationComponent>()
                                      .Where(x => x.Station == _target).ToArray();
                StationComponent tempQualifier = _robustRandom.Pick(possibleTargets);
                var stationEnt = (tempQualifier).Owner;

                if (!_entityManager.TryGetComponent <IMapGridComponent>(stationEnt, out var grid))
                {
                    return;
                }

                if (mapManager.IsGridPaused(grid.GridIndex))
                {
                    return;
                }

                SpawnPulse(grid.Grid);
            }
        }
Exemplo n.º 12
0
        /*
         * This is triggered by server and either adds or removes items to an ILS caused by a ship transport.
         * Also update the remoteOrder value to reflect the changes
         */
        public static void AddTakeItem(ILSShipItems packet)
        {
            if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient || GameMain.data.galacticTransport.stationPool.Length <= packet.stationGID)
            {
                return;
            }

            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGID];

            if (stationComponent != null && stationComponent.gid == packet.stationGID && stationComponent.storage != null)
            {
                if (packet.addItem)
                {
                    stationComponent.AddItem(packet.itemId, packet.itemCount);
                    for (int i = 0; i < stationComponent.storage.Length; i++)
                    {
                        if (stationComponent.storage[i].itemId == packet.itemId)
                        {
                            stationComponent.storage[i].remoteOrder -= packet.itemCount;
                            RefreshValuesUI(stationComponent, i);
                            break;
                        }
                    }
                }
                else
                {
                    int itemId    = packet.itemId;
                    int itemCount = packet.itemCount;
                    stationComponent.TakeItem(ref itemId, ref itemCount);
                    // TODO: Update remote order here (issue #230)
                }
            }
        }
Exemplo n.º 13
0
        private static void UninstallMod(PlanetTransport instance, PrefabDesc prefabDesc, int warperId)
        {
            int warperSlotIndex = prefabDesc.stationMaxItemKinds;

            for (int j = 1; j < instance.stationCursor; j++)
            {
                if (instance.stationPool[j] != null && instance.stationPool[j].id == j)
                {
                    StationComponent stationComponent = instance.stationPool[j];
                    if (stationComponent.isCollector == true || stationComponent.isStellar == false)
                    {
                        continue;
                    }
                    if (stationComponent.storage.Length > prefabDesc.stationMaxItemKinds &&
                        stationComponent.storage.Last().itemId == warperId)
                    {
                        instance.SetStationStorage(
                            stationComponent.id,
                            warperSlotIndex,
                            0, 0,
                            ELogisticStorage.None,
                            ELogisticStorage.None,
                            GameMain.mainPlayer);
                        List <StationStore> storeCopy = new List <StationStore>(stationComponent.storage);
                        storeCopy.RemoveAt(warperSlotIndex);
                        stationComponent.storage = storeCopy.ToArray();
                    }
                    instance.RefreshTraffic();
                    instance.gameData.galacticTransport.RefreshTraffic(stationComponent.gid);
                    stationComponent.UpdateNeeds();
                }
            }
        }
Exemplo n.º 14
0
        private static void UpdateStorageUI(StationUI packet)
        {
            StationComponent stationComponent = null;
            PlanetData       planet           = GameMain.galaxy?.PlanetById(packet.PlanetId);

            // If we can't find planet or the factory for said planet, we can just skip this
            if (planet?.factory?.transport == null)
            {
                return;
            }

            StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
            StationComponent[] stationPool  = planet?.factory?.transport?.stationPool;

            stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId];

            if (stationComponent == null)
            {
                Log.Error($"UpdateStorageUI: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}");
                return;
            }

            using (ILSShipManager.PatchLockILS.On())
            {
                planet.factory.transport.SetStationStorage(stationComponent.id, packet.StorageIdx, packet.ItemId, packet.ItemCountMax, packet.LocalLogic, packet.RemoteLogic, (packet.ShouldMimic == true) ? GameMain.mainPlayer : null);
            }
        }
Exemplo n.º 15
0
        public static void OnStationIdChangePre(UIStationWindow __instance, ref string __state)
        {
            if (__instance.stationId == 0 || __instance.factory == null || __instance.transport?.stationPool == null)
            {
                return;
            }

            StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId];

            ItemProto itemProto = LDB.items.Select(__instance.factory.entityPool[stationComponent.entityId].protoId);

            if (itemProto.ID != GigaStationsPlugin.pls.ID && itemProto.ID != GigaStationsPlugin.ils.ID && itemProto.ID != GigaStationsPlugin.collector.ID)
            {
                return;
            }

            if (!__instance.active)
            {
                return;
            }

            string text = (!string.IsNullOrEmpty(stationComponent.name))
                ? stationComponent.name
                : ((!stationComponent.isStellar)
                    ? ("Planetary Giga Station #" + stationComponent.id)
                    : ((stationComponent.isCollector)
                        ? ("Orbital Giga Collector #" + stationComponent.gid)
                        : ("Interstellar Giga Station #" + stationComponent.gid)));

            __state = text;
        }
        public override void ProcessPacket(StationUIInitialSyncRequest packet, NebulaConnection conn)
        {
            if (IsClient)
            {
                return;
            }

            StationComponent stationComponent = null;

            StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
            StationComponent[] stationPool  = GameMain.data.galaxy?.PlanetById(packet.PlanetId)?.factory?.transport?.stationPool;

            stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId];

            if (stationComponent == null)
            {
                Log.Error($"StationUIInitialSyncRequestProcessor: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}");
                return;
            }

            StationStore[] storage = stationComponent.storage;

            int[] itemId       = new int[storage.Length];
            int[] itemCountMax = new int[storage.Length];
            int[] itemCount    = new int[storage.Length];
            int[] localLogic   = new int[storage.Length];
            int[] remoteLogic  = new int[storage.Length];
            int[] remoteOrder  = new int[storage.Length];

            for (int i = 0; i < stationComponent.storage.Length; i++)
            {
                itemId[i]       = storage[i].itemId;
                itemCountMax[i] = storage[i].max;
                itemCount[i]    = storage[i].count;
                localLogic[i]   = (int)storage[i].localLogic;
                remoteLogic[i]  = (int)storage[i].remoteLogic;
                remoteOrder[i]  = storage[i].remoteOrder;
            }

            conn.SendPacket(new StationUIInitialSync(
                                packet.PlanetId,
                                packet.StationId,
                                packet.StationGId,
                                stationComponent.tripRangeDrones,
                                stationComponent.tripRangeShips,
                                stationComponent.deliveryDrones,
                                stationComponent.deliveryShips,
                                stationComponent.warpEnableDist,
                                stationComponent.warperNecessary,
                                stationComponent.includeOrbitCollector,
                                stationComponent.energy,
                                stationComponent.energyPerTick,
                                itemId,
                                itemCountMax,
                                itemCount,
                                localLogic,
                                remoteLogic,
                                remoteOrder
                                ));
        }
Exemplo n.º 17
0
        public static void _OnOpen_Postfix(UIStationWindow __instance)
        {
            if (!Multiplayer.IsActive || __instance.transport == null)
            {
                return;
            }

            StationComponent stationComponent = __instance.transport.stationPool[__instance.stationId];

            Multiplayer.Session.StationsUI.SliderBarPacket    = new StationUI(__instance.factory.planet.id, stationComponent.id, stationComponent.gid, StationUI.EUISettings.None, 0);
            Multiplayer.Session.StationsUI.StorageMaxChangeId = -1;
            if (Multiplayer.Session.LocalPlayer.IsHost)
            {
                return;
            }
            lastUpdateGametick = GameMain.gameTick;

            // Stage 0 : Hide UI elements until sync data arrive
            __instance.titleText.text = "Loading...";
            for (int i = 0; i < __instance.storageUIs.Length; i++)
            {
                __instance.storageUIs[i]._Close();
                __instance.storageUIs[i].ClosePopMenu();
            }
            __instance.panelDown.SetActive(false);

            // for some reason advance miner has planetId set to 0, so we use UI's factory planetId
            Multiplayer.Session.Network.SendPacket(new StationUIInitialSyncRequest(__instance.factory.planetId, stationComponent.id, stationComponent.gid));
        }
Exemplo n.º 18
0
        public void ProcessPacket(ILSShipDock packet, NebulaConnection conn)
        {
            // a fake entry should already have been created
            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.stationGId];

            stationComponent.shipDockPos = DataStructureExtensions.ToVector3(packet.shipDockPos);
            stationComponent.shipDockRot = DataStructureExtensions.ToQuaternion(packet.shipDockRot);

            for (int i = 0; i < 10; i++)
            {
                stationComponent.shipDiskRot[i] = Quaternion.Euler(0f, 360f / (float)10 * (float)i, 0f);
                stationComponent.shipDiskPos[i] = stationComponent.shipDiskRot[i] * new Vector3(0f, 0f, 11.5f);
            }
            for (int j = 0; j < 10; j++)
            {
                stationComponent.shipDiskRot[j] = stationComponent.shipDockRot * stationComponent.shipDiskRot[j];
                stationComponent.shipDiskPos[j] = stationComponent.shipDockPos + stationComponent.shipDockRot * stationComponent.shipDiskPos[j];
            }

            for (int i = 0; i < packet.shipOtherGId.Length; i++)
            {
                stationComponent = GameMain.data.galacticTransport.stationPool[packet.shipOtherGId[i]];

                stationComponent.workShipDatas[packet.shipIndex[i]].uPos     = DataStructureExtensions.ToVectorLF3(packet.shipPos[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].uRot     = DataStructureExtensions.ToQuaternion(packet.shipRot[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pPosTemp = DataStructureExtensions.ToVectorLF3(packet.shipPPosTemp[i]);
                stationComponent.workShipDatas[packet.shipIndex[i]].pRotTemp = DataStructureExtensions.ToQuaternion(packet.shipPRotTemp[i]);
            }
        }
Exemplo n.º 19
0
        /*
         * this is also triggered by server and called once a ship lands back to the dock station
         */
        public static void WorkShipBackToIdle(ILSShipData packet)
        {
            if (!SimulatedWorld.Initialized || LocalPlayer.IsMasterClient)
            {
                return;
            }

            if (GameMain.data.galacticTransport.stationCapacity <= packet.planetAStationGID)
            {
                CreateFakeStationComponent(packet.planetAStationGID, packet.planetA);
            }
            else if (GameMain.data.galacticTransport.stationPool[packet.planetAStationGID] == null)
            {
                CreateFakeStationComponent(packet.planetAStationGID, packet.planetA);
            }
            else if (GameMain.data.galacticTransport.stationPool[packet.planetAStationGID].shipDockPos == Vector3.zero)
            {
                RequestgStationDockPos(packet.planetAStationGID);
            }

            StationComponent stationComponent = GameMain.data.galacticTransport.stationPool[packet.planetAStationGID];

            Array.Copy(stationComponent.workShipDatas, packet.origShipIndex + 1, stationComponent.workShipDatas, packet.origShipIndex, stationComponent.workShipDatas.Length - packet.origShipIndex - 1);
            stationComponent.workShipCount--;
            stationComponent.idleShipCount++;
            if (stationComponent.idleShipCount < 0)
            {
                stationComponent.idleShipCount = 0;
            }
            if (stationComponent.workShipCount > ILSMaxShipCount)
            {
                stationComponent.workShipCount = ILSMaxShipCount;
            }
            stationComponent.WorkShipBackToIdle(packet.origShipIndex);
        }
Exemplo n.º 20
0
        public static void NewStationComponent(
            PlanetTransport __instance,
            StationComponent __result
            )
        {
            var component = __result;

            if (component.isCollector)
            {
                return;
            }

            var planetTransport = __instance;
            var itemProto       = LDB.items.Select(planetTransport.factory.entityPool[component.entityId].protoId);
            var prefabDesc      = itemProto.prefabDesc;

            component.SetChargingPower(planetTransport, prefabDesc);
            component.SetTransportRanges();
            component.SetTransportLoads();
            component.AddDronesFromInventory(prefabDesc);

            // Extra configuration if ILS.
            if (!component.isStellar)
            {
                return;
            }
            component.SetToggles();
            component.SetMinWarpDistance();
            component.AddVesselsFromInventory(prefabDesc);
            component.AddWarperRequestToLastSlot(planetTransport);
        }
Exemplo n.º 21
0
 public static void SetToggles(
     this StationComponent component
     )
 {
     component.warperNecessary       = AspConfig.ILS.MustEquipWarp.Value;
     component.includeOrbitCollector = AspConfig.ILS.UseOrbitalCollectors.Value;
 }
Exemplo n.º 22
0
        public void ProcessPacket(StationUIInitialSync packet, NebulaConnection conn)
        {
            StationComponent[] gStationPool = null;
            if (packet.planetId == 0)
            {
                gStationPool = GameMain.data.galacticTransport.stationPool;
            }
            else
            {
                PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId);
                if (pData?.factory?.transport != null)
                {
                    gStationPool = pData.factory.transport.stationPool;
                }
            }
            if (gStationPool != null && gStationPool.Length > packet.stationGId && StationUIManager.UIIsSyncedStage == 1)
            {
                StationComponent stationComponent = gStationPool[packet.stationGId];
                if (stationComponent != null)
                {
                    UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;

                    stationComponent.tripRangeDrones       = packet.tripRangeDrones;
                    stationComponent.tripRangeShips        = packet.tripRangeShips;
                    stationComponent.deliveryDrones        = packet.deliveryDrones;
                    stationComponent.deliveryShips         = packet.deliveryShips;
                    stationComponent.warpEnableDist        = packet.warpEnableDist;
                    stationComponent.warperNecessary       = packet.warperNecessary;
                    stationComponent.includeOrbitCollector = packet.includeOrbitCollector;
                    stationComponent.energy        = packet.energy;
                    stationComponent.energyPerTick = packet.energyPerTick;
                    for (int i = 0; i < packet.itemId.Length; i++)
                    {
                        if (stationComponent.storage == null)
                        {
                            // 3 is games default storage places for PLS
                            stationComponent.storage = new StationStore[packet.itemId.Length];
                        }
                        stationComponent.storage[i].itemId      = packet.itemId[i];
                        stationComponent.storage[i].max         = packet.itemCountMax[i];
                        stationComponent.storage[i].count       = packet.itemCount[i];
                        stationComponent.storage[i].remoteOrder = packet.remoteOrder[i];
                        stationComponent.storage[i].localLogic  = (ELogisticStorage)packet.localLogic[i];
                        stationComponent.storage[i].remoteLogic = (ELogisticStorage)packet.remoteLogic[i];
                    }
                    if (stationWindow != null && stationWindow.active)
                    {
                        conn.SendPacket(new StationSubscribeUIUpdates(true, stationComponent.gid));
                        StationUIManager.UIIsSyncedStage++;
                        stationWindow._Free();
                        stationWindow._Init(stationComponent);
                        AccessTools.Field(typeof(UIStationWindow), "_stationId").SetValue(stationWindow, stationComponent.id);
                        stationWindow._Open();
                        stationWindow._Update();
                    }
                    StationUIManager.UIStationId = stationComponent.id;
                }
            }
        }
Exemplo n.º 23
0
 public static void WorkShipBackToIdle_Postfix(StationComponent __instance, int index)
 {
     if (SimulatedWorld.Initialized && LocalPlayer.IsMasterClient)
     {
         ILSShipData packet = new ILSShipData(false, __instance.gid, index);
         LocalPlayer.SendPacket(packet);
     }
 }
Exemplo n.º 24
0
 public static void IdleShipGetToWork_Postfix(StationComponent __instance, int index)
 {
     if (Multiplayer.IsActive && Multiplayer.Session.LocalPlayer.IsHost)
     {
         ILSIdleShipBackToWork packet = new ILSIdleShipBackToWork(__instance.workShipDatas[__instance.workShipCount - 1], __instance.gid, __instance.workShipDatas.Length, __instance.warperCount);
         Multiplayer.Session.Network.SendPacket(packet);
     }
 }
Exemplo n.º 25
0
 public static void SetMinWarpDistance(this StationComponent component)
 {
     if (!component.isStellar)
     {
         return;
     }
     component.warpEnableDist = Util.AU(AspConfig.ILS.MinWarpDistance.Value);
 }
Exemplo n.º 26
0
 public ILSWorkShipBackToIdle(StationComponent stationComponent, ShipData shipData, int workShipIndex)
 {
     GId                 = stationComponent.gid;
     PlanetA             = shipData.planetA;
     StationMaxShipCount = stationComponent.workShipDatas.Length;
     ShipIndex           = shipData.shipIndex;
     WorkShipIndex       = workShipIndex;
 }
Exemplo n.º 27
0
 public static void IdleShipGetToWork_Postfix(StationComponent __instance, int index)
 {
     if (SimulatedWorld.Initialized && LocalPlayer.IsMasterClient)
     {
         ILSShipData packet = new ILSShipData(true, __instance.workShipDatas[__instance.workShipCount - 1].planetA, __instance.workShipDatas[__instance.workShipCount - 1].planetB, __instance.workShipDatas[__instance.workShipCount - 1].itemId, __instance.workShipDatas[__instance.workShipCount - 1].itemCount, __instance.gid, __instance.workShipDatas[__instance.workShipCount - 1].otherGId, index, __instance.workShipDatas[__instance.workShipCount - 1].warperCnt, __instance.warperCount);
         LocalPlayer.SendPacket(packet);
     }
 }
        public override void ProcessPacket(StationUIInitialSync packet, NebulaConnection conn)
        {
            StationComponent stationComponent = null;

            StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
            StationComponent[] stationPool  = GameMain.data.galaxy.PlanetById(packet.PlanetId).factory.transport.stationPool;

            stationComponent = packet.StationGId > 0 ? gStationPool[packet.StationGId] : stationPool?[packet.StationId];

            if (stationComponent == null)
            {
                Log.Error($"StationUIInitialSyncProcessor: Unable to find requested station on planet {packet.PlanetId} with id {packet.StationId} and gid of {packet.StationGId}");
                return;
            }

            if (StationUIManager.UIIsSyncedStage == 1)
            {
                UIStationWindow stationWindow = UIRoot.instance.uiGame.stationWindow;

                stationComponent.tripRangeDrones       = packet.TripRangeDrones;
                stationComponent.tripRangeShips        = packet.TripRangeShips;
                stationComponent.deliveryDrones        = packet.DeliveryDrones;
                stationComponent.deliveryShips         = packet.DeliveryShips;
                stationComponent.warpEnableDist        = packet.WarperEnableDistance;
                stationComponent.warperNecessary       = packet.WarperNecessary;
                stationComponent.includeOrbitCollector = packet.IncludeOrbitCollector;
                stationComponent.energy        = packet.Energy;
                stationComponent.energyPerTick = packet.EnergyPerTick;

                for (int i = 0; i < packet.ItemId.Length; i++)
                {
                    if (stationComponent.storage == null)
                    {
                        stationComponent.storage = new StationStore[packet.ItemId.Length];
                    }

                    stationComponent.storage[i].itemId      = packet.ItemId[i];
                    stationComponent.storage[i].max         = packet.ItemCountMax[i];
                    stationComponent.storage[i].count       = packet.ItemCount[i];
                    stationComponent.storage[i].remoteOrder = packet.RemoteOrder[i];
                    stationComponent.storage[i].localLogic  = (ELogisticStorage)packet.LocalLogic[i];
                    stationComponent.storage[i].remoteLogic = (ELogisticStorage)packet.RemoteLogic[i];
                }

                if (stationWindow != null && stationWindow.active)
                {
                    conn.SendPacket(new StationSubscribeUIUpdates(true, stationComponent.planetId, stationComponent.id, stationComponent.gid));
                    StationUIManager.UIIsSyncedStage++;
                    stationWindow._Free();
                    stationWindow._Init(stationComponent);
                    AccessTools.Field(typeof(UIStationWindow), "_stationId").SetValue(stationWindow, stationComponent.id);
                    stationWindow._Open();
                    stationWindow._Update();
                }

                StationUIManager.UIStationId = stationComponent.id;
            }
        }
Exemplo n.º 29
0
 public void ProcessPacket(StationUIInitialSyncRequest packet, NebulaConnection conn)
 {
     StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
     if (packet.stationGId < gStationPool.Length)
     {
         StationComponent stationComponent = null;
         if (packet.planetId == 0)
         {
             stationComponent = gStationPool[packet.stationGId];
         }
         else
         {
             PlanetData pData = GameMain.galaxy.PlanetById(packet.planetId);
             // GId is the id in this case as we look at a PLS
             if (pData?.factory?.transport != null && pData.factory.transport.stationPool.Length > packet.stationGId)
             {
                 stationComponent = pData.factory.transport.stationPool[packet.stationGId];
             }
         }
         if (stationComponent != null)
         {
             StationStore[] storage      = stationComponent.storage;
             int[]          itemId       = new int[storage.Length];
             int[]          itemCountMax = new int[storage.Length];
             int[]          itemCount    = new int[storage.Length];
             int[]          localLogic   = new int[storage.Length];
             int[]          remoteLogic  = new int[storage.Length];
             int[]          remoteOrder  = new int[storage.Length];
             for (int i = 0; i < stationComponent.storage.Length; i++)
             {
                 itemId[i]       = storage[i].itemId;
                 itemCountMax[i] = storage[i].max;
                 itemCount[i]    = storage[i].count;
                 localLogic[i]   = (int)storage[i].localLogic;
                 remoteLogic[i]  = (int)storage[i].remoteLogic;
                 remoteOrder[i]  = storage[i].remoteOrder;
             }
             StationUIInitialSync packet2 = new StationUIInitialSync(packet.stationGId,
                                                                     packet.planetId,
                                                                     stationComponent.tripRangeDrones,
                                                                     stationComponent.tripRangeShips,
                                                                     stationComponent.deliveryDrones,
                                                                     stationComponent.deliveryShips,
                                                                     stationComponent.warpEnableDist,
                                                                     stationComponent.warperNecessary,
                                                                     stationComponent.includeOrbitCollector,
                                                                     stationComponent.energy,
                                                                     stationComponent.energyPerTick,
                                                                     itemId,
                                                                     itemCountMax,
                                                                     itemCount,
                                                                     localLogic,
                                                                     remoteLogic,
                                                                     remoteOrder);
             conn.SendPacket(packet2);
         }
     }
 }
Exemplo n.º 30
0
 public static bool RematchRemotePairs_Prefix(StationComponent __instance, StationComponent[] gStationPool, int gStationCursor, int keyStationGId, int shipCarries)
 {
     if (Multiplayer.IsActive && !Multiplayer.Session.LocalPlayer.IsHost)
     {
         // skip vanilla code entirely for clients as we do this event based triggered by the server
         return(false);
     }
     return(true);
 }