Exemplo n.º 1
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.Play(SoundType.UI, TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.Play(SoundType.UI, TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            var buildable = CurrentQueue.BuildableItems().FirstOrDefault(a => a.Name == icon.Name);

            if (buildable != null)
            {
                // Queue a new item
                Game.Sound.Play(SoundType.UI, TabClick);
                string notification;
                var    canQueue = CurrentQueue.CanQueue(buildable, out notification);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", notification, World.LocalPlayer.Faction.InternalName);

                if (canQueue)
                {
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.Play(SoundType.UI, TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.Play(SoundType.UI, TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
            {
                // Queue a new item
                Game.Sound.Play(SoundType.UI, TabClick);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
                return(true);
            }

            return(false);
        }
        bool HandleRightClick(ProductionItem item, ProductionIcon icon, bool handleMultiple)
        {
            if (item == null)
            {
                return(false);
            }

            Sound.Play(TabClick);

            if (item.Paused || item.Done || item.TotalCost == item.RemainingCost)
            {
                // Instant cancel of things we have not started yet and things that are finished
                Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name,
                                                        handleMultiple ? 5 : 1));
            }
            else
            {
                // Pause an existing item
                Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
            }

            return(true);
        }
Exemplo n.º 4
0
        bool HandleEvent(ProductionIcon icon, bool isLeftClick, bool handleMultiple)
        {
            var actor = World.Map.Rules.Actors[icon.Name];
            var first = icon.Queued.FirstOrDefault();

            if (isLeftClick)
            {
                // Pick up a completed building
                if (first != null && first.Done && actor.Traits.Contains <BuildingInfo>())
                {
                    Sound.Play(TabClick);
                    World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue, icon.Name);
                }
                else if (first != null && first.Paused)
                {
                    // Resume a paused item
                    Sound.Play(TabClick);
                    World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                }
                else if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
                {
                    // Queue a new item
                    Sound.Play(TabClick);
                    Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name,
                                                           handleMultiple ? 5 : 1));
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }
            else
            {
                // Hold/Cancel an existing item
                if (first != null)
                {
                    Sound.Play(TabClick);

                    // instant cancel of things we havent started yet and things that are finished
                    if (first.Paused || first.Done || first.TotalCost == first.RemainingCost)
                    {
                        Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name,
                                                                handleMultiple ? 5 : 1));
                    }
                    else
                    {
                        Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Country.Race);
                        World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
                    }
                }
                else
                {
                    Sound.Play(DisabledTabClick);
                }
            }

            return(true);
        }
        public override void Tick()
        {
            if (lastIconIdx >= productionIconsBounds.Count)
            {
                TooltipIcon = null;
                return;
            }

            if (TooltipIcon != null && productionIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
            {
                return;
            }

            for (var i = 0; i < productionIconsBounds.Count; i++)
            {
                if (!productionIconsBounds[i].Contains(Viewport.LastMousePos))
                {
                    continue;
                }

                lastIconIdx = i;
                TooltipIcon = productionIcons[i];
                return;
            }

            TooltipIcon = null;
        }
Exemplo n.º 6
0
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, bool handleMultiple)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Sound.Play(TabClick);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Sound.Play(TabClick);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
            {
                // Queue a new item
                Sound.Play(TabClick);
                Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Country.Race);
                World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name,
                                                       handleMultiple ? 5 : 1));
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        public void RefreshIcons()
        {
            icons = new Dictionary <Rectangle, ProductionIcon>();
            var producer = CurrentQueue != null?CurrentQueue.MostLikelyProducer() : default(TraitPair <Production>);

            if (CurrentQueue == null || producer.Trait == null)
            {
                if (DisplayedIconCount != 0)
                {
                    OnIconCountChanged(DisplayedIconCount, 0);
                    DisplayedIconCount = 0;
                }

                return;
            }

            var oldIconCount = DisplayedIconCount;

            DisplayedIconCount = 0;

            var ks      = Game.Settings.Keys;
            var rb      = RenderBounds;
            var faction = producer.Trait.Faction;

            foreach (var item in AllBuildables.Skip(IconRowOffset * Columns).Take(MaxIconRowOffset * Columns))
            {
                var x    = DisplayedIconCount % Columns;
                var y    = DisplayedIconCount / Columns;
                var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);

                var rsi  = item.TraitInfo <RenderSpritesInfo>();
                var icon = new Animation(World, rsi.GetImage(item, World.Map.Rules.Sequences, faction));
                var bi   = item.TraitInfo <BuildableInfo>();
                icon.Play(bi.Icon);

                var pi = new ProductionIcon()
                {
                    Actor             = item,
                    Name              = item.Name,
                    Hotkey            = ks.GetProductionHotkey(DisplayedIconCount),
                    Sprite            = icon.Image,
                    Palette           = worldRenderer.Palette(bi.IconPalette),
                    IconClockPalette  = worldRenderer.Palette(ClockPalette),
                    IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
                    Pos             = new float2(rect.Location),
                    Queued          = currentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                    ProductionQueue = currentQueue
                };

                icons.Add(rect, pi);
                DisplayedIconCount++;
            }

            eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

            if (oldIconCount != DisplayedIconCount)
            {
                OnIconCountChanged(oldIconCount, DisplayedIconCount);
            }
        }
Exemplo n.º 8
0
        protected ObserverProductionIconsWidget(ObserverProductionIconsWidget other)
            : base(other)
        {
            GetPlayer     = other.GetPlayer;
            world         = other.world;
            worldRenderer = other.worldRenderer;
            clocks        = other.clocks;

            IconWidth   = other.IconWidth;
            IconHeight  = other.IconHeight;
            IconSpacing = other.IconSpacing;
            iconSize    = new float2(IconWidth, IconHeight);

            ClockAnimation = other.ClockAnimation;
            ClockSequence  = other.ClockSequence;
            ClockPalette   = other.ClockPalette;

            TooltipIcon    = other.TooltipIcon;
            GetTooltipIcon = () => TooltipIcon;

            MinWidth = other.MinWidth;

            TooltipTemplate  = other.TooltipTemplate;
            TooltipContainer = other.TooltipContainer;

            tooltipContainer = Exts.Lazy(() =>
                                         Ui.Root.Get <TooltipContainerWidget>(TooltipContainer));
        }
Exemplo n.º 9
0
        protected bool PickUpCompletedBuildingIcon(ProductionIcon icon, ProductionItem item)
        {
            var actor = World.Map.Rules.Actors[icon.Name];

            if (item != null && item.Done && actor.HasTraitInfo <BuildingInfo>())
            {
                World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue, icon.Name);
                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        bool HandleEvent(ProductionIcon icon, bool isLeftClick, bool handleMultiple)
        {
            var item    = icon.Queued.FirstOrDefault();
            var handled = isLeftClick ? HandleLeftClick(item, icon, handleMultiple)
                                : HandleRightClick(item, icon, handleMultiple);

            if (!handled)
            {
                Sound.Play(DisabledTabClick);
            }

            return(true);
        }
        void InitIcons(Rectangle renderBounds)
        {
            var iconWidthWithSpacing = IconWidth * 2 + IconSpacing;
            var numOfIcons           = this.Bounds.Width + 8 / iconWidthWithSpacing;

            iconRects = new Rectangle[numOfIcons];
            icons     = new ProductionIcon[numOfIcons];

            for (var i = 0; i < numOfIcons; i++)
            {
                iconRects[i] = new Rectangle(renderBounds.X + i * iconWidthWithSpacing, renderBounds.Y + 3, IconWidth * 2, IconHeight * 2);
                icons[i]     = new ProductionIcon();
            }
        }
Exemplo n.º 12
0
        bool HandleMiddleClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (item == null)
            {
                return(false);
            }

            // Directly cancel, skipping "on-hold"
            Game.Sound.Play(SoundType.UI, TabClick);
            Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
            World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));

            return(true);
        }
Exemplo n.º 13
0
        bool HandleEvent(ProductionIcon icon, MouseButton btn, Modifiers modifiers)
        {
            var startCount  = modifiers.HasModifier(Modifiers.Shift) ? 5 : 1;
            var cancelCount = modifiers.HasModifier(Modifiers.Ctrl) ? CurrentQueue.QueueLength : startCount;
            var item        = icon.Queued.FirstOrDefault();
            var handled     = btn == MouseButton.Left ? HandleLeftClick(item, icon, startCount)
                                : btn == MouseButton.Right ? HandleRightClick(item, icon, cancelCount)
                                : btn == MouseButton.Middle ? HandleMiddleClick(item, icon, cancelCount)
                                : false;

            if (!handled)
            {
                Game.Sound.Play(SoundType.UI, DisabledTabClick);
            }

            return(true);
        }
        public override void Tick()
        {
            if (TooltipIcon != null && iconRects[lastIconIdx].Contains(Viewport.LastMousePos))
            {
                return;
            }

            for (var i = 0; i < iconRects.Length; i++)
            {
                if (iconRects[i].Contains(Viewport.LastMousePos))
                {
                    lastIconIdx = i;
                    TooltipIcon = icons[i];
                    return;
                }
            }

            TooltipIcon = null;
        }
        bool HandleEvent(ProductionIcon icon, MouseButton btn, Modifiers modifiers)
        {
            var startCount = modifiers.HasModifier(Modifiers.Shift) ? 5 : 1;

            // PERF: avoid an unnecessary enumeration by casting back to its known type
            var cancelCount = modifiers.HasModifier(Modifiers.Ctrl) ? ((List <ProductionItem>)CurrentQueue.AllQueued()).Count : startCount;
            var item        = icon.Queued.FirstOrDefault();
            var handled     = btn == MouseButton.Left ? HandleLeftClick(item, icon, startCount, modifiers)
                                : btn == MouseButton.Right ? HandleRightClick(item, icon, cancelCount)
                                : btn == MouseButton.Middle ? HandleMiddleClick(item, icon, cancelCount)
                                : false;

            if (!handled)
            {
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickDisabledSound, null);
            }

            return(true);
        }
Exemplo n.º 16
0
        void IssueOrderForEachSelectedQueue(ProductionItem item, ProductionIcon icon, Func <ProductionQueue, Order> orderProducer)
        {
            var queues = World.Selection.Actors
                         .Where(a => a.IsInWorld && a.World.LocalPlayer == a.Owner)
                         .SelectMany(a => a.TraitsImplementing <ProductionQueue>())
                         .Where(q => q.Enabled && q.BuildableItems().Any(a => a.Name == icon.Name));

            if (queues.Count() == 0)
            {
                World.IssueOrder(orderProducer(currentQueue));
            }
            else
            {
                foreach (ProductionQueue queue in queues)
                {
                    World.IssueOrder(orderProducer(queue));
                }
            }
        }
Exemplo n.º 17
0
        public override void Tick()
        {
            if (TooltipContainer == null)
            {
                return;
            }

            if (Ui.MouseOverWidget != this)
            {
                if (TooltipIcon != null)
                {
                    tooltipContainer.Value.RemoveTooltip(currentTooltipToken);
                    lastIconIdx = 0;
                    TooltipIcon = null;
                }

                return;
            }

            if (TooltipIcon != null && productionIconsBounds.Count > lastIconIdx && productionIcons[lastIconIdx].Actor == TooltipIcon.Actor && productionIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
            {
                return;
            }

            for (var i = 0; i < productionIconsBounds.Count; i++)
            {
                if (!productionIconsBounds[i].Contains(Viewport.LastMousePos))
                {
                    continue;
                }

                lastIconIdx         = i;
                TooltipIcon         = productionIcons[i];
                currentTooltipToken = tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs {
                    { "player", GetPlayer() }, { "getTooltipIcon", GetTooltipIcon }
                });
                return;
            }

            TooltipIcon = null;
        }
        bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount, Modifiers modifiers)
        {
            if (PickUpCompletedBuildingIcon(icon, item))
            {
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                return(true);
            }

            if (item != null && item.Paused)
            {
                // Resume a paused item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
                return(true);
            }

            var buildable = CurrentQueue.BuildableItems().FirstOrDefault(a => a.Name == icon.Name);

            if (buildable != null)
            {
                // Queue a new item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);
                string notification;
                var    canQueue = CurrentQueue.CanQueue(buildable, out notification);

                if (!CurrentQueue.AllQueued().Any())
                {
                    Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", notification, World.LocalPlayer.Faction.InternalName);
                }

                if (canQueue)
                {
                    var queued = !modifiers.HasModifier(Modifiers.Ctrl);
                    World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount, queued));
                    return(true);
                }
            }

            return(false);
        }
        public override void MouseEntered()
        {
            if (TooltipContainer == null)
            {
                return;
            }

            for (var i = 0; i < productionIconsBounds.Count; i++)
            {
                if (!productionIconsBounds[i].Contains(Viewport.LastMousePos))
                {
                    continue;
                }

                TooltipIcon = productionIcons[i];
                break;
            }

            tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs {
                { "player", GetPlayer() }, { "getTooltipIcon", GetTooltipIcon }
            });
        }
        bool HandleRightClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (item == null)
            {
                return(false);
            }

            Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Sounds", ClickSound, null);

            if (CurrentQueue.Info.DisallowPaused || item.Paused || item.Done || item.TotalCost == item.RemainingCost)
            {
                // Instantly cancel items that haven't started, have finished, or if the queue doesn't support pausing
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));
            }
            else
            {
                // Pause an existing item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
                World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
            }

            return(true);
        }
Exemplo n.º 21
0
        bool HandleRightClick(ProductionItem item, ProductionIcon icon, int handleCount)
        {
            if (item == null)
            {
                return(false);
            }

            Game.Sound.Play(SoundType.UI, TabClick);

            if (item.Paused || item.Done || item.TotalCost == item.RemainingCost)
            {
                // Instant cancel of things we have not started yet and things that are finished
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
                IssueOrderForEachSelectedQueue(item, icon, queue => Order.CancelProduction(queue.Actor, icon.Name, handleCount));
            }
            else
            {
                // Pause an existing item
                Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
                IssueOrderForEachSelectedQueue(item, icon, queue => Order.PauseProduction(queue.Actor, icon.Name, true));
            }

            return(true);
        }
Exemplo n.º 22
0
		bool HandleEvent(ProductionIcon icon, bool isLeftClick, bool handleMultiple)
		{
			var item = icon.Queued.FirstOrDefault();
			var handled = isLeftClick ? HandleLeftClick(item, icon, handleMultiple)
				: HandleRightClick(item, icon, handleMultiple);

			if (!handled)
				Sound.Play(DisabledTabClick);

			return true;
		}
Exemplo n.º 23
0
		public void RefreshIcons()
		{
			icons = new Dictionary<Rectangle, ProductionIcon>();
			var producer = CurrentQueue != null ? CurrentQueue.MostLikelyProducer() : default(TraitPair<Production>);
			if (CurrentQueue == null || producer.Trait == null)
			{
				if (DisplayedIconCount != 0)
				{
					OnIconCountChanged(DisplayedIconCount, 0);
					DisplayedIconCount = 0;
				}

				return;
			}

			var oldIconCount = DisplayedIconCount;
			DisplayedIconCount = 0;

			var ks = Game.Settings.Keys;
			var rb = RenderBounds;
			var faction = producer.Trait.Faction;

			foreach (var item in AllBuildables.Skip(IconRowOffset * Columns).Take(MaxIconRowOffset * Columns))
			{
				var x = DisplayedIconCount % Columns;
				var y = DisplayedIconCount / Columns;
				var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);

				var rsi = item.TraitInfo<RenderSpritesInfo>();
				var icon = new Animation(World, rsi.GetImage(item, World.Map.Rules.Sequences, faction));
				icon.Play(item.TraitInfo<TooltipInfo>().Icon);

				var bi = item.TraitInfo<BuildableInfo>();

				var pi = new ProductionIcon()
				{
					Actor = item,
					Name = item.Name,
					Hotkey = ks.GetProductionHotkey(DisplayedIconCount),
					Sprite = icon.Image,
					Palette = worldRenderer.Palette(bi.IconPalette),
					IconClockPalette = worldRenderer.Palette(ClockPalette),
					IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
					Pos = new float2(rect.Location),
					Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList()
				};

				icons.Add(rect, pi);
				DisplayedIconCount++;
			}

			eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

			if (oldIconCount != DisplayedIconCount)
				OnIconCountChanged(oldIconCount, DisplayedIconCount);
		}
Exemplo n.º 24
0
		bool HandleEvent(ProductionIcon icon, MouseButton btn, Modifiers modifiers)
		{
			var startCount = modifiers.HasModifier(Modifiers.Shift) ? 5 : 1;
			var cancelCount = modifiers.HasModifier(Modifiers.Ctrl) ? CurrentQueue.QueueLength : startCount;
			var item = icon.Queued.FirstOrDefault();
			var handled = btn == MouseButton.Left ? HandleLeftClick(item, icon, startCount)
				: btn == MouseButton.Right ? HandleRightClick(item, icon, cancelCount)
				: btn == MouseButton.Middle ? HandleMiddleClick(item, icon, cancelCount)
				: false;

			if (!handled)
				Game.Sound.Play(DisabledTabClick);

			return true;
		}
Exemplo n.º 25
0
		bool HandleMiddleClick(ProductionItem item, ProductionIcon icon, int handleCount)
		{
			if (item == null)
				return false;

			// Directly cancel, skipping "on-hold"
			Game.Sound.Play(TabClick);
			Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
			World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));

			return true;
		}
Exemplo n.º 26
0
		bool HandleRightClick(ProductionItem item, ProductionIcon icon, int handleCount)
		{
			if (item == null)
				return false;

			Game.Sound.Play(TabClick);

			if (item.Paused || item.Done || item.TotalCost == item.RemainingCost)
			{
				// Instant cancel of things we have not started yet and things that are finished
				Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.CancelledAudio, World.LocalPlayer.Faction.InternalName);
				World.IssueOrder(Order.CancelProduction(CurrentQueue.Actor, icon.Name, handleCount));
			}
			else
			{
				// Pause an existing item
				Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.OnHoldAudio, World.LocalPlayer.Faction.InternalName);
				World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, true));
			}

			return true;
		}
Exemplo n.º 27
0
		bool HandleLeftClick(ProductionItem item, ProductionIcon icon, int handleCount)
		{
			if (PickUpCompletedBuildingIcon(icon, item))
			{
				Game.Sound.Play(TabClick);
				return true;
			}

			if (item != null && item.Paused)
			{
				// Resume a paused item
				Game.Sound.Play(TabClick);
				World.IssueOrder(Order.PauseProduction(CurrentQueue.Actor, icon.Name, false));
				return true;
			}

			if (CurrentQueue.BuildableItems().Any(a => a.Name == icon.Name))
			{
				// Queue a new item
				Game.Sound.Play(TabClick);
				Game.Sound.PlayNotification(World.Map.Rules, World.LocalPlayer, "Speech", CurrentQueue.Info.QueuedAudio, World.LocalPlayer.Faction.InternalName);
				World.IssueOrder(Order.StartProduction(CurrentQueue.Actor, icon.Name, handleCount));
				return true;
			}

			return false;
		}
Exemplo n.º 28
0
		protected bool PickUpCompletedBuildingIcon(ProductionIcon icon, ProductionItem item)
		{
			var actor = World.Map.Rules.Actors[icon.Name];

			if (item != null && item.Done && actor.HasTraitInfo<BuildingInfo>())
			{
				World.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue, icon.Name);
				return true;
			}

			return false;
		}