protected override bool OnHotkeyActivated(KeyInput e) { var player = world.RenderPlayer ?? world.LocalPlayer; var facilities = world.ActorsHavingTrait <Production>() .Where(a => a.Owner == player && a.OccupiesSpace != null && !a.Info.HasTraitInfo <BaseBuildingInfo>() && a.TraitsImplementing <Production>().Any(t => !t.IsTraitDisabled)) .OrderBy(f => f.TraitsImplementing <Production>().First(t => !t.IsTraitDisabled).Info.Produces.First()) .ToList(); if (!facilities.Any()) { return(true); } var next = facilities .SkipWhile(b => !selection.Contains(b)) .Skip(1) .FirstOrDefault(); if (next == null) { next = facilities.First(); } Game.Sound.PlayNotification(world.Map.Rules, null, "Sounds", clickSound, null); selection.Combine(world, new Actor[] { next }, false, true); viewport.Center(selection.Actors); return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { var player = world.RenderPlayer ?? world.LocalPlayer; var harvesters = world.ActorsHavingTrait <Harvester>() .Where(a => a.IsInWorld && a.Owner == player) .ToList(); if (!harvesters.Any()) { return(true); } var next = harvesters .SkipWhile(b => !selection.Contains(b)) .Skip(1) .FirstOrDefault(); if (next == null) { next = harvesters.First(); } selection.Combine(world, new Actor[] { next }, false, true); viewport.Center(selection.Actors); return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { var player = world.RenderPlayer ?? world.LocalPlayer; var bases = world.ActorsHavingTrait <BaseBuilding>() .Where(a => a.Owner == player) .ToList(); // If no BaseBuilding exist pick the first selectable Building. if (!bases.Any()) { var building = world.ActorsHavingTrait <Building>() .FirstOrDefault(a => a.Owner == player && a.Info.HasTraitInfo <SelectableInfo>()); // No buildings left if (building == null) { return(true); } selection.Combine(world, new Actor[] { building }, false, true); viewport.Center(selection.Actors); return(true); } var next = bases .SkipWhile(b => !selection.Contains(b)) .Skip(1) .FirstOrDefault(); if (next == null) { next = bases.First(); } selection.Combine(world, new Actor[] { next }, false, true); viewport.Center(selection.Actors); return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { if (world.IsGameOver) { return(false); } var eligiblePlayers = SelectionUtils.GetPlayersToIncludeInSelection(world); // Select actors on the screen which belong to the current player(s) var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count()) { if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across screen."); } } else { // Select actors in the world that have highest selection priority newSelection = SelectionUtils.SelectActorsInWorld(world, null, eligiblePlayers).SubsetWithHighestSelectionPriority(e.Modifiers).ToList(); if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across map."); } } selection.Combine(world, newSelection, false, false); Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickSound, null); return(true); }
protected override bool OnHotkeyActivated(KeyInput e) { if (world.IsGameOver) { return(false); } if (!selection.Actors.Any()) { TextNotificationsManager.AddFeedbackLine("Nothing selected."); Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickDisabledSound, null); return(false); } var eligiblePlayers = SelectionUtils.GetPlayersToIncludeInSelection(world); var ownedActors = selection.Actors .Where(x => !x.IsDead && eligiblePlayers.Contains(x.Owner)) .ToList(); if (!ownedActors.Any()) { return(false); } // Get all the selected actors' selection classes var selectedClasses = ownedActors .Select(a => a.Trait <ISelectable>().Class) .ToHashSet(); // Select actors on the screen that have the same selection class as one of the already selected actors var newSelection = SelectionUtils.SelectActorsOnScreen(world, worldRenderer, selectedClasses, eligiblePlayers).ToList(); // Check if selecting actors on the screen has selected new units if (newSelection.Count > selection.Actors.Count()) { if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across screen."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across screen."); } } else { // Select actors in the world that have the same selection class as one of the already selected actors newSelection = SelectionUtils.SelectActorsInWorld(world, selectedClasses, eligiblePlayers).ToList(); if (newSelection.Count > 1) { TextNotificationsManager.AddFeedbackLine($"Selected {newSelection.Count} units across map."); } else { TextNotificationsManager.AddFeedbackLine($"Selected one unit across map."); } } selection.Combine(world, newSelection, true, false); Game.Sound.PlayNotification(world.Map.Rules, world.LocalPlayer, "Sounds", ClickSound, null); return(true); }