コード例 #1
0
        public void Tick(Actor self)
        {
            if (queue == null)
            {
                var type = info.ProductionType ?? self.Trait <Production>().Info.Produces.First();

                // Per-actor queue
                queue = self.TraitsImplementing <ProductionQueue>()
                        .FirstOrDefault(q => type == null || type == q.Info.Type);

                if (queue == null)
                {
                    // No queues available - check for classic production queues
                    queue = self.Owner.PlayerActor.TraitsImplementing <ProductionQueue>()
                            .FirstOrDefault(q => type == null || type == q.Info.Type);
                }

                if (queue == null)
                {
                    throw new InvalidOperationException("No queues available for production type '{0}'".F(type));
                }
            }

            var current = queue.CurrentItem();

            value = current != null ? 1 - (float)current.RemainingCost / current.TotalCost : 0;
        }
コード例 #2
0
 public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete)
 {
     Item          = item;
     RemainingTime = TotalTime = 1;
     RemainingCost = TotalCost = cost;
     OnComplete    = onComplete;
     Queue         = queue;
     this.pm       = pm;
 }
コード例 #3
0
 public ProductionItem(ProductionQueue queue, string item, int cost, PowerManager pm, Action onComplete)
 {
     Item          = item;
     RemainingTime = TotalTime = 1;
     RemainingCost = TotalCost = cost;
     OnComplete    = onComplete;
     Queue         = queue;
     this.pm       = pm;
     //Log.Write("debug", "new ProductionItem: {0} time={1} cost={2}", item, time, cost);
 }
コード例 #4
0
		public override bool HandleMouseInput(MouseInput mi)
		{
			if (mi.Event == MouseInputEvent.Scroll)
			{
				Scroll(mi.ScrollDelta);
				return true;
			}

			if (mi.Button != MouseButton.Left)
				return true;

			if (mi.Event == MouseInputEvent.Down && !TakeMouseFocus(mi))
				return true;

			if (!HasMouseFocus)
				return true;

			if (HasMouseFocus && mi.Event == MouseInputEvent.Up)
				return YieldMouseFocus(mi);

			leftPressed = leftButtonRect.Contains(mi.Location);
			rightPressed = rightButtonRect.Contains(mi.Location);
			var leftDisabled = listOffset >= 0;
			var rightDisabled = listOffset <= Bounds.Width - rightButtonRect.Width - leftButtonRect.Width - contentWidth;

			if (leftPressed || rightPressed)
			{
				if ((leftPressed && !leftDisabled) || (rightPressed && !rightDisabled))
					Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
				else
					Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickDisabledSound", null);
			}

			// Check production tabs
			var offsetloc = mi.Location - new int2(leftButtonRect.Right - 1 + (int)listOffset, leftButtonRect.Y);
			if (offsetloc.X > 0 && offsetloc.X < contentWidth)
			{
				CurrentQueue = Groups[queueGroup].Tabs[offsetloc.X / (TabWidth - 1)].Queue;
				Sound.PlayNotification(world.Map.Rules, null, "Sounds", "ClickSound", null);
			}

			return true;
		}