Beispiel #1
0
        public static ErrorCodes GetInsurancePrice(int definition, ref double insuranceFee, ref double insurancePayOut)
        {
            var ec = ErrorCodes.NoError;

            insuranceFee    = 0;
            insurancePayOut = 0;

            InsurancePrice insurancePrice;

            if (_insurancePrices.TryGetValue(definition, out insurancePrice))
            {
                if (insurancePrice == null)
                {
                    return(ErrorCodes.WTFErrorMedicalAttentionSuggested);
                }
            }
            else
            {
                var record = Db.Query().CommandText("select fee,payout from insuranceprices where definition=@definition").SetParameter("@definition", definition)
                             .ExecuteSingleRow();

                if (record == null)
                {
                    _insurancePrices.AddOrUpdate(definition, o => null, (k, v) => null);
                    Logger.Info("no record was found for definition: " + definition + " " + EntityDefault.Get(definition).Name);
                    return(ErrorCodes.WTFErrorMedicalAttentionSuggested);
                }

                insurancePrice = new InsurancePrice
                {
                    definition = definition,
                    fee        = record.GetValue <double>(0),
                    payOut     = record.GetValue <double>(1)
                };


                _insurancePrices.AddOrUpdate(definition, insurancePrice, (k, v) => v);
            }

            insuranceFee    = insurancePrice.fee;
            insurancePayOut = insurancePrice.payOut;
            return(ec);
        }
Beispiel #2
0
        public static ErrorCodes ReserveComponents_noSQL(IEnumerable <ProductionLiveComponent> itemsNeeded, long storageEid, Container container, out long[] reservedItems)
        {
            var ec           = ErrorCodes.NoError;
            var reservedList = new List <long>();

            reservedItems = null;

            foreach (var plc in itemsNeeded)
            {
                //load the component
                var component = container.GetItem(plc.eid, true);
                if (component == null)
                {
                    ec = ErrorCodes.ItemNotFound;
                    return(ec);
                }

                if (plc.resultQuantity == 0)
                {
                    //the component will be completely used for the manufacture

                    //put it into the storage

                    if (!container.RemoveItemFromTree(component))
                    {
                        return(ErrorCodes.ItemNotFound);
                    }

                    component.Parent = storageEid;

                    reservedList.Add(component.Eid);                     //this is the item we put into the storage

                    component.Save();
                }
                else
                {
                    //create a portion of the component

                    var componentPortion = component.Unstack(plc.quantity - plc.resultQuantity);

                    componentPortion.Parent = storageEid;

                    //save the component portion
                    componentPortion.Save();

                    reservedList.Add(componentPortion.Eid);
                }
            }

            reservedItems = reservedList.ToArray();

            //---------------------------------------------DEBUG OUTPUT-------------------------------------
            var outputDict = new Dictionary <string, int>();

            foreach (var comp in itemsNeeded)
            {
                var defname      = EntityDefault.Get(comp.definition).Name;
                var quantityUsed = comp.resultQuantity == 0 ? comp.quantity : comp.quantity - comp.resultQuantity;

                if (outputDict.ContainsKey(defname))
                {
                    outputDict[defname] += quantityUsed;
                }
                else
                {
                    outputDict[defname] = quantityUsed;
                }
            }

            Logger.Info("items used for production: ----------------------------------");
            foreach (var pair in outputDict)
            {
                Logger.Info(pair.Key + " " + pair.Value);
            }
            Logger.Info("-------------------------------------------------------------");

            return(ec);
        }
Beispiel #3
0
        private IDictionary <string, object> EndMassProduction(ProductionInProgress productionInProgress, bool forced)
        {
            Logger.Info("mass production finished: " + productionInProgress);

            //delete the used items
            foreach (var item in productionInProgress.GetReservedItems())
            {
                productionInProgress.character.LogTransaction(TransactionLogEvent.Builder()
                                                              .SetTransactionType(TransactionType.MassProductionDeleted)
                                                              .SetCharacter(productionInProgress.character)
                                                              .SetItem(item));
                Repository.Delete(item);
            }

            //pick the output defintion---------------------------------------------------

            var outputDefinition = productionInProgress.resultDefinition;

            //load container
            var container = (PublicContainer)Container.GetOrThrow(PublicContainerEid);

            container.ReloadItems(productionInProgress.character);

            var outputDefault = EntityDefault.Get(outputDefinition).ThrowIfEqual(EntityDefault.None, ErrorCodes.DefinitionNotSupported);

            //create item
            var resultItem = container.CreateAndAddItem(outputDefinition, false, item =>
            {
                item.Owner    = productionInProgress.character.Eid;
                item.Quantity = outputDefault.Quantity * productionInProgress.amountOfCycles;
            });

            productionInProgress.character.WriteItemTransactionLog(TransactionType.MassProductionCreated, resultItem);

            CalibrationProgram calibrationProgram;
            var wasLineDead            = false;
            var affectedProductionLine = DecalibrateLine(productionInProgress, ref wasLineDead, out calibrationProgram);

            if (affectedProductionLine == null)
            {
                Logger.Error("EndMassProduction: a production line was not found for an ending productionInProgress " + productionInProgress);
            }
            else
            {
                if (!forced && !wasLineDead)
                {
                    if (affectedProductionLine.Rounds >= 1)
                    {
                        //do production rounds
                        //ThreadPoolHelper.ScheduledTask(3000, () => TryNextRound(productionInProgress.character, affectedProductionLine.ID, productionInProgress.amountOfCycles, productionInProgress.useCorporationWallet));

                        var nrp = new NextRoundProduction(ProductionProcessor, productionInProgress.character, affectedProductionLine.Id, productionInProgress.amountOfCycles, productionInProgress.useCorporationWallet, Eid);

                        ProductionProcessor.EnqueueNextRoundProduction(nrp);
                    }
                }
            }


            //mission stuff
            if (outputDefault.CategoryFlags.IsCategory(CategoryFlags.cf_generic_random_items))
            {
                var randomCalibrationProgram = calibrationProgram as RandomCalibrationProgram;
                if (randomCalibrationProgram != null)
                {
                    //set it from the ct
                    resultItem.Quantity = randomCalibrationProgram.TargetQuantity;
                    Logger.Info("mission quantity is forced from CPRG:" + randomCalibrationProgram.Eid + " qty:" + randomCalibrationProgram.TargetQuantity);
                }
            }

            container.Save();

            //get list in order to return
            var linesList = GetLinesList(productionInProgress.character);

            Logger.Info("Mass Production created an item: " + resultItem + " production:" + productionInProgress);

            var replyDict = new Dictionary <string, object>
            {
                { k.result, resultItem.BaseInfoToDictionary() },
                { k.lines, linesList },
                { k.lineCount, linesList.Count }
            };

            ProductionProcessor.EnqueueProductionMissionTarget(MissionTargetType.massproduce, productionInProgress.character, MyMissionLocationId(), resultItem.Definition, resultItem.Quantity);
            return(replyDict);
        }
            public static Dictionary <string, object> Build(IExtensionReader extensionReader, IRobotTemplateRelations robotTemplateRelations, EntityDefault ed)
            {
                var info = ed.ToDictionary();

                try
                {
                    Entity entity = null;

                    var robotTemplate = robotTemplateRelations.GetRelatedTemplate(ed);
                    if (robotTemplate != null)
                    {
                        entity = robotTemplate.Build();
                    }

                    if (entity == null)
                    {
                        entity = Entity.Factory.CreateWithRandomEID(ed);
                    }

                    var item = entity as Item;
                    item?.Initialize();

                    var builder = new InfoBuilder(extensionReader, info);
                    entity.AcceptVisitor(builder);
                }
                catch (Exception ex)
                {
                    Logger.Error($"troubled definition: {ed.Definition}  {ex.Message}");
                    Logger.Error($"{ex}\n{ex.Message}\n{ex.Source}\n{ex.InnerException?.Message}\n{ex.StackTrace}\n");
                }

                return(info);
            }
 private RobotSetup(EntityDefault robotShell, EntityDefault head, EntityDefault chassis, EntityDefault leg, EntityDefault container, EntityDefault hybridShell)
 {
     _robotShell  = robotShell;
     _head        = head;
     _chassis     = chassis;
     _leg         = leg;
     _container   = container;
     _hybridShell = hybridShell;
 }
Beispiel #6
0
        private static void CollectHangarRent(IStandingHandler standingHandler)
        {
            var storage = EntityDefault.GetByName(DefinitionNames.PUBLIC_CORPORATE_HANGARS_STORAGE);

            var hangarEids = Db.Query().CommandText("select eid from entities where parent in (SELECT eid FROM dbo.getLiveDockingbaseChildren() WHERE definition=@hangarDef) order by parent")
                             .SetParameter("@hangarDef", storage.Definition)
                             .Execute()
                             .Select(h => (CorporateHangar)GetOrThrow(h.GetValue <long>(0)))
                             .ToArray();

            Logger.Info("--- hangars collected for rent check: " + hangarEids.Count());

            using (var scope = Db.CreateTransaction())
            {
                try
                {
                    foreach (var hangar in hangarEids)
                    {
                        var hangarStorage = hangar.GetHangarStorage();
                        switch (hangarStorage.GetParentDockingBase())
                        {
                        case Outpost outpost:
                        {
                            var siteInfo = outpost.GetIntrusionSiteInfo();
                            if (siteInfo?.Owner != null)
                            {
                                //it has an owner
                                if (hangar.Owner != siteInfo.Owner)
                                {
                                    //the owner is not the hangar's owner
                                    var dockingStandingLimit = siteInfo.DockingStandingLimit;
                                    if (dockingStandingLimit != null)
                                    {
                                        //the outpost has standing limit set
                                        var standingTowardsOwner = standingHandler.GetStanding((long)siteInfo.Owner, hangar.Owner);

                                        if (standingTowardsOwner < dockingStandingLimit)
                                        {
                                            //the hangar is inaccessible
                                            Logger.Info("hangar is inaccessible for corp. " + hangar.Owner + " hangaried:" + hangar.Eid + " standing:" + standingTowardsOwner + " dockingStandingLimit:" + dockingStandingLimit);
                                            continue;
                                        }
                                    }
                                }
                            }
                            break;
                        }

                        case PBSDockingBase pbsDockingBase:
                        {
                            if (pbsDockingBase.StandingEnabled)
                            {
                                var standingTowardsOwner = standingHandler.GetStanding(pbsDockingBase.Owner, hangar.Owner);

                                if (standingTowardsOwner < pbsDockingBase.StandingLimit)
                                {
                                    Logger.Info("hangar is inaccessible for corp. " + hangar.Owner + " hangaried:" + hangar.Eid + " standing:" + standingTowardsOwner + " dockingStandingLimit:" + pbsDockingBase.StandingLimit);
                                    continue;
                                }
                            }
                            break;
                        }
                        }

                        var rentInfo = hangarStorage.GetCorporationHangarRentInfo();

                        // rent expired?

                        if (hangar.IsLeaseExpired)
                        {
                            continue;
                        }

                        if (DateTime.Now > hangar.LeaseEnd)
                        {
                            var corporation = hangar.GetCorporation();

                            Logger.Info("--- hangar rent process started for hangarEID:" + hangar.Eid + " hangarName:" + hangar.Name + " corporaration:" + corporation.Eid + " corpname:" + corporation.Description.name);

                            var wallet = new CorporationWallet(corporation);

                            if (wallet.Balance < rentInfo.price)
                            {
                                Logger.Info("--- corporation is broken. corporationEID:" + corporation.Eid + " hangar closed. EID:" + hangar.Eid);

                                //corporation broken
                                hangar.IsLeaseExpired = true; //block the hangar's content

                                //alert accountants
                                var info = new Dictionary <string, object> {
                                    { k.containerEID, hangar.Eid }
                                };

                                Message.Builder.SetCommand(Commands.CorporationHangarRentExpired)
                                .WithData(info)
                                .ToCorporation(corporation, CorporationRole.Accountant)
                                .Send();
                            }
                            else
                            {
                                wallet.Balance -= rentInfo.price;

                                var b = TransactionLogEvent.Builder()
                                        .SetCorporation(corporation)
                                        .SetTransactionType(TransactionType.hangarRentAuto)
                                        .SetCreditBalance(wallet.Balance)
                                        .SetCreditChange(-rentInfo.price);

                                corporation.LogTransaction(b);

                                hangarStorage.GetParentDockingBase().AddCentralBank(TransactionType.hangarRentAuto, rentInfo.price);

                                hangar.LeaseStart     = DateTime.Now;
                                hangar.LeaseEnd       = DateTime.Now + rentInfo.period;
                                hangar.IsLeaseExpired = false;

                                Logger.Info("--- hangar price paid. hangarEID: " + hangar.Eid + " lease ended:" + hangar.LeaseEnd + " lease extened:" + hangar.LeaseEnd);
                            }

                            hangar.Save();
                        }
                        else
                        {
                            Logger.Info("--- hangar still paid. eid:" + hangar.Eid + " lease end:" + hangar.LeaseEnd);
                        }
                    }

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    Logger.Exception(ex);
                }
            }
        }
        /// <summary>
        /// This spawns the reward items for the config missions
        /// </summary>
        /// <param name="mission"></param>
        /// <param name="missionInProgress"></param>
        private static void SpawnStartItemsForConfigMissions(Mission mission, MissionInProgress missionInProgress)
        {
            if (!mission.StartItems.Any())
            {
                return;
            }

            var container = missionInProgress.myLocation.GetContainer;

            var startItems = new List <Item>();

            foreach (var itemInfo in mission.StartItems)
            {
                var ed = EntityDefault.Get(itemInfo.Definition);

                if (ed.AttributeFlags.NonStackable)
                {
                    //give one by one the nonstackable

                    for (var i = 0; i < itemInfo.Quantity; i++)
                    {
                        var startItem = container.CreateAndAddItem(itemInfo.Definition, false, item =>
                        {
                            item.Owner    = missionInProgress.character.Eid;
                            item.Quantity = 1;
                        });

                        startItems.Add(startItem);
                    }
                }
                else
                {
                    //these ones are also nonstacked just for the clarity, so the player sees the items separately
                    var info      = itemInfo;
                    var startItem = container.CreateAndAddItem(itemInfo.Definition, false, item =>
                    {
                        item.Owner    = missionInProgress.character.Eid;
                        item.Quantity = info.Quantity;
                    });

                    startItems.Add(startItem);
                }
            }

            container.Save();

            if (startItems.Count <= 0)
            {
                return;
            }


            var startItemsDict = startItems.ToDictionary("i", i => i.ToDictionary());
            var result         = new Dictionary <string, object>(2)
            {
                { k.locationID, missionInProgress.myLocation.id },
                { k.startItems, startItemsDict },
            };

            Transaction.Current.OnCommited(() =>
            {
                Message.Builder.SetCommand(Commands.MissionStartItems)
                .WithData(result)
                .ToCharacter(missionInProgress.character)
                .Send();
            });
        }
Beispiel #8
0
 public static void GetCalibrationDefault(this IProductionDataAccess dataAccess, EntityDefault ed, out int materialEfficiency, out int timeEfficiency)
 {
     dataAccess.GetCalibrationDefault(ed.Definition, out materialEfficiency, out timeEfficiency);
 }
Beispiel #9
0
        public ErrorCodes StartResearch(Character character, int researchTimeSeconds, Item sourceItem, ResearchKit researchKit, bool useCorporationWallet, out ProductionInProgress newProduction)
        {
            newProduction = ProductionInProgressFactory();

            var itemsList = new [] { researchKit, sourceItem };

            ItemResearchLevel itemResearchLevel;

            if (!ProductionDataAccess.ResearchLevels.TryGetValue(sourceItem.Definition, out itemResearchLevel))
            {
                Logger.Error("consistency error. no research level or calibration program was defined for " + EntityDefault.Get(sourceItem.Definition).Name + " " + sourceItem.Definition);
                return(ErrorCodes.ServerError);
            }

            if (itemResearchLevel.calibrationProgramDefinition == null)
            {
                Logger.Error("consistency error. CPRG definition is NULL for " + EntityDefault.Get(sourceItem.Definition).Name + " " + sourceItem.Definition);
                return(ErrorCodes.ServerError);
            }

            var cprgDefiniton = (int)itemResearchLevel.calibrationProgramDefinition;


            MoveItemsToStorage(itemsList);

            newProduction                            = ProductionInProgressFactory();
            newProduction.startTime                  = DateTime.Now;
            newProduction.finishTime                 = DateTime.Now.AddSeconds(researchTimeSeconds);
            newProduction.type                       = ProductionInProgressType.research;
            newProduction.character                  = character;
            newProduction.facilityEID                = Eid;
            newProduction.resultDefinition           = cprgDefiniton;
            newProduction.totalProductionTimeSeconds = researchTimeSeconds;
            newProduction.baseEID                    = Parent;
            newProduction.pricePerSecond             = GetPricePerSecond();
            newProduction.ReservedEids               = (from i in itemsList select i.Eid).ToArray();
            newProduction.useCorporationWallet       = useCorporationWallet;
            newProduction.amountOfCycles             = 1;

            if (!newProduction.TryWithdrawCredit())
            {
                if (useCorporationWallet)
                {
                    throw new PerpetuumException(ErrorCodes.CorporationNotEnoughMoney);
                }

                throw new PerpetuumException(ErrorCodes.CharacterNotEnoughMoney);
            }

            return(ErrorCodes.NoError);
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var buyer                     = request.Session.Character;
                var itemDefinition            = request.Data.GetOrDefault <int>(k.definition);
                var duration                  = request.Data.GetOrDefault <int>(k.duration);
                var pricePerPiece             = request.Data.GetOrDefault <double>(k.price);
                var quantity                  = request.Data.GetOrDefault(k.quantity, 1);
                var useBuyerCorporationWallet = request.Data.GetOrDefault <int>(k.useCorporationWallet) == 1;
                var forMyCorporation          = request.Data.GetOrDefault <int>(k.forMembersOf) == 1;

                quantity.ThrowIfLessOrEqual(0, ErrorCodes.AmountTooLow);

                buyer.IsDocked.ThrowIfFalse(ErrorCodes.CharacterHasToBeDocked);
                buyer.CheckPrivilegedTransactionsAndThrowIfFailed();

                pricePerPiece.ThrowIfLessOrEqual(0, ErrorCodes.IllegalMarketPrice);

                duration.ThrowIfLessOrEqual(1, ErrorCodes.MinimalDurationNotReached);

                var ed = EntityDefault.Get(itemDefinition).ThrowIfEqual(EntityDefault.None, ErrorCodes.DefinitionNotSupported);

                ed.IsSellable.ThrowIfFalse(ErrorCodes.ItemNotSellable);

                var market = buyer.GetCurrentDockingBase().GetMarketOrThrow();

                var realMarketFee = Market.GetRealMarketFee(buyer, duration);

                var corporationEid = buyer.CorporationEid;

                //cash market fee anyways
                _marketHelper.CashInMarketFee(buyer, useBuyerCorporationWallet, realMarketFee);

                buyer.GetCurrentDockingBase().AddCentralBank(TransactionType.marketFee, realMarketFee);

                if (_marketInfoService.CheckAveragePrice)
                {
                    var avgPrice = _marketHandler.GetAveragePriceByMarket(market, itemDefinition);

                    if (avgPrice != null && avgPrice.AveragePrice > 0)
                    {
                        if (pricePerPiece < avgPrice.AveragePrice * (1 - _marketInfoService.Margin) || pricePerPiece > avgPrice.AveragePrice * (1 + _marketInfoService.Margin))
                        {
                            throw new PerpetuumException(ErrorCodes.PriceOutOfAverageRange);
                        }
                    }
                }

                var publicContainer = buyer.GetPublicContainerWithItems();

                long?forMembersOf = null;
                if (forMyCorporation)
                {
                    if (!DefaultCorporationDataCache.IsCorporationDefault(corporationEid))
                    {
                        forMembersOf = corporationEid;
                    }
                    else
                    {
                        forMyCorporation = false;
                    }
                }

                if (!forMyCorporation)
                {
                    _marketHelper.CheckBuyOrderCounts(buyer).ThrowIfFalse(ErrorCodes.MarketItemsExceed);
                }

                var lowestSellOrder = _marketOrderRepository.GetLowestSellOrder(itemDefinition, pricePerPiece, buyer.Eid, market, corporationEid);

                if (!forMyCorporation && lowestSellOrder != null)
                {
                    // requested item was found on the market, make immediate transaction
                    market.FulfillBuyOrderInstantly(buyer, useBuyerCorporationWallet, lowestSellOrder, pricePerPiece, duration, quantity, publicContainer, forMembersOf);
                }
                else
                {
                    var deposit = pricePerPiece * quantity;

                    // take the deposit from the character
                    _marketHelper.CashIn(buyer, useBuyerCorporationWallet, pricePerPiece, itemDefinition, quantity, TransactionType.buyOrderDeposit);

                    //store the deposit in the central bank
                    market.AddCentralBank(TransactionType.buyOrderDeposit, deposit);

                    // create a new buy order
                    var newBuyOrder = market.CreateBuyOrder(buyer, itemDefinition, duration, pricePerPiece, quantity, useBuyerCorporationWallet, forMembersOf);

                    var data = new Dictionary <string, object>
                    {
                        { k.buyOrder, newBuyOrder.ToDictionary() }
                    };

                    Message.Builder.SetCommand(Commands.MarketBuyOrderCreated)
                    .WithData(data)
                    .ToCharacter(buyer)
                    .Send();
                }

                publicContainer.Save();

                Message.Builder.SetCommand(Commands.ListContainer)
                .WithData(publicContainer.ToDictionary())
                .ToCharacter(buyer)
                .Send();

                scope.Complete();
            }
        }
Beispiel #11
0
        public static int GetResultingDefinitionFromCalibrationDefinition(this IProductionDataAccess dataAccess, int definition)
        {
            var target = (dataAccess.ResearchLevels.Values.Where(ir => ir.calibrationProgramDefinition == definition).Select(ir => ir.definition)).FirstOrDefault();

            if (target == 0)
            {
                Logger.Error("no target definition was found for calibration program: " + EntityDefault.Get(definition).Name + " " + definition);
            }

            return(target);
        }
Beispiel #12
0
 public Item CreateItem(EntityDefault entityDefault, EntityIDGenerator idGenerator)
 {
     return((Item)_entityServices.Factory.Create(entityDefault, idGenerator));
 }
        public static PrivateCorporation Create(CorporationDescription corporationDescription)
        {
            var container = SystemContainer.GetByName(k.es_private_corporation);

            return((PrivateCorporation)Create(EntityDefault.GetByName(DefinitionNames.PRIVATE_CORPORATION), container, corporationDescription, EntityIDGenerator.Random));
        }
        public void HandleRequest(IRequest request)
        {
            using (var scope = Db.CreateTransaction())
            {
                var cfLong     = request.Data.GetOrDefault <long>(k.categoryFlags);
                var category   = request.Data.GetOrDefault <string>(k.category);
                var global     = request.Data.GetOrDefault <int>(k.global) == 1;
                var marketEID  = request.Data.GetOrDefault <long>(k.marketEID);
                var withVendor = request.Data.GetOrDefault("vendor", 1) == 1;
                var nameFilter = request.Data.GetOrDefault <string>(k.filter);

                if (global)
                {
                    if (cfLong > 0)
                    {
                        _marketHelper.RemoveItemsByCategoryFlags((CategoryFlags)cfLong, withVendor);
                    }

                    if (Enum.TryParse(category, true, out CategoryFlags cf))
                    {
                        _marketHelper.RemoveItemsByCategoryFlags(cf, withVendor);
                    }
                }
                else
                {
                    if (marketEID == 0)
                    {
                        var character   = request.Session.Character;
                        var dockingBase = character.GetCurrentDockingBase();
                        var market      = dockingBase.GetMarket();
                        marketEID = market.Eid;
                    }

                    Enum.TryParse(category, true, out CategoryFlags cf).ThrowIfFalse(ErrorCodes.SyntaxError);

                    var definitions = _entityServices.Defaults.GetAll().GetDefinitionsByCategoryFlag(cf);

                    if (!nameFilter.IsNullOrEmpty())
                    {
                        var tmpList = new List <int>();

                        foreach (var definition in definitions)
                        {
                            var ed = EntityDefault.Get(definition);

                            if (!ed.Name.Contains(nameFilter))
                            {
                                continue;
                            }

                            tmpList.Add(ed.Definition);
                        }

                        definitions = tmpList.ToArray();
                    }

                    var definitionsString = definitions.ArrayToString();

                    var queryString = "delete marketitems where marketeid=@marketEID and itemdefinition in (" + definitionsString + ") ";

                    if (!withVendor)
                    {
                        queryString += " and isvendoritem=0";
                    }

                    Db.Query().CommandText(queryString)
                    .SetParameter("@marketEID", marketEID)
                    .ExecuteNonQuery();
                }

                Message.Builder.FromRequest(request).WithOk().Send();

                scope.Complete();
            }
        }
Beispiel #15
0
 private FittingPreset(string name, EntityDefault robot, IEnumerable <ModuleInfo> modules)
 {
     _modules = modules.ToArray();
     Name     = name;
     Robot    = robot;
 }
Beispiel #16
0
        private IDictionary <string, object> EndResearch(ProductionInProgress productionInProgress)
        {
            Logger.Info("research finished: " + productionInProgress);

            Item        item;
            ResearchKit researchKit;

            LoadItemAndResearchKit(productionInProgress, out researchKit, out item).ThrowIfError();

            var isPrototypeItem = ProductionDataAccess.IsPrototypeDefinition(item.Definition);

            var itemLevel        = ProductionDataAccess.GetResearchLevel(item.Definition);
            var researchKitLevel = researchKit.GetResearchLevel();

            int researchTime;
            int levelDifferenceBonusPoints;

            CalculateFinalResearchTimeSeconds(productionInProgress.character, itemLevel, researchKitLevel, isPrototypeItem, out researchTime, out levelDifferenceBonusPoints);

            var outputDefinition = productionInProgress.resultDefinition;

            //load public container
            var targetContainer = (PublicContainer)Container.GetOrThrow(PublicContainerEid);

            targetContainer.ReloadItems(productionInProgress.character);

            var outputDefault = EntityDefault.Get(outputDefinition).ThrowIfEqual(EntityDefault.None, ErrorCodes.DefinitionNotSupported);

            (outputDefault.CategoryFlags.IsCategory(CategoryFlags.cf_calibration_programs) || outputDefault.CategoryFlags.IsCategory(CategoryFlags.cf_random_calibration_programs)).ThrowIfFalse(ErrorCodes.WTFErrorMedicalAttentionSuggested);


            //create item
            var resultItem = targetContainer.CreateAndAddItem(outputDefinition, false, item1 =>
            {
                item1.Owner    = productionInProgress.character.Eid;
                item1.Quantity = 1;
            });

            var calibrationProgram = resultItem as CalibrationProgram;

            calibrationProgram.ThrowIfNull(ErrorCodes.ConsistencyError);

            var itemResearchLevel = ProductionDataAccess.GetItemReserchLevelByCalibrationProgram(calibrationProgram);

            int materialEfficiency;
            int timeEfficiency;

            researchKit.GetCalibrationDefaults(outputDefault, out materialEfficiency, out timeEfficiency);

            var rawMatEff = materialEfficiency;

            //modify the results even further
            CalculateMaterialAndTimeEfficiency(productionInProgress.character, itemResearchLevel, levelDifferenceBonusPoints, ref materialEfficiency, ref timeEfficiency);

            if (calibrationProgram.IsMissionRelated)
            {
                materialEfficiency = rawMatEff;
                calibrationProgram.MaterialEfficiencyPoints = rawMatEff;
                calibrationProgram.TimeEfficiencyPoints     = timeEfficiency;
            }
            else
            {
                calibrationProgram.MaterialEfficiencyPoints = materialEfficiency;
                calibrationProgram.TimeEfficiencyPoints     = timeEfficiency;
            }



            var randomCalibrationProgram = calibrationProgram as RandomCalibrationProgram;

            //for random missions look up for targets, gang and stuff
            randomCalibrationProgram?.SetComponentsFromRunningTargets(productionInProgress.character);

            calibrationProgram.Save();

            productionInProgress.character.WriteItemTransactionLog(TransactionType.ResearchCreated, calibrationProgram);

            //delete the used items

            Repository.Delete(item);

            Repository.Delete(researchKit);

            productionInProgress.character.WriteItemTransactionLog(TransactionType.ResearchDeleted, item);
            productionInProgress.character.WriteItemTransactionLog(TransactionType.ResearchDeleted, researchKit);

            targetContainer.Save();

            Logger.Info("endResearch created an item: " + calibrationProgram + " production:" + productionInProgress);

            var replyDict = new Dictionary <string, object>
            {
                { k.result, calibrationProgram.ToDictionary() }
            };


            ProductionProcessor.EnqueueProductionMissionTarget(MissionTargetType.research, productionInProgress.character, MyMissionLocationId(), calibrationProgram.Definition);
            return(replyDict);
        }
Beispiel #17
0
 public ModuleInfo(RobotComponentType component, int slot, EntityDefault module, EntityDefault ammo)
 {
     Component = component;
     Slot      = slot;
     Module    = module;
     Ammo      = ammo;
 }
Beispiel #18
0
        public IDictionary <string, object> ResearchQuery(Character character, int researchKitDefinition, int targetDefinition)
        {
            var replyDict = new Dictionary <string, object>
            {
                { k.researchKitDefinition, researchKitDefinition },
                { k.itemDefinition, targetDefinition }
            };

            var researchKitDefault = EntityDefault.Get(researchKitDefinition);
            var itemDefault        = EntityDefault.Get(targetDefinition);

            var missionRelated = false;

            //match item vs research kit vs mission
            if (researchKitDefault.CategoryFlags.IsCategory(CategoryFlags.cf_random_research_kits))
            {
                itemDefault.CategoryFlags.IsCategory(CategoryFlags.cf_generic_random_items).ThrowIfFalse(ErrorCodes.OnlyMissionItemAccepted);
                missionRelated = true;
            }

            if (itemDefault.CategoryFlags.IsCategory(CategoryFlags.cf_generic_random_items))
            {
                researchKitDefault.CategoryFlags.IsCategory(CategoryFlags.cf_random_research_kits).ThrowIfFalse(ErrorCodes.OnlyMissionResearchKitAccepted);
                missionRelated = true;
            }

            //on gamma not even possible
            if (GetDockingBase().IsOnGammaZone())
            {
                missionRelated.ThrowIfTrue(ErrorCodes.MissionItemCantBeResearchedOnGamma);
            }

            var researchKitLevel = ResearchKit.GetResearchLevelByDefinition(researchKitDefinition);

            replyDict.Add(k.researchKitLevel, researchKitLevel);

            var isPrototypeItem = ProductionDataAccess.IsPrototypeDefinition(targetDefinition);

            Logger.Info("item definition: " + EntityDefault.Get(targetDefinition).Name + " isPrototype:" + isPrototypeItem);

            var nominalDict = new Dictionary <string, object>();
            var realDict    = new Dictionary <string, object>();

            //match research levels
            var itemLevel = ProductionDataAccess.GetResearchLevel(targetDefinition);

            itemLevel.ThrowIfEqual(0, ErrorCodes.ItemNotResearchable);
            itemLevel.ThrowIfGreater(researchKitLevel, ErrorCodes.ResearchLevelMismatch);

            var itemResearchLevel = ProductionDataAccess.ResearchLevels.GetOrDefault(targetDefinition).ThrowIfNull(ErrorCodes.ItemNotResearchable);

            var outputDefinition = (int)itemResearchLevel.calibrationProgramDefinition.ThrowIfNull(ErrorCodes.ServerError);

            //calculate
            CalculateFinalResearchTimeSeconds(character, itemLevel, researchKitLevel, isPrototypeItem, out int researchTimeSeconds, out int levelDifferenceBonusPoints);

            researchTimeSeconds = GetShortenedProductionTime(researchTimeSeconds);

            var price = missionRelated ? 0.0 : researchTimeSeconds *GetPricePerSecond();

            ProductionDataAccess.GetCalibrationDefault(outputDefinition, out int materialEfficiency, out int timeEfficiency);

            var rawMaterialEfficiency = materialEfficiency;

            CalculateMaterialAndTimeEfficiency(character, itemResearchLevel, levelDifferenceBonusPoints, ref materialEfficiency, ref timeEfficiency);

            if (missionRelated)
            {
                //the material efficiency must be default 1.0
                materialEfficiency = rawMaterialEfficiency;
            }


            //calculate nominal
            var nominalResearchTimeSeconds = CalculateNominalResearchTimeSeconds(character, itemResearchLevel.researchLevel);

            var nominalPrice = missionRelated ? 0.0 : nominalResearchTimeSeconds *GetPricePerSecond();

            ProductionDataAccess.GetCalibrationDefault(outputDefinition, out int nominalMaterialEfficiency, out int nominalTimeEfficiency);

            var rawNominalMatEff = nominalMaterialEfficiency;

            CalculateMaterialAndTimeEfficiency(character, itemResearchLevel, 0, ref nominalMaterialEfficiency, ref nominalTimeEfficiency);

            if (missionRelated)
            {
                nominalMaterialEfficiency  = rawNominalMatEff;
                researchTimeSeconds        = 10;
                nominalResearchTimeSeconds = 10;
            }

            //collect definition related
            replyDict.Add(k.calibrationProgram, itemResearchLevel.calibrationProgramDefinition);

            //collect real
            realDict.Add(k.price, (long)price);
            realDict.Add(k.researchTime, researchTimeSeconds);
            realDict.Add(k.materialEfficiency, materialEfficiency);
            realDict.Add(k.timeEfficiency, timeEfficiency);

            //collect nominal
            nominalDict.Add(k.price, (long)nominalPrice);
            nominalDict.Add(k.researchTime, nominalResearchTimeSeconds);
            nominalDict.Add(k.materialEfficiency, nominalMaterialEfficiency);
            nominalDict.Add(k.timeEfficiency, nominalTimeEfficiency);

            replyDict.Add(k.real, realDict);
            replyDict.Add(k.nominal, nominalDict);
            replyDict.Add(k.facility, Eid);

            return(replyDict);
        }
Beispiel #19
0
 public static CorporateHangar Create()
 {
     return((CorporateHangar)Factory.CreateWithRandomEID(EntityDefault.GetByName(DefinitionNames.CORPORATE_HANGAR_STANDARD)));
 }
 private Coin(EntityDefault coinED, int amount)
 {
     _coinED = coinED;
     _amount = amount;
 }
        private double GetAverageWorldPriceByComponents(EntityDefault entityDefault)
        {
            Logger.Info("wavg for " + entityDefault.Name + " " + entityDefault.Definition);

            var sumCost = 0.0;

            foreach (var component in _productionDataAccess.ProductionComponents[entityDefault.Definition])
            {
                if (component.IsRobotShard)
                {
                    continue;
                }

                // COMMODITY es MATERIAL
                if (component.IsMaterial)
                {
                    var commodityComponents = _productionDataAccess.ProductionComponents[component.EntityDefault.Definition].ToArray();
                    if (commodityComponents.Length > 0)
                    {
                        //this is a commodity =>  do components
                        Logger.Info("   commodity break down for: " + component.EntityDefault.Name);

                        foreach (var commodityComponent in commodityComponents)
                        {
                            var marketAverage = _marketHandler.GetWorldAveragePriceByTrades(commodityComponent.EntityDefault);
                            var cost          = commodityComponent.Amount * marketAverage * component.Amount;

                            if (marketAverage > 0)
                            {
                                sumCost += cost;
                                Logger.Info("   comm=>raw comp: " + EntityDefault.Get(commodityComponent.EntityDefault.Definition).Name + " q:" + commodityComponent.Amount * component.Amount + " mavg: " + marketAverage + " cost:" + cost);
                            }
                            else
                            {
                                Logger.Info("    comp WTF - no trade - " + EntityDefault.Get(commodityComponent.EntityDefault.Definition).Name);
                            }
                        }
                    }
                    else
                    {
                        // raw material => get market average
                        var marketAverage = _marketHandler.GetWorldAveragePriceByTrades(component.EntityDefault);
                        var cost          = component.Amount * marketAverage;

                        if (marketAverage > 0)
                        {
                            sumCost += cost;
                            Logger.Info("    raw comp: " + component.EntityDefault.Name + " q:" + component.Amount + " mavg: " + marketAverage + " cost:" + cost);
                        }
                        else
                        {
                            Logger.Info("    comp WTF - no trade - " + component.EntityDefault.Name);
                        }
                    }
                }

                if (component.IsEquipment)
                {
                    Logger.Info("  component is equipment: " + component.EntityDefault.Name + " recursion starts");

                    var marketAverage = GetAverageWorldPriceByComponents(component.EntityDefault);

                    var cost = component.Amount * marketAverage;

                    if (marketAverage > 0)
                    {
                        sumCost += cost;
                        Logger.Info("   equipment comp: " + component.EntityDefault.Name + " q:" + component.Amount + " mavg: " + marketAverage + " cost:" + cost);
                    }
                    else
                    {
                        Logger.Info("    comp WTF - no trade - " + component.EntityDefault.Name);
                    }
                }

                if (!component.IsRobot)
                {
                    continue;
                }

                Logger.Info("  component is robot: " + component.EntityDefault.Name + " recursion starts");

                var template = _robotTemplateRelations.GetRelatedTemplateOrDefault(component.EntityDefault.Definition);

                var marketAverageHead = GetAverageWorldPriceByComponents(template.Head.EntityDefault);
                var costHead          = component.Amount * marketAverageHead;

                if (marketAverageHead > 0)
                {
                    sumCost += costHead;
                    Logger.Info("  head comp: " + template.Head.EntityDefault.Name + " q:" + component.Amount + " mavg: " + marketAverageHead + " cost:" + costHead);
                }
                else
                {
                    Logger.Info("    comp WTF - no trade - " + template.Head.EntityDefault.Name);
                }

                var marketAverageChassis = GetAverageWorldPriceByComponents(template.Chassis.EntityDefault);
                var costChassis          = component.Amount * marketAverageChassis;

                if (marketAverageChassis > 0)
                {
                    sumCost += costChassis;
                    Logger.Info("   chassis comp: " + template.Chassis.EntityDefault.Name + " q:" + component.Amount + " mavg: " + marketAverageChassis + " cost:" + costChassis);
                }
                else
                {
                    Logger.Info("    comp WTF - no trade - " + template.Chassis.EntityDefault.Name);
                }

                var marketAverageLeg = GetAverageWorldPriceByComponents(template.Leg.EntityDefault);
                var costLeg          = component.Amount * marketAverageLeg;

                if (marketAverageLeg > 0)
                {
                    sumCost += costLeg;
                    Logger.Info("   leg comp: " + template.Leg.EntityDefault.Name + " q:" + component.Amount + " mavg: " + marketAverageLeg + " cost:" + costLeg);
                }
                else
                {
                    Logger.Info("    comp WTF - no trade - " + template.Leg.EntityDefault.Name);
                }
            }

            Logger.Info("total comp sum for " + entityDefault.Name + "  " + sumCost);
            return(sumCost);
        }
 public static Coin CreateASICoin(int amount)
 {
     return(new Coin(EntityDefault.GetByName(DefinitionNames.ASI_MISSION_COIN), amount));
 }
 public override string ToString()
 {
     return($"productionLineId:{Id}, CharacterId:{CharacterId}, Facility:{FacilityEid}, Definition:{TargetDefinition} {EntityDefault.Get(TargetDefinition).Name}");
 }
 public static Coin CreateUniversalCoin(int amount)
 {
     return(new Coin(EntityDefault.GetByName(DefinitionNames.UNIVERSAL_MISSION_COIN), amount));
 }
Beispiel #25
0
        public ErrorCodes PrepareResearchKitMerge(
            PublicContainer publicContainer,
            Character character, long target, int quantity,
            out int nextDefinition,
            out int nextLevel,
            out double fullPrice,
            out int availableQuantity,
            out int searchDefinition)
        {
            ErrorCodes ec;

            nextDefinition    = 0;
            nextLevel         = 0;
            fullPrice         = 0;
            availableQuantity = 0;
            searchDefinition  = 0;

            var researchKit = (ResearchKit)publicContainer.GetItem(target, true);

            if (researchKit == null)
            {
                return(ErrorCodes.ItemNotFound);
            }

            var definition = researchKit.Definition;

            searchDefinition = definition;

            EntityDefault ed;

            if (!EntityDefault.TryGet(definition, out ed))
            {
                return(ErrorCodes.DefinitionNotSupported);
            }

            int level = ed.Options.Level;

            if (level == 0)
            {
                Logger.Error("no level was defined for research kit: " + ed.Name + " " + ed.Definition);
                return(ErrorCodes.ConsistencyError);
            }

            if (level == 10)
            {
                return(ErrorCodes.MaximumResearchLevelReached);
            }

            nextLevel = level + 1;

            var sameDefinitions = publicContainer.GetItems().Where(i => i.Definition == definition).Sum(i => i.Quantity);

            if (sameDefinitions % 2 == 1)
            {
                sameDefinitions--;
            }

            var pairs = sameDefinitions / 2;

            if ((ec = ProductionHelper.FindResearchKitDefinitionByLevel(nextLevel, out nextDefinition)) != ErrorCodes.NoError)
            {
                return(ec);
            }

            availableQuantity = Math.Min(pairs, quantity);

            fullPrice = GetReserchKitMergePrice(nextLevel, character) * availableQuantity;

            return(ec);
        }
        public void ScaleComponentsAmount(double scale, CategoryFlags targetCategoryFlag, CategoryFlags componentCategory)
        {
            var descriptions = _productionDescriptions.Values.Where(productionDescription => EntityDefault.Get(productionDescription.definition).CategoryFlags.IsCategory(targetCategoryFlag));

            foreach (var productionDescription in descriptions)
            {
                productionDescription.ScaleComponents(scale, componentCategory);
            }

            _productionDescriptionCache = null;
            _productionDescriptions.Clear();
            InitProductionDescriptions();
        }
Beispiel #27
0
        public void HandleRequest(IRequest request)
        {
            var rootEID = request.Data.GetOrDefault <long>(k.eid);

            var character = request.Session.Character;
            var owner     = character.Eid;

            var records = Enumerable.Select(Db.Query().CommandText("getitemsummary")
                                            .SetParameter("@ownerEID", owner)
                                            .SetParameter("@rootEID", rootEID)
                                            .Execute(), r =>
            {
                return(new
                {
                    definition = r.GetValue <int>(0),
                    parent = r.GetValue <long>(1),
                    qty = r.GetValue <long>(2)
                });
            }).ToList();

            var itemsDict = new Dictionary <string, object>();
            var count     = 0;
            var parents   = new List <long>(records.Count);

            foreach (var record in records)
            {
                var l = record.qty;
                if (l >= int.MaxValue)
                {
                    l = int.MaxValue;
                }

                var quantitySum = (int)l;

                if (!EntityDefault.TryGet(record.definition, out EntityDefault ed))
                {
                    continue;
                }

                if (!(ed.CategoryFlags.IsCategory(CategoryFlags.cf_robot_equipment) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_robots) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_ammo) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_material) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_documents) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_dogtags) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_production_items) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_mission_items) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_field_accessories) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_container) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_dynamic_cprg) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_scan_result) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_redeemables) ||
                      ed.CategoryFlags.IsCategory(CategoryFlags.cf_pbs_capsules)))
                {
                    continue;
                }

                var oneEntry = new Dictionary <string, object>
                {
                    { k.definition, record.definition },
                    { k.parent, record.parent },
                    { k.quantity, quantitySum }
                };

                parents.Add(record.parent);

                itemsDict.Add("c" + count++, oneEntry);
                Logger.DebugInfo($"{record.parent} {EntityDefault.Get(record.definition).Name} {quantitySum}");
            }

            var result = new Dictionary <string, object>
            {
                { k.items, itemsDict },
                { k.rootEID, rootEID }
            };

            if (parents.Count > 0)
            {
                var parentStr     = parents.ArrayToString();
                var counter       = 0;
                var parentsDict   = new Dictionary <string, object>();
                var secondParents = new List <long>();

                var dataRecords = Db.Query().CommandText($"select eid,ename,parent,definition from entities where eid in ({parentStr})").Execute();

                foreach (var r in dataRecords)
                {
                    var secondDefinition = r.GetValue <int>(3);
                    var secondParent     = r.GetValue <long?>(2);

                    EntityDefault ed;
                    if (!EntityDefault.TryGet(secondDefinition, out ed))
                    {
                        continue;
                    }

                    if (ed.CategoryFlags.IsCategory(CategoryFlags.cf_volume_wrapper_container))
                    {
                        continue;
                    }


                    if (secondParent != null && secondParent > 0)
                    {
                        secondParents.Add((long)secondParent);
                    }

                    var oneEntry =
                        new Dictionary <string, object>
                    {
                        { k.eid, r.GetValue <long>(0) },
                        { k.eName, r.GetValue <string>(1) },
                        { k.parent, secondParent },
                        { k.definition, secondDefinition }
                    };


                    parentsDict.Add("p" + counter++, oneEntry);
                }


                if (secondParents.Count > 0)
                {
                    var secondParentStr = secondParents.Except(parents).ArrayToString();


                    foreach (var r in Db.Query().CommandText("select eid,ename,parent,definition from entities where eid in (" + secondParentStr + ")").Execute())
                    {
                        var oneEntry =
                            new Dictionary <string, object>
                        {
                            { k.eid, r.GetValue <long>(0) },
                            { k.eName, r.GetValue <string>(1) },
                            { k.parent, r.GetValue <long>(2) },
                            { k.definition, r.GetValue <int>(3) }
                        };

                        parentsDict.Add("p" + counter++, oneEntry);
                    }
                }


                result.Add(k.data, parentsDict);


                foreach (var pair in parentsDict)
                {
                    var v = (Dictionary <string, object>)pair.Value;
                    Logger.DebugInfo($"{v[k.eid]} {v[k.parent]} {v[k.eName]} {EntityDefault.Get((int)v[k.definition]).Name}");
                }
            }

            Message.Builder.FromRequest(request).WithData(result).Send();
        }
Beispiel #28
0
        private void GetSuppliedItem(Player player)
        {
            if (!player.InZone)
            {
                return;
            }

            //csak mission felveve

            var supplyTargets = player.MissionHandler.GetTargetsForMissionStructure(this);

            if (supplyTargets.Count == 0)
            {
                return;
            }

            using (var scope = Db.CreateTransaction())
            {
                try
                {
                    var container = player.GetContainer();
                    Debug.Assert(container != null, "container != null");
                    container.EnlistTransaction();
                    //spawn item to player

                    var spawnedItems = new List <Item>();

                    foreach (var targetBase in supplyTargets.Cast <ItemSupplyZoneTarget>())
                    {
                        var goalQuantity   = targetBase.MyTarget.ValidQuantitySet ? targetBase.MyTarget.Quantity : 1;
                        var alreadyGiven   = targetBase.GetCurrentProgress();
                        var quantityNeeded = (goalQuantity - alreadyGiven).Clamp(0, goalQuantity);
                        if (quantityNeeded == 0)
                        {
                            Logger.Error("WTF in GetSuppliedItem " + targetBase.MyTarget);
                            continue;
                        }

                        var itemEd   = EntityDefault.Get(targetBase.MyTarget.Definition);
                        var quantity = container.GetMaximalQuantity(itemEd, quantityNeeded);

                        if (quantity <= 0)
                        {
                            // clarify gameplay
                            Message.Builder.SetCommand(Commands.MissionError).WithData(container.GetCapacityInfo()).ToCharacter(player.Character).WithError(ErrorCodes.ContainerIsFull).Send();
                            continue;
                        }

                        var item = (Item)Factory.CreateWithRandomEID(itemEd);
                        item.Owner    = player.Character.Eid;
                        item.Quantity = quantity;

                        // ha itt megall akkor rosszul van kiszamolva a quantity
                        Debug.Assert(container.IsEnoughCapacity(item), "not enough capacity!");

                        //this is the point when the item supply spawns a cprg
                        //collect components here from the mission
                        var randomCalibrationProgram = item as RandomCalibrationProgram;
                        randomCalibrationProgram?.SetComponentsFromRunningTargets(player.Character);

                        container.AddItem(item, false);
                        spawnedItems.Add(item);

                        var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.ItemSupply).SetCharacter(player.Character).SetItem(item);
                        player.Character.LogTransaction(b);
                    }

                    container.Save();

                    Transaction.Current.OnCommited(() =>
                    {
                        foreach (var item in spawnedItems)
                        {
                            player.MissionHandler.EnqueueMissionEventInfo(new ItemSupplyEventInfo(player, item, this, CurrentPosition));
                        }

                        //success beam kirajzolo
                        CreateSuccessBeam(player);

                        container.SendUpdateToOwner();
                        CreateInteractionBeam(player);
                    });

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    var err = ErrorCodes.ServerError;
                    var gex = ex as PerpetuumException;
                    if (gex != null)
                    {
                        err = gex.error;
                        Logger.Exception(ex);
                    }
                    else
                    {
                        Logger.Exception(ex);
                    }

                    player.Character.SendErrorMessage(Commands.MissionError, err);
                }
            }
        }
 public override string ToString()
 {
     return(string.Format("ID:{0} characterID:{1} characterEID:{2} resultDefinition:{3} {9} type:{4} facilityEID:{5} baseEID:{6} price:{7} amountOfCycles:{8}", ID, character.Id, character.Eid, resultDefinition, type, facilityEID, baseEID, Price, amountOfCycles, EntityDefault.Get(resultDefinition).Name));
 }
 public static RobotTemplate GetRelatedTemplateOrDefault(this IRobotTemplateRelations relations, EntityDefault ed)
 {
     return(relations.GetRelatedTemplateOrDefault(ed.Definition));
 }