Example #1
0
        /// <summary>Get the output item.</summary>
        public override ITrackedStack?GetOutput()
        {
            Tree tree = this.Machine;

            // recalculate drop queue
            var drops = this.ItemDrops.Value;

            if (!drops.Any())
            {
                // seed must be last item dropped, since collecting the seed will reset the stack
                int?seedId = TreeMachine.GetSeedForTree(tree);
                if (seedId.HasValue)
                {
                    drops.Push(seedId.Value);
                }

                // get extra drops
                foreach (int itemId in this.GetRandomExtraDrops())
                {
                    drops.Push(itemId);
                }
            }

            // get next drop
            return(drops.Any()
                ? new TrackedItem(new SObject(drops.Peek(), 1), onReduced: this.OnOutputReduced)
                : null);
        }
Example #2
0
        /*********
        ** Private methods
        *********/
        /// <summary>Reset the machine so it's ready to accept a new input.</summary>
        /// <param name="item">The output item that was taken.</param>
        private void OnOutputReduced(Item item)
        {
            Tree tree = this.Machine;

            if (item.ParentSheetIndex == TreeMachine.GetSeedForTree(tree))
            {
                tree.hasSeed.Value = false;
            }

            Stack <int> drops = this.ItemDrops.Value;

            if (drops.Any() && drops.Peek() == item.ParentSheetIndex)
            {
                drops.Pop();
            }
        }
Example #3
0
 /// <summary>Get whether a tree can be automated.</summary>
 /// <param name="tree">The tree to automate.</param>
 public static bool CanAutomate(Tree tree)
 {
     return(TreeMachine.GetSeedForTree(tree) != null);
 }