Ejemplo n.º 1
0
        public override double ServerUpdateIntervalSeconds => double.MaxValue; // never

        public static void ServerOnBaseMerged(ILogicObject areasGroupFrom, ILogicObject areasGroupTo)
        {
            var fromState = GetPrivateState(areasGroupFrom);
            var toState   = GetPrivateState(areasGroupTo);

            PowerGrid.ServerOnPowerGridMerged(fromState.PowerGrid, toState.PowerGrid);

            var fromContainer = fromState.ItemsContainer;

            if (fromContainer.OccupiedSlotsCount != 0)
            {
                var toContainer = toState.ItemsContainer;
                Server.Items.TryMoveAllItems(fromContainer, toContainer, onlyToExistingStacks: true);

                var slotsNeeded = fromContainer.OccupiedSlotsCount;
                if (slotsNeeded > 0)
                {
                    Server.Items.SetSlotsCount(toContainer,
                                               Math.Max(ItemsContainerLandClaimSafeStorage.ServerSafeItemsSlotsCapacity,
                                                        (byte)(toContainer.OccupiedSlotsCount + slotsNeeded)));
                    Server.Items.TryMoveAllItems(fromContainer, toContainer, onlyToExistingStacks: false);
                }

                Logger.Important($"Bases merged: moved all safe storage items from {fromContainer} to {toContainer}");
            }
        }