Ejemplo n.º 1
0
        private void FillProcessorMap()
        {
            if (this.processorMap.Count > 0)
            {
                Service.Get <StaRTSLogger>().Error("Attempting to fill an already-full processorMap!");
            }
            CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>();
            string        planetId      = currentPlayer.PlanetId;

            if (currentPlayer.Objectives.ContainsKey(planetId))
            {
                ObjectiveGroup objectiveGroup = currentPlayer.Objectives[planetId];
                int            i     = 0;
                int            count = objectiveGroup.ProgressObjects.Count;
                while (i < count)
                {
                    ObjectiveProgress objectiveProgress = objectiveGroup.ProgressObjects[i];
                    if (objectiveProgress.State == ObjectiveState.Active)
                    {
                        AbstractObjectiveProcessor processor = ObjectiveFactory.GetProcessor(objectiveProgress.VO, this);
                        this.processorMap.Add(processor, objectiveProgress);
                    }
                    i++;
                }
            }
        }
Ejemplo n.º 2
0
        public void Progress(AbstractObjectiveProcessor processor, int amount)
        {
            if (Service.Get <PlanetRelocationController>().IsRelocationInProgress())
            {
                return;
            }
            if (!this.processorMap.ContainsKey(processor))
            {
                return;
            }
            EventManager      eventManager      = Service.Get <EventManager>();
            ObjectiveProgress objectiveProgress = this.processorMap[processor];

            objectiveProgress.Count = Math.Min(objectiveProgress.Count + amount, objectiveProgress.Target);
            if (objectiveProgress.Count >= objectiveProgress.Target)
            {
                objectiveProgress.State = ObjectiveState.Complete;
                eventManager.SendEvent(EventId.UpdateObjectiveToastData, objectiveProgress);
                eventManager.SendEvent(EventId.ObjectiveCompleted, null);
                this.processorMap.Remove(processor);
                processor.Destroy();
            }
            eventManager.SendEvent(EventId.ObjectivesUpdated, objectiveProgress);
        }