//load ALL facilities
        private void InitLoadFacilities()
        {
            var counter = 0;

#if DEBUG
            var facilityEids = ProductionHelper.LoadFacilityEidsFromActiveZones();
#else
            var facilityEids = ProductionHelper.LoadAllLiveFacilityEids();
#endif
            foreach (var facilityEid in facilityEids)
            {
                try
                {
                    var facility = (ProductionFacility)Entity.Repository.LoadOrThrow(facilityEid);
                    facility.ProductionProcessor = this;

                    AddFacilityToCache(facility);
                    counter++;
                }
                catch (Exception ex)
                {
                    Logger.Error("error occured loading the facility " + facilityEid + " " + ex.Message);
                }
            }

            Logger.Info(counter + " production facilities cached");
        }
 public void WriteLog()
 {
     ProductionHelper.ProductionLogInsert(character, resultDefinition, GetResultingAmount(), type, CalculateDurationSeconds(), Price, useCorporationWallet);
 }
Beispiel #3
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);
        }
Beispiel #4
0
 public IEnumerable <ProductionLiveComponent> ProcessComponentRequirement(ProductionInProgressType productionType, List <ProductionLiveComponent> foundComponents, int targetAmount, double materialMultiplier)
 {
     return(ProductionHelper.ProcessComponentRequirement(productionType, foundComponents, targetAmount, materialMultiplier, Components));
 }
Beispiel #5
0
 public IEnumerable <ProductionLiveComponent> SearchForAvailableComponents(Container container)
 {
     return(ProductionHelper.SearchForAvailableComponents(container, Components.ToList()));
 }