Пример #1
0
        public override Status Process()
        {
            ActivateIfInactive();

            timeFromLastExtraction += Time.deltaTime;

            if (load.IsFull)
            {
                status = Status.Completed;
            }
            else if (yielder.IsDepleted)
            {
                status = Status.Failed;
            }
            else if (timeFromLastExtraction > stats.LoadTime)
            {
                ResourceSet requestAmount = new ResourceSet()
                                            .With(ResourceType.Nectar, yielder.defaultNectarYield)
                                            .With(ResourceType.Pollen, yielder.defaultPollenYield)
                                            .With(ResourceType.Water, yielder.defaultWaterYield)
                                            .With(ResourceType.Beeswax, yielder.defaultBeeswaxYield)
                                            .With(ResourceType.Honey, yielder.defaultHoneyYield)
                                            .With(ResourceType.RoyalJelly, yielder.defaultRoyalJellyYield);

                ResourceSet result = yielder.Yield(requestAmount);

                if (result.IsEmpty())
                {
                    return(Status.Failed);
                }

                load.AddResources(result);
                if (agent.GetComponent <Selectable>().IsSelected)
                {
                    UIController.Instance.SetBeeLoadText(agent);
                }
                timeFromLastExtraction = 0.0f;

                if (ResourceExtracted != null)
                {
                    ResourceExtracted(agent, yielder.gameObject);
                }
            }

            return(status);
        }