Beispiel #1
0
        public override TaskStatus OnUpdate()
        {
            base.OnUpdate();

            GatherStructure gs = citizen.workplace ? citizen.workplace.GetComponent <GatherStructure>() : null;

            outGatherStructure.Value = gs ? gs.gameObject : null;

            return(gs ? TaskStatus.Success : TaskStatus.Failure);
        }
Beispiel #2
0
        public void Hide()
        {
            structure = null;

            canvas.enabled = false;

            if (Player.instance)
            {
                Player.instance.controlsEnabled = true;
            }
        }
Beispiel #3
0
        public void Show(GatherStructure structure)
        {
            this.structure = structure;

            canvas.enabled = true;

            itemNameText.text        = structure.itemType.name;
            itemImage.sprite         = structure.itemType.GenerateThumbnail();
            itemDescriptionText.text = structure.itemType.description;

            UpdateWorkerPanel();

            controlsUnlocked = false;

            Player.instance.controlsEnabled = false;
        }
Beispiel #4
0
        /*
         * is gatherer
         * search storage
         * search item on the ground
         * search source
         * store item
         * gather source
         */

        public override TaskStatus OnUpdate()
        {
            base.OnUpdate();

            outItem.Value    = null;
            outStorage.Value = null;
            outSource.Value  = null;

            GatherStructure gatherStructure = citizen.workplace.GetComponent <GatherStructure>();

            if (!gatherStructure)
            {
                return(TaskStatus.Failure);
            }

            if (SearchFor.NearestStorageStructure(gatherStructure.plot, transform.position, out StorageStructure storage))
            {
                outStorage.Value = storage.gameObject;
            }
            else
            {
                //TODO: "No storage" notification
                return(TaskStatus.Failure);
            }

            if (SearchFor.ItemOnTheGround(gatherStructure.itemType, gatherStructure.plot, gatherStructure.transform.position, out GameObject item))
            {
                outItem.Value = item;
            }
            else
            {
                Source source = gatherStructure.sources.FirstOrDefault(s => s && s.gameObject.activeSelf);
                //Source.list.FindAll(s => s.itemType == gatherStructure.itemType && !s.ReservedBy && s.Health.HP > 0 && Distance.Manhattan2D(gatherStructure.transform.position, s.transform.position) < gatherStructure.rangeOfSearch).OrderBy(s => Distance.Manhattan2D(gatherStructure.transform.position, s.transform.position)).FirstOrDefault();
                if (source)
                {
                    outSource.Value = source.gameObject;
                }
            }

            return(TaskStatus.Success);
        }
Beispiel #5
0
 public static bool GatherStructureWithItemType(ItemType itemType, Vector3 position, out GatherStructure gatherStructure)
 {
     gatherStructure = GatherStructure.list
                       .FindAll(s => s.itemType == itemType)
                       .OrderBy(s => (s.transform.position - position).sqrMagnitude)
                       .FirstOrDefault();
     return(gatherStructure);
 }