private void SendServerCommand(ICommand command, bool immediate)
        {
            ServerAPI serverAPI = Service.Get <ServerAPI>();

            if (!serverAPI.Enabled && Service.Get <CurrentPlayer>().CampaignProgress.FueInProgress)
            {
                if (immediate)
                {
                    serverAPI.Enabled = true;
                    serverAPI.Sync(command);
                    serverAPI.Enabled = false;
                    return;
                }
                serverAPI.Enqueue(command);
                return;
            }
            else
            {
                if (immediate)
                {
                    serverAPI.Sync(command);
                    return;
                }
                serverAPI.Enqueue(command);
                return;
            }
        }
示例#2
0
        private void SendServerCommand(ICommand command, bool immediate)
        {
            ServerAPI serverAPI = Service.ServerAPI;

            if (!serverAPI.Enabled && Service.CurrentPlayer.CampaignProgress.FueInProgress)
            {
                if (immediate)
                {
                    serverAPI.Enabled = true;
                    serverAPI.Sync(command);
                    serverAPI.Enabled = false;
                }
                else
                {
                    serverAPI.Enqueue(command);
                }
            }
            else if (immediate)
            {
                serverAPI.Sync(command);
            }
            else
            {
                serverAPI.Enqueue(command);
            }
        }
示例#3
0
        private int CollectCurrencyFromGenerator(Entity buildingEntity, bool sendServerCommand)
        {
            BuildingComponent buildingComponent = buildingEntity.Get <BuildingComponent>();
            Building          buildingTO        = buildingComponent.BuildingTO;
            Inventory         inventory         = Service.CurrentPlayer.Inventory;
            int  num  = -1;
            int  num2 = 0;
            uint secondsPassed;

            if (this.GetTimePassed(buildingTO, out secondsPassed, true))
            {
                num = this.CalculateAccruedCurrency(buildingTO.CurrentStorage, buildingComponent.BuildingType, secondsPassed);
                CurrencyType currency = buildingComponent.BuildingType.Currency;
                if (currency != CurrencyType.Credits)
                {
                    if (currency != CurrencyType.Materials)
                    {
                        if (currency == CurrencyType.Contraband)
                        {
                            num2 = inventory.ModifyContraband(num);
                        }
                    }
                    else
                    {
                        num2 = inventory.ModifyMaterials(num);
                    }
                }
                else
                {
                    num2 = inventory.ModifyCredits(num);
                }
            }
            ServerAPI serverAPI = Service.ServerAPI;

            buildingTO.LastCollectTime = serverAPI.ServerTime;
            buildingTO.CurrentStorage  = num2;
            buildingTO.AccruedCurrency = num2;
            if (sendServerCommand)
            {
                serverAPI.Enqueue(new BuildingCollectCommand(new BuildingCollectRequest
                {
                    BuildingId = buildingTO.Key
                }));
            }
            return(num - num2);
        }