Use Tuple syntax
This commit is contained in:
@@ -201,16 +201,16 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (nextCell == null)
|
||||
return false;
|
||||
|
||||
var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.First, mobile.Facing);
|
||||
var firstFacing = self.World.Map.FacingBetween(mobile.FromCell, nextCell.Value.Cell, mobile.Facing);
|
||||
if (firstFacing != mobile.Facing)
|
||||
{
|
||||
path.Add(nextCell.Value.First);
|
||||
path.Add(nextCell.Value.Cell);
|
||||
QueueChild(new Turn(self, firstFacing));
|
||||
mobile.TurnToMove = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, nextCell.Value.First, nextCell.Value.Second);
|
||||
mobile.SetLocation(mobile.FromCell, mobile.FromSubCell, nextCell.Value.Cell, nextCell.Value.SubCell);
|
||||
|
||||
var map = self.World.Map;
|
||||
var from = (mobile.FromCell.Layer == 0 ? map.CenterOfCell(mobile.FromCell) :
|
||||
@@ -224,7 +224,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return false;
|
||||
}
|
||||
|
||||
Pair<CPos, SubCell>? PopPath(Actor self)
|
||||
(CPos Cell, SubCell SubCell)? PopPath(Actor self)
|
||||
{
|
||||
if (path.Count == 0)
|
||||
return null;
|
||||
@@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var newCell = path[path.Count - 1];
|
||||
path.RemoveAt(path.Count - 1);
|
||||
|
||||
return Pair.New(newCell, mobile.GetAvailableSubCell(nextCell, mobile.FromSubCell, ignoreActor));
|
||||
return (newCell, mobile.GetAvailableSubCell(nextCell, mobile.FromSubCell, ignoreActor));
|
||||
}
|
||||
else if (mobile.IsBlocking)
|
||||
{
|
||||
@@ -321,7 +321,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if ((nextCell - newCell).Value.LengthSquared > 2)
|
||||
path.Add(mobile.ToCell);
|
||||
|
||||
return Pair.New(newCell.Value, mobile.GetAvailableSubCell(newCell.Value, mobile.FromSubCell, ignoreActor));
|
||||
return (newCell.Value, mobile.GetAvailableSubCell(newCell.Value, mobile.FromSubCell, ignoreActor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
hasWaited = false;
|
||||
path.RemoveAt(path.Count - 1);
|
||||
|
||||
return Pair.New(nextCell, mobile.GetAvailableSubCell(nextCell, mobile.FromSubCell, ignoreActor));
|
||||
return (nextCell, mobile.GetAvailableSubCell(nextCell, mobile.FromSubCell, ignoreActor));
|
||||
}
|
||||
|
||||
protected override void OnLastRun(Actor self)
|
||||
@@ -518,23 +518,23 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var nextCell = parent.PopPath(self);
|
||||
if (nextCell != null)
|
||||
{
|
||||
if (!mobile.IsTraitPaused && !mobile.IsTraitDisabled && IsTurn(mobile, nextCell.Value.First, map))
|
||||
if (!mobile.IsTraitPaused && !mobile.IsTraitDisabled && IsTurn(mobile, nextCell.Value.Cell, map))
|
||||
{
|
||||
var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.Second);
|
||||
var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.SubCell);
|
||||
var ret = new MoveFirstHalf(
|
||||
Move,
|
||||
Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2,
|
||||
Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
|
||||
Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.Cell) + (toSubcellOffset + nextSubcellOffset) / 2,
|
||||
mobile.Facing,
|
||||
map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing),
|
||||
map.FacingBetween(mobile.ToCell, nextCell.Value.Cell, mobile.Facing),
|
||||
moveFraction - MoveFractionTotal);
|
||||
|
||||
mobile.FinishedMoving(self);
|
||||
mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second);
|
||||
mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.Cell, nextCell.Value.SubCell);
|
||||
return ret;
|
||||
}
|
||||
|
||||
parent.path.Add(nextCell.Value.First);
|
||||
parent.path.Add(nextCell.Value.Cell);
|
||||
}
|
||||
|
||||
var toPos = mobile.ToCell.Layer == 0 ? map.CenterOfCell(mobile.ToCell) :
|
||||
|
||||
@@ -50,15 +50,15 @@ namespace OpenRA.Mods.Common.Activities
|
||||
this.unloadRange = unloadRange;
|
||||
}
|
||||
|
||||
public Pair<CPos, SubCell>? ChooseExitSubCell(Actor passenger)
|
||||
public (CPos Cell, SubCell SubCell)? ChooseExitSubCell(Actor passenger)
|
||||
{
|
||||
var pos = passenger.Trait<IPositionable>();
|
||||
|
||||
return cargo.CurrentAdjacentCells
|
||||
.Shuffle(self.World.SharedRandom)
|
||||
.Select(c => Pair.New(c, pos.GetAvailableSubCell(c)))
|
||||
.Cast<Pair<CPos, SubCell>?>()
|
||||
.FirstOrDefault(s => s.Value.Second != SubCell.Invalid);
|
||||
.Select(c => (c, pos.GetAvailableSubCell(c)))
|
||||
.Cast<(CPos, SubCell SubCell)?>()
|
||||
.FirstOrDefault(s => s.Value.SubCell != SubCell.Invalid);
|
||||
}
|
||||
|
||||
IEnumerable<CPos> BlockedExitCells(Actor passenger)
|
||||
@@ -121,7 +121,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var move = actor.Trait<IMove>();
|
||||
var pos = actor.Trait<IPositionable>();
|
||||
|
||||
pos.SetPosition(actor, exitSubCell.Value.First, exitSubCell.Value.Second);
|
||||
pos.SetPosition(actor, exitSubCell.Value.Cell, exitSubCell.Value.SubCell);
|
||||
pos.SetVisualPosition(actor, spawn);
|
||||
|
||||
actor.CancelActivity();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var dest = new CellRegion(gridType, source.TopLeft + offset, source.BottomRight + offset);
|
||||
|
||||
var previews = new Dictionary<string, ActorReference>();
|
||||
var tiles = new Dictionary<CPos, Tuple<TerrainTile, ResourceTile, byte>>();
|
||||
var tiles = new Dictionary<CPos, (TerrainTile, ResourceTile, byte)>();
|
||||
var copyFilters = getCopyFilters();
|
||||
|
||||
foreach (var cell in source)
|
||||
@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
if (!mapTiles.Contains(cell) || !mapTiles.Contains(cell + offset))
|
||||
continue;
|
||||
|
||||
tiles.Add(cell + offset, Tuple.Create(mapTiles[cell], mapResources[cell], mapHeight[cell]));
|
||||
tiles.Add(cell + offset, (mapTiles[cell], mapResources[cell], mapHeight[cell]));
|
||||
|
||||
if (copyFilters.HasFlag(MapCopyFilters.Actors))
|
||||
{
|
||||
@@ -178,7 +178,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public string Text { get; private set; }
|
||||
|
||||
readonly MapCopyFilters copyFilters;
|
||||
readonly Dictionary<CPos, Tuple<TerrainTile, ResourceTile, byte>> tiles;
|
||||
readonly Dictionary<CPos, (TerrainTile Tile, ResourceTile Resource, byte Height)> tiles;
|
||||
readonly Dictionary<string, ActorReference> previews;
|
||||
readonly EditorActorLayer editorLayer;
|
||||
readonly CellRegion dest;
|
||||
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
readonly Queue<EditorActorPreview> addedActorPreviews = new Queue<EditorActorPreview>();
|
||||
|
||||
public CopyPasteEditorAction(MapCopyFilters copyFilters, Map map,
|
||||
Dictionary<CPos, Tuple<TerrainTile, ResourceTile, byte>> tiles, Dictionary<string, ActorReference> previews,
|
||||
Dictionary<CPos, (TerrainTile, ResourceTile, byte)> tiles, Dictionary<string, ActorReference> previews,
|
||||
EditorActorLayer editorLayer, CellRegion dest)
|
||||
{
|
||||
this.copyFilters = copyFilters;
|
||||
@@ -219,12 +219,12 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
undoCopyPastes.Enqueue(new UndoCopyPaste(kv.Key, mapTiles[kv.Key], mapResources[kv.Key], mapHeight[kv.Key]));
|
||||
|
||||
if (copyFilters.HasFlag(MapCopyFilters.Terrain))
|
||||
mapTiles[kv.Key] = kv.Value.Item1;
|
||||
mapTiles[kv.Key] = kv.Value.Tile;
|
||||
|
||||
if (copyFilters.HasFlag(MapCopyFilters.Resources))
|
||||
mapResources[kv.Key] = kv.Value.Item2;
|
||||
mapResources[kv.Key] = kv.Value.Resource;
|
||||
|
||||
mapHeight[kv.Key] = kv.Value.Item3;
|
||||
mapHeight[kv.Key] = kv.Value.Height;
|
||||
}
|
||||
|
||||
if (copyFilters.HasFlag(MapCopyFilters.Actors))
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
// HACK: We don't have enough texture channels to pass the depth data to the shader
|
||||
// so for now just offset everything forward so that the back corner is rendered at pos.
|
||||
pxOrigin -= new float3(0, 0, Screen3DBounds(wr).Second.X);
|
||||
pxOrigin -= new float3(0, 0, Screen3DBounds(wr).Z.X);
|
||||
|
||||
var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1));
|
||||
|
||||
@@ -221,10 +221,10 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr)
|
||||
{
|
||||
return Screen3DBounds(wr).First;
|
||||
return Screen3DBounds(wr).Bounds;
|
||||
}
|
||||
|
||||
Pair<Rectangle, float2> Screen3DBounds(WorldRenderer wr)
|
||||
(Rectangle Bounds, float2 Z) Screen3DBounds(WorldRenderer wr)
|
||||
{
|
||||
var pxOrigin = wr.ScreenPosition(model.pos);
|
||||
var draw = model.models.Where(v => v.IsVisible);
|
||||
@@ -260,7 +260,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.New(Rectangle.FromLTRB((int)minX, (int)minY, (int)maxX, (int)maxY), new float2(minZ, maxZ));
|
||||
return (Rectangle.FromLTRB((int)minX, (int)minY, (int)maxX, (int)maxY), new float2(minZ, maxZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +106,13 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
public Rectangle ScreenBounds(WorldRenderer wr)
|
||||
{
|
||||
return Screen3DBounds(wr).First;
|
||||
return Screen3DBounds(wr).Bounds;
|
||||
}
|
||||
|
||||
static readonly uint[] CornerXIndex = { 0, 0, 0, 0, 3, 3, 3, 3 };
|
||||
static readonly uint[] CornerYIndex = { 1, 1, 4, 4, 1, 1, 4, 4 };
|
||||
static readonly uint[] CornerZIndex = { 2, 5, 2, 5, 2, 5, 2, 5 };
|
||||
Pair<Rectangle, float2> Screen3DBounds(WorldRenderer wr)
|
||||
(Rectangle Bounds, float2 Z) Screen3DBounds(WorldRenderer wr)
|
||||
{
|
||||
var pxOrigin = model.screenPos;
|
||||
var draw = model.models.Where(v => v.IsVisible);
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
return Pair.New(Rectangle.FromLTRB((int)minX, (int)minY, (int)maxX, (int)maxY), new float2(minZ, maxZ));
|
||||
return (Rectangle.FromLTRB((int)minX, (int)minY, (int)maxX, (int)maxY), new float2(minZ, maxZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
var checkWidgetFields = modData.ObjectCreator.GetTypesImplementing<Widget>()
|
||||
.SelectMany(w => w.GetFields()
|
||||
.Where(f => f.FieldType == typeof(HotkeyReference))
|
||||
.Select(f => Pair.New(w.Name.Substring(0, w.Name.Length - 6), f.Name)))
|
||||
.Select(f => (w.Name.Substring(0, w.Name.Length - 6), f.Name)))
|
||||
.ToArray();
|
||||
|
||||
var customLintMethods = new Dictionary<string, List<string>>();
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Common.Lint
|
||||
}
|
||||
}
|
||||
|
||||
void CheckInner(ModData modData, string[] namedKeys, Pair<string, string>[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
|
||||
void CheckInner(ModData modData, string[] namedKeys, (string Widget, string Field)[] checkWidgetFields, Dictionary<string, List<string>> customLintMethods,
|
||||
List<MiniYamlNode> nodes, string filename, MiniYamlNode parent, Action<string> emitError, Action<string> emitWarning)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
@@ -74,19 +74,17 @@ namespace OpenRA.Mods.Common.Lint
|
||||
|
||||
foreach (var x in checkWidgetFields)
|
||||
{
|
||||
if (node.Key == x.Second && parent != null && parent.Key.StartsWith(x.First, StringComparison.Ordinal))
|
||||
if (node.Key == x.Field && parent != null && parent.Key.StartsWith(x.Widget, StringComparison.Ordinal))
|
||||
{
|
||||
// Keys are valid if they refer to a named key or can be parsed as a regular Hotkey.
|
||||
Hotkey unused;
|
||||
if (!namedKeys.Contains(node.Value.Value) && !Hotkey.TryParse(node.Value.Value, out unused))
|
||||
if (!namedKeys.Contains(node.Value.Value) && !Hotkey.TryParse(node.Value.Value, out var unused))
|
||||
emitError("{0} refers to a Key named `{1}` that does not exist".F(node.Location, node.Value.Value));
|
||||
}
|
||||
}
|
||||
|
||||
// Check runtime-defined hotkey names
|
||||
List<string> checkMethods;
|
||||
var widgetType = node.Key.Split('@')[0];
|
||||
if (customLintMethods.TryGetValue(widgetType, out checkMethods))
|
||||
if (customLintMethods.TryGetValue(widgetType, out var checkMethods))
|
||||
{
|
||||
var type = modData.ObjectCreator.FindType(widgetType + "Widget");
|
||||
var keyNames = checkMethods.SelectMany(m => (IEnumerable<string>)type.GetMethod(m).Invoke(null, new object[] { node, emitError, emitWarning }));
|
||||
@@ -111,10 +109,9 @@ namespace OpenRA.Mods.Common.Lint
|
||||
checkArgKeys.AddRange(type.GetCustomAttributes<ChromeLogicArgsHotkeys>(true).SelectMany(x => x.LogicArgKeys));
|
||||
}
|
||||
|
||||
Hotkey unused;
|
||||
foreach (var n in node.Value.Nodes)
|
||||
if (checkArgKeys.Contains(n.Key))
|
||||
if (!namedKeys.Contains(n.Value.Value) && !Hotkey.TryParse(n.Value.Value, out unused))
|
||||
if (!namedKeys.Contains(n.Value.Value) && !Hotkey.TryParse(n.Value.Value, out var unused))
|
||||
emitError("{0} {1}:{2} refers to a Key named `{3}` that does not exist".F(filename, node.Value.Value, n.Key, n.Value.Value));
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Optimize>true</Optimize>
|
||||
<LangVersion>5</LangVersion>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<OutputPath>../mods/common</OutputPath>
|
||||
|
||||
@@ -262,9 +262,9 @@ namespace OpenRA.Mods.Common.Orders
|
||||
{
|
||||
foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, actorInfo, buildingInfo, owner))
|
||||
{
|
||||
var lineBuildable = world.IsCellBuildable(t.First, actorInfo, buildingInfo);
|
||||
var lineCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, actorInfo, t.First);
|
||||
footprint.Add(t.First, MakeCellType(lineBuildable && lineCloseEnough, true));
|
||||
var lineBuildable = world.IsCellBuildable(t.Cell, actorInfo, buildingInfo);
|
||||
var lineCloseEnough = buildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, actorInfo, t.Cell);
|
||||
footprint.Add(t.Cell, MakeCellType(lineBuildable && lineCloseEnough, true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
/// <summary>
|
||||
/// Stores the analyzed nodes by the expand function
|
||||
/// </summary>
|
||||
IEnumerable<Pair<CPos, int>> Considered { get; }
|
||||
IEnumerable<(CPos Cell, int Cost)> Considered { get; }
|
||||
|
||||
Player Owner { get; }
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
|
||||
protected IPriorityQueue<GraphConnection> OpenQueue { get; private set; }
|
||||
|
||||
public abstract IEnumerable<Pair<CPos, int>> Considered { get; }
|
||||
public abstract IEnumerable<(CPos Cell, int Cost)> Considered { get; }
|
||||
|
||||
public Player Owner { get { return Graph.Actor.Owner; } }
|
||||
public int MaxCost { get; protected set; }
|
||||
|
||||
@@ -92,8 +92,8 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
readonly bool checkTerrainHeight;
|
||||
CellLayer<CellInfo> groundInfo;
|
||||
|
||||
readonly Dictionary<byte, Pair<ICustomMovementLayer, CellLayer<CellInfo>>> customLayerInfo =
|
||||
new Dictionary<byte, Pair<ICustomMovementLayer, CellLayer<CellInfo>>>();
|
||||
readonly Dictionary<byte, (ICustomMovementLayer Layer, CellLayer<CellInfo> Info)> customLayerInfo =
|
||||
new Dictionary<byte, (ICustomMovementLayer, CellLayer<CellInfo>)>();
|
||||
|
||||
public PathGraph(CellInfoLayerPool layerPool, Locomotor locomotor, Actor actor, World world, BlockedByActor check)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
.Where(cml => cml.EnabledForActor(actor.Info, locomotorInfo));
|
||||
|
||||
foreach (var cml in layers)
|
||||
customLayerInfo[cml.Index] = Pair.New(cml, pooledLayer.GetLayer());
|
||||
customLayerInfo[cml.Index] = (cml, pooledLayer.GetLayer());
|
||||
|
||||
World = world;
|
||||
worldMovementInfo = locomotorInfo.GetWorldMovementInfo(world);
|
||||
@@ -135,7 +135,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
|
||||
public List<GraphConnection> GetConnections(CPos position)
|
||||
{
|
||||
var info = position.Layer == 0 ? groundInfo : customLayerInfo[position.Layer].Second;
|
||||
var info = position.Layer == 0 ? groundInfo : customLayerInfo[position.Layer].Info;
|
||||
var previousPos = info[position].PreviousPos;
|
||||
|
||||
var dx = position.X - previousPos.X;
|
||||
@@ -156,8 +156,8 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
{
|
||||
foreach (var cli in customLayerInfo.Values)
|
||||
{
|
||||
var layerPosition = new CPos(position.X, position.Y, cli.First.Index);
|
||||
var entryCost = cli.First.EntryMovementCost(Actor.Info, locomotor.Info, layerPosition);
|
||||
var layerPosition = new CPos(position.X, position.Y, cli.Layer.Index);
|
||||
var entryCost = cli.Layer.EntryMovementCost(Actor.Info, locomotor.Info, layerPosition);
|
||||
if (entryCost != CostForInvalidCell)
|
||||
validNeighbors.Add(new GraphConnection(layerPosition, entryCost));
|
||||
}
|
||||
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
else
|
||||
{
|
||||
var layerPosition = new CPos(position.X, position.Y, 0);
|
||||
var exitCost = customLayerInfo[position.Layer].First.ExitMovementCost(Actor.Info, locomotor.Info, layerPosition);
|
||||
var exitCost = customLayerInfo[position.Layer].Layer.ExitMovementCost(Actor.Info, locomotor.Info, layerPosition);
|
||||
if (exitCost != CostForInvalidCell)
|
||||
validNeighbors.Add(new GraphConnection(layerPosition, exitCost));
|
||||
}
|
||||
@@ -224,8 +224,8 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
|
||||
public CellInfo this[CPos pos]
|
||||
{
|
||||
get { return (pos.Layer == 0 ? groundInfo : customLayerInfo[pos.Layer].Second)[pos]; }
|
||||
set { (pos.Layer == 0 ? groundInfo : customLayerInfo[pos.Layer].Second)[pos] = value; }
|
||||
get { return (pos.Layer == 0 ? groundInfo : customLayerInfo[pos.Layer].Info)[pos]; }
|
||||
set { (pos.Layer == 0 ? groundInfo : customLayerInfo[pos.Layer].Info)[pos] = value; }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -30,19 +30,19 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
return LayerPoolTable.GetValue(world, CreateLayerPool);
|
||||
}
|
||||
|
||||
public override IEnumerable<Pair<CPos, int>> Considered
|
||||
public override IEnumerable<(CPos, int)> Considered
|
||||
{
|
||||
get { return considered; }
|
||||
}
|
||||
|
||||
LinkedList<Pair<CPos, int>> considered;
|
||||
LinkedList<(CPos, int)> considered;
|
||||
|
||||
#region Constructors
|
||||
|
||||
private PathSearch(IGraph<CellInfo> graph)
|
||||
: base(graph)
|
||||
{
|
||||
considered = new LinkedList<Pair<CPos, int>>();
|
||||
considered = new LinkedList<(CPos, int)>();
|
||||
}
|
||||
|
||||
public static IPathSearch Search(World world, Locomotor locomotor, Actor self, BlockedByActor check, Func<CPos, bool> goalCondition)
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
var connection = new GraphConnection(location, cost);
|
||||
OpenQueue.Add(connection);
|
||||
StartPoints.Add(connection);
|
||||
considered.AddLast(new Pair<CPos, int>(location, 0));
|
||||
considered.AddLast((location, 0));
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -146,7 +146,7 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
if (gCost > MaxCost)
|
||||
MaxCost = gCost;
|
||||
|
||||
considered.AddLast(new Pair<CPos, int>(neighborCPos, gCost));
|
||||
considered.AddLast((neighborCPos, gCost));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
public Actor[] TargetParatroopers(WPos target, WAngle? facing = null)
|
||||
{
|
||||
var actors = pp.SendParatroopers(Self, target, facing);
|
||||
return actors.First;
|
||||
return actors.Aircraft;
|
||||
}
|
||||
|
||||
[Desc("Activate the actor's Paratroopers Power. Returns the aircraft that will drop the reinforcements. DEPRECATED! Will be removed.")]
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
Game.Debug("SendParatroopersFrom is deprecated. Use TargetParatroopers instead.");
|
||||
var actors = pp.SendParatroopers(Self, target, facing == -1 ? (WAngle?)null : WAngle.FromFacing(facing));
|
||||
return actors.First;
|
||||
return actors.Aircraft;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,17 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
public static class ShroudExts
|
||||
{
|
||||
public static bool AnyExplored(this Shroud shroud, Pair<CPos, SubCell>[] cells)
|
||||
public static bool AnyExplored(this Shroud shroud, (CPos Cell, SubCell SubCell)[] cells)
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var cell in cells)
|
||||
if (shroud.IsExplored(cell.First))
|
||||
if (shroud.IsExplored(cell.Cell))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -36,11 +35,11 @@ namespace OpenRA.Mods.Common
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool AnyVisible(this Shroud shroud, Pair<CPos, SubCell>[] cells)
|
||||
public static bool AnyVisible(this Shroud shroud, (CPos Cell, SubCell SubCell)[] cells)
|
||||
{
|
||||
// PERF: Avoid LINQ.
|
||||
foreach (var cell in cells)
|
||||
if (shroud.IsVisible(cell.First))
|
||||
if (shroud.IsVisible(cell.Cell))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
// PERF: Reuse collection to avoid allocations.
|
||||
footprint.UnionWith(self.OccupiesSpace.OccupiedCells()
|
||||
.SelectMany(kv => Shroud.ProjectedCellsInRange(map, map.CenterOfCell(kv.First), minRange, maxRange, Info.MaxHeightDelta)));
|
||||
.SelectMany(kv => Shroud.ProjectedCellsInRange(map, map.CenterOfCell(kv.Cell), minRange, maxRange, Info.MaxHeightDelta)));
|
||||
var cells = footprint.ToArray();
|
||||
footprint.Clear();
|
||||
return cells;
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyActorDisposing, INotifyBecomingIdle, ICreationActivity,
|
||||
IActorPreviewInitModifier, IDeathActorInitModifier, IIssueDeployOrder, IIssueOrder, IResolveOrder, IOrderVoice
|
||||
{
|
||||
static readonly Pair<CPos, SubCell>[] NoCells = { };
|
||||
static readonly (CPos, SubCell)[] NoCells = { };
|
||||
|
||||
readonly Actor self;
|
||||
|
||||
@@ -597,12 +597,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
get { return !IsTraitDisabled && !IsTraitPaused ? Util.ApplyPercentageModifiers(Info.Speed, speedModifiers) : 0; }
|
||||
}
|
||||
|
||||
public Pair<CPos, SubCell>[] OccupiedCells()
|
||||
public (CPos Cell, SubCell SubCell)[] OccupiedCells()
|
||||
{
|
||||
if (!self.IsAtGroundLevel())
|
||||
return landingCells.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
return landingCells.Select(c => (c, SubCell.FullCell)).ToArray();
|
||||
|
||||
return new[] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
return new[] { (TopLeft, SubCell.FullCell) };
|
||||
}
|
||||
|
||||
public WVec FlyStep(WAngle facing)
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
"Overrides `Color` if both set.")]
|
||||
public readonly string Terrain = null;
|
||||
|
||||
void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<Pair<MPos, Color>> destinationBuffer)
|
||||
void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<(MPos, Color)> destinationBuffer)
|
||||
{
|
||||
var tileSet = map.Rules.TileSet;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var ios = ai.TraitInfo<IOccupySpaceInfo>();
|
||||
var cells = ios.OccupiedCells(ai, s.Get<LocationInit>().Value);
|
||||
foreach (var cell in cells)
|
||||
destinationBuffer.Add(new Pair<MPos, Color>(cell.Key.ToMPos(map), color));
|
||||
destinationBuffer.Add((cell.Key.ToMPos(map), color));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int currentBarrel;
|
||||
int barrelCount;
|
||||
|
||||
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
|
||||
List<(int Ticks, Action Func)> delayedActions = new List<(int, Action)>();
|
||||
|
||||
public WDist Recoil;
|
||||
public int FireDelay { get; protected set; }
|
||||
@@ -211,12 +211,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
for (var i = 0; i < delayedActions.Count; i++)
|
||||
{
|
||||
var x = delayedActions[i];
|
||||
if (--x.First <= 0)
|
||||
x.Second();
|
||||
if (--x.Ticks <= 0)
|
||||
x.Func();
|
||||
delayedActions[i] = x;
|
||||
}
|
||||
|
||||
delayedActions.RemoveAll(a => a.First <= 0);
|
||||
delayedActions.RemoveAll(a => a.Ticks <= 0);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
protected void ScheduleDelayedAction(int t, Action a)
|
||||
{
|
||||
if (t > 0)
|
||||
delayedActions.Add(Pair.New(t, a));
|
||||
delayedActions.Add((t, a));
|
||||
else
|
||||
a();
|
||||
}
|
||||
|
||||
@@ -64,27 +64,27 @@ namespace OpenRA.Mods.Common.Traits
|
||||
DemolishWeaponInfo = weapon;
|
||||
}
|
||||
|
||||
public IEnumerable<Pair<ushort, int>> Templates
|
||||
public IEnumerable<(ushort Template, int Health)> Templates
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Template != 0)
|
||||
yield return Pair.New(Template, 100);
|
||||
yield return (Template, 100);
|
||||
|
||||
if (DamagedTemplate != 0)
|
||||
yield return Pair.New(DamagedTemplate, 49);
|
||||
yield return (DamagedTemplate, 49);
|
||||
|
||||
if (DestroyedTemplate != 0)
|
||||
yield return Pair.New(DestroyedTemplate, 0);
|
||||
yield return (DestroyedTemplate, 0);
|
||||
|
||||
if (DestroyedPlusNorthTemplate != 0)
|
||||
yield return Pair.New(DestroyedPlusNorthTemplate, 0);
|
||||
yield return (DestroyedPlusNorthTemplate, 0);
|
||||
|
||||
if (DestroyedPlusSouthTemplate != 0)
|
||||
yield return Pair.New(DestroyedPlusSouthTemplate, 0);
|
||||
yield return (DestroyedPlusSouthTemplate, 0);
|
||||
|
||||
if (DestroyedPlusBothTemplate != 0)
|
||||
yield return Pair.New(DestroyedPlusBothTemplate, 0);
|
||||
yield return (DestroyedPlusBothTemplate, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var palette = wr.Palette(TileSet.TerrainPaletteInternalName);
|
||||
renderables = new Dictionary<ushort, IRenderable[]>();
|
||||
foreach (var t in info.Templates)
|
||||
renderables.Add(t.First, TemplateRenderables(wr, palette, t.First));
|
||||
renderables.Add(t.Template, TemplateRenderables(wr, palette, t.Template));
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -268,8 +267,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Actor self;
|
||||
readonly BuildingInfluence influence;
|
||||
|
||||
Pair<CPos, SubCell>[] occupiedCells;
|
||||
Pair<CPos, SubCell>[] targetableCells;
|
||||
(CPos, SubCell)[] occupiedCells;
|
||||
(CPos, SubCell)[] targetableCells;
|
||||
CPos[] transitOnlyCells;
|
||||
|
||||
public CPos TopLeft { get { return topLeft; } }
|
||||
@@ -283,21 +282,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
influence = self.World.WorldActor.Trait<BuildingInfluence>();
|
||||
|
||||
occupiedCells = Info.OccupiedTiles(TopLeft)
|
||||
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
.Select(c => (c, SubCell.FullCell)).ToArray();
|
||||
|
||||
targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied)
|
||||
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
.Select(c => (c, SubCell.FullCell)).ToArray();
|
||||
|
||||
transitOnlyCells = Info.TransitOnlyTiles(TopLeft).ToArray();
|
||||
|
||||
CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World);
|
||||
}
|
||||
|
||||
public Pair<CPos, SubCell>[] OccupiedCells() { return occupiedCells; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return occupiedCells; }
|
||||
|
||||
public CPos[] TransitOnlyCells() { return transitOnlyCells; }
|
||||
|
||||
Pair<CPos, SubCell>[] ITargetableCells.TargetableCells() { return targetableCells; }
|
||||
(CPos, SubCell)[] ITargetableCells.TargetableCells() { return targetableCells; }
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
world.IsCellBuildable(t, ai, bi, toIgnore));
|
||||
}
|
||||
|
||||
public static IEnumerable<Pair<CPos, Actor>> GetLineBuildCells(World world, CPos cell, ActorInfo ai, BuildingInfo bi, Player owner)
|
||||
public static IEnumerable<(CPos Cell, Actor Actor)> GetLineBuildCells(World world, CPos cell, ActorInfo ai, BuildingInfo bi, Player owner)
|
||||
{
|
||||
var lbi = ai.TraitInfo<LineBuildInfo>();
|
||||
var topLeft = cell; // 1x1 assumption!
|
||||
|
||||
if (world.IsCellBuildable(topLeft, ai, bi))
|
||||
yield return Pair.New<CPos, Actor>(topLeft, null);
|
||||
yield return (topLeft, null);
|
||||
|
||||
// Start at place location, search outwards
|
||||
// TODO: First make it work, then make it nice
|
||||
@@ -91,7 +91,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Place intermediate-line sections
|
||||
if (dirs[d] > 0)
|
||||
for (var i = 1; i < dirs[d]; i++)
|
||||
yield return Pair.New(topLeft + i * vecs[d], connectors[d]);
|
||||
yield return (topLeft + i * vecs[d], connectors[d]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
|
||||
{
|
||||
Dictionary<Actor, Pair<int, int>> progress = new Dictionary<Actor, Pair<int, int>>();
|
||||
Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>();
|
||||
|
||||
public CapturableProgressBar(Actor self, CapturableProgressBarInfo info)
|
||||
: base(info) { }
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (total == 0)
|
||||
progress.Remove(captor);
|
||||
else
|
||||
progress[captor] = Pair.New(current, total);
|
||||
progress[captor] = (current, total);
|
||||
}
|
||||
|
||||
float ISelectionBar.GetValue()
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsTraitDisabled || !progress.Any())
|
||||
return 0f;
|
||||
|
||||
return progress.Values.Max(p => (float)p.First / p.Second);
|
||||
return progress.Values.Max(p => (float)p.Current / p.Total);
|
||||
}
|
||||
|
||||
Color ISelectionBar.GetColor() { return Info.Color; }
|
||||
|
||||
@@ -155,20 +155,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (crateActions.Any())
|
||||
{
|
||||
var shares = crateActions.Select(a => Pair.New(a, a.GetSelectionSharesOuter(crusher)));
|
||||
var shares = crateActions.Select(a => (Action: a, Shares: a.GetSelectionSharesOuter(crusher)));
|
||||
|
||||
var totalShares = shares.Sum(a => a.Second);
|
||||
var totalShares = shares.Sum(a => a.Shares);
|
||||
var n = self.World.SharedRandom.Next(totalShares);
|
||||
|
||||
foreach (var s in shares)
|
||||
{
|
||||
if (n < s.Second)
|
||||
if (n < s.Shares)
|
||||
{
|
||||
s.First.Activate(crusher);
|
||||
s.Action.Activate(crusher);
|
||||
return;
|
||||
}
|
||||
|
||||
n -= s.Second;
|
||||
n -= s.Shares;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return Location; } }
|
||||
public Pair<CPos, SubCell>[] OccupiedCells() { return new[] { Pair.New(Location, SubCell.FullCell) }; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return new[] { (Location, SubCell.FullCell) }; }
|
||||
|
||||
public WPos CenterPosition { get; private set; }
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var kv in self.OccupiesSpace.OccupiedCells())
|
||||
{
|
||||
totalTiles++;
|
||||
if (!Info.Terrain.Contains(self.World.Map.GetTerrainInfo(kv.First).Type))
|
||||
if (!Info.Terrain.Contains(self.World.Map.GetTerrainInfo(kv.Cell).Type))
|
||||
safeTiles++;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (info.DrawPerimiterCellVectors)
|
||||
{
|
||||
var occupiedCells = self.OccupiesSpace.OccupiedCells().Select(p => p.First).ToArray();
|
||||
var occupiedCells = self.OccupiesSpace.OccupiedCells().Select(p => p.Cell).ToArray();
|
||||
perimeterCells = Util.ExpandFootprint(occupiedCells, true).Except(occupiedCells).ToArray();
|
||||
|
||||
foreach (var perimCell in perimeterCells)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly GainsExperienceInfo info;
|
||||
readonly int initialExperience;
|
||||
|
||||
readonly List<Pair<int, string>> nextLevel = new List<Pair<int, string>>();
|
||||
readonly List<(int RequiredExperience, string Condition)> nextLevel = new List<(int, string)>();
|
||||
|
||||
// Stored as a percentage of our value
|
||||
[Sync]
|
||||
@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var valued = self.Info.TraitInfoOrDefault<ValuedInfo>();
|
||||
var requiredExperience = info.ExperienceModifier < 0 ? (valued != null ? valued.Cost : 1) : info.ExperienceModifier;
|
||||
foreach (var kv in info.Conditions)
|
||||
nextLevel.Add(Pair.New(kv.Key * requiredExperience, kv.Value));
|
||||
nextLevel.Add((kv.Key * requiredExperience, kv.Value));
|
||||
|
||||
if (initialExperience > 0)
|
||||
GiveExperience(initialExperience, info.SuppressLevelupAnimation);
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var newLevel = Math.Min(Level + numLevels, MaxLevel);
|
||||
GiveExperience(nextLevel[newLevel - 1].First - Experience, silent);
|
||||
GiveExperience(nextLevel[newLevel - 1].RequiredExperience - Experience, silent);
|
||||
}
|
||||
|
||||
public void GiveExperience(int amount, bool silent = false)
|
||||
@@ -108,11 +108,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (MaxLevel == 0)
|
||||
return;
|
||||
|
||||
Experience = (Experience + amount).Clamp(0, nextLevel[MaxLevel - 1].First);
|
||||
Experience = (Experience + amount).Clamp(0, nextLevel[MaxLevel - 1].RequiredExperience);
|
||||
|
||||
while (Level < MaxLevel && Experience >= nextLevel[Level].First)
|
||||
while (Level < MaxLevel && Experience >= nextLevel[Level].RequiredExperience)
|
||||
{
|
||||
self.GrantCondition(nextLevel[Level].Second);
|
||||
self.GrantCondition(nextLevel[Level].Condition);
|
||||
|
||||
Level++;
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (Info.UseTargetableCellsOffsets && targetableCells != null)
|
||||
foreach (var c in targetableCells.TargetableCells())
|
||||
yield return self.World.Map.CenterOfCell(c.First);
|
||||
yield return self.World.Map.CenterOfCell(c.Cell);
|
||||
|
||||
foreach (var o in Info.TargetableOffsets)
|
||||
{
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
public Pair<CPos, SubCell>[] OccupiedCells() { return new[] { Pair.New(TopLeft, SubCell.FullCell) }; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return new[] { (TopLeft, SubCell.FullCell) }; }
|
||||
public bool IsLeavingCell(CPos location, SubCell subCell = SubCell.Any) { return false; }
|
||||
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
|
||||
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Sync]
|
||||
readonly WPos position;
|
||||
|
||||
readonly Pair<CPos, SubCell>[] occupied;
|
||||
readonly (CPos, SubCell)[] occupied;
|
||||
|
||||
public Immobile(ActorInitializer init, ImmobileInfo info)
|
||||
{
|
||||
@@ -47,14 +47,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
position = init.World.Map.CenterOfCell(location);
|
||||
|
||||
if (info.OccupiesSpace)
|
||||
occupied = new[] { Pair.New(TopLeft, SubCell.FullCell) };
|
||||
occupied = new[] { (TopLeft, SubCell.FullCell) };
|
||||
else
|
||||
occupied = new Pair<CPos, SubCell>[0];
|
||||
occupied = new (CPos, SubCell)[0];
|
||||
}
|
||||
|
||||
public CPos TopLeft { get { return location; } }
|
||||
public WPos CenterPosition { get { return position; } }
|
||||
public Pair<CPos, SubCell>[] OccupiedCells() { return occupied; }
|
||||
public (CPos, SubCell)[] OccupiedCells() { return occupied; }
|
||||
|
||||
void INotifyAddedToWorld.AddedToWorld(Actor self)
|
||||
{
|
||||
|
||||
@@ -229,16 +229,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public CPos TopLeft { get { return ToCell; } }
|
||||
|
||||
public Pair<CPos, SubCell>[] OccupiedCells()
|
||||
public (CPos, SubCell)[] OccupiedCells()
|
||||
{
|
||||
if (FromCell == ToCell)
|
||||
return new[] { Pair.New(FromCell, FromSubCell) };
|
||||
return new[] { (FromCell, FromSubCell) };
|
||||
|
||||
// HACK: Should be fixed properly, see https://github.com/OpenRA/OpenRA/pull/17292 for an explanation
|
||||
if (Info.LocomotorInfo.SharesCell)
|
||||
return new[] { Pair.New(ToCell, ToSubCell) };
|
||||
return new[] { (ToCell, ToSubCell) };
|
||||
|
||||
return new[] { Pair.New(FromCell, FromSubCell), Pair.New(ToCell, ToSubCell) };
|
||||
return new[] { (FromCell, FromSubCell), (ToCell, ToSubCell) };
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -78,12 +78,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var myTeam = self.World.LobbyInfo.ClientWithIndex(self.Owner.ClientIndex).Team;
|
||||
var teams = self.World.Players.Where(p => !p.NonCombatant && p.Playable)
|
||||
.Select(p => new Pair<Player, PlayerStatistics>(p, p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.Second != null ? p.Second.Experience : 0)
|
||||
.GroupBy(p => (self.World.LobbyInfo.ClientWithIndex(p.First.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.Second != null ? gg.Second.Experience : 0));
|
||||
.Select(p => (Player: p, PlayerStatistics: p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.PlayerStatistics != null ? p.PlayerStatistics.Experience : 0)
|
||||
.GroupBy(p => (self.World.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics != null ? gg.PlayerStatistics.Experience : 0));
|
||||
|
||||
if (teams.First().Key == myTeam && (myTeam != 0 || teams.First().First().First == self.Owner))
|
||||
if (teams.First().Key == myTeam && (myTeam != 0 || teams.First().First().Player == self.Owner))
|
||||
{
|
||||
mo.MarkCompleted(self.Owner, objectiveID);
|
||||
return;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class GrantConditionOnPrerequisiteManager : ITechTreeElement
|
||||
{
|
||||
readonly Actor self;
|
||||
readonly Dictionary<string, List<Pair<Actor, GrantConditionOnPrerequisite>>> upgradables = new Dictionary<string, List<Pair<Actor, GrantConditionOnPrerequisite>>>();
|
||||
readonly Dictionary<string, List<(Actor Actor, GrantConditionOnPrerequisite GrantConditionOnPrerequisite)>> upgradables = new Dictionary<string, List<(Actor, GrantConditionOnPrerequisite)>>();
|
||||
readonly TechTree techTree;
|
||||
|
||||
public GrantConditionOnPrerequisiteManager(ActorInitializer init)
|
||||
@@ -44,11 +44,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var key = MakeKey(prerequisites);
|
||||
if (!upgradables.ContainsKey(key))
|
||||
{
|
||||
upgradables.Add(key, new List<Pair<Actor, GrantConditionOnPrerequisite>>());
|
||||
upgradables.Add(key, new List<(Actor, GrantConditionOnPrerequisite)>());
|
||||
techTree.Add(key, prerequisites, 0, this);
|
||||
}
|
||||
|
||||
upgradables[key].Add(Pair.New(actor, u));
|
||||
upgradables[key].Add((actor, u));
|
||||
|
||||
// Notify the current state
|
||||
u.PrerequisitesUpdated(actor, techTree.HasPrerequisites(prerequisites));
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var key = MakeKey(prerequisites);
|
||||
var list = upgradables[key];
|
||||
|
||||
list.RemoveAll(x => x.First == actor && x.Second == u);
|
||||
list.RemoveAll(x => x.Actor == actor && x.GrantConditionOnPrerequisite == u);
|
||||
if (!list.Any())
|
||||
{
|
||||
upgradables.Remove(key);
|
||||
@@ -69,22 +69,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void PrerequisitesAvailable(string key)
|
||||
{
|
||||
List<Pair<Actor, GrantConditionOnPrerequisite>> list;
|
||||
List<(Actor Actor, GrantConditionOnPrerequisite GrantConditionOnPrerequisite)> list;
|
||||
if (!upgradables.TryGetValue(key, out list))
|
||||
return;
|
||||
|
||||
foreach (var u in list)
|
||||
u.Second.PrerequisitesUpdated(u.First, true);
|
||||
u.GrantConditionOnPrerequisite.PrerequisitesUpdated(u.Actor, true);
|
||||
}
|
||||
|
||||
public void PrerequisitesUnavailable(string key)
|
||||
{
|
||||
List<Pair<Actor, GrantConditionOnPrerequisite>> list;
|
||||
List<(Actor Actor, GrantConditionOnPrerequisite GrantConditionOnPrerequisite)> list;
|
||||
if (!upgradables.TryGetValue(key, out list))
|
||||
return;
|
||||
|
||||
foreach (var u in list)
|
||||
u.Second.PrerequisitesUpdated(u.First, false);
|
||||
u.GrantConditionOnPrerequisite.PrerequisitesUpdated(u.Actor, false);
|
||||
}
|
||||
|
||||
public void PrerequisitesItemHidden(string key) { }
|
||||
|
||||
@@ -119,16 +119,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var t in BuildingUtils.GetLineBuildCells(w, targetLocation, actorInfo, buildingInfo, order.Player))
|
||||
{
|
||||
if (t.First == targetLocation)
|
||||
if (t.Cell == targetLocation)
|
||||
continue;
|
||||
|
||||
w.CreateActor(t.First == targetLocation ? actorInfo.Name : segmentType, new TypeDictionary
|
||||
w.CreateActor(t.Cell == targetLocation ? actorInfo.Name : segmentType, new TypeDictionary
|
||||
{
|
||||
new LocationInit(t.First),
|
||||
new LocationInit(t.Cell),
|
||||
new OwnerInit(order.Player),
|
||||
new FactionInit(faction),
|
||||
new LineBuildDirectionInit(t.First.X == targetLocation.X ? LineBuildDirection.Y : LineBuildDirection.X),
|
||||
new LineBuildParentInit(new[] { t.Second, placed }),
|
||||
new LineBuildDirectionInit(t.Cell.X == targetLocation.X ? LineBuildDirection.Y : LineBuildDirection.X),
|
||||
new LineBuildParentInit(new[] { t.Actor, placed }),
|
||||
new PlaceBuildingInit()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool IsInitialized { get; private set; }
|
||||
|
||||
readonly World world;
|
||||
CellLayer<Pair<int, int>> terrainColor;
|
||||
CellLayer<(int, int)> terrainColor;
|
||||
readonly Shroud shroud;
|
||||
|
||||
public event Action<MPos> CellTerrainColorChanged = null;
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
terrainColor = new CellLayer<Pair<int, int>>(w.Map);
|
||||
terrainColor = new CellLayer<(int, int)>(w.Map);
|
||||
|
||||
w.AddFrameEndTask(_ =>
|
||||
{
|
||||
@@ -82,22 +82,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
});
|
||||
}
|
||||
|
||||
public Pair<int, int> this[MPos uv]
|
||||
public (int Left, int Right) this[MPos uv]
|
||||
{
|
||||
get { return terrainColor[uv]; }
|
||||
}
|
||||
|
||||
public static Pair<int, int> GetColor(Map map, MPos uv)
|
||||
public static (int Left, int Right) GetColor(Map map, MPos uv)
|
||||
{
|
||||
var custom = map.CustomTerrain[uv];
|
||||
if (custom != byte.MaxValue)
|
||||
{
|
||||
var c = map.Rules.TileSet[custom].Color.ToArgb();
|
||||
return Pair.New(c, c);
|
||||
return (c, c);
|
||||
}
|
||||
|
||||
var tc = map.GetTerrainColorPair(uv);
|
||||
return Pair.New(tc.First.ToArgb(), tc.Second.ToArgb());
|
||||
return (tc.Left.ToArgb(), tc.Right.ToArgb());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,12 +119,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
var myTeam = self.World.LobbyInfo.ClientWithIndex(self.Owner.ClientIndex).Team;
|
||||
var teams = self.World.Players.Where(p => !p.NonCombatant && p.Playable)
|
||||
.Select(p => new Pair<Player, PlayerStatistics>(p, p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.Second != null ? p.Second.Experience : 0)
|
||||
.GroupBy(p => (self.World.LobbyInfo.ClientWithIndex(p.First.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.Second != null ? gg.Second.Experience : 0));
|
||||
.Select(p => (Player: p, PlayerStatistics: p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.PlayerStatistics != null ? p.PlayerStatistics.Experience : 0)
|
||||
.GroupBy(p => (self.World.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics != null ? gg.PlayerStatistics.Experience : 0));
|
||||
|
||||
if (teams.First().Key == myTeam && (myTeam != 0 || teams.First().First().First == self.Owner))
|
||||
if (teams.First().Key == myTeam && (myTeam != 0 || teams.First().First().Player == self.Owner))
|
||||
{
|
||||
mo.MarkCompleted(self.Owner, objectiveID);
|
||||
return;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits.Radar
|
||||
modifier = self.TraitsImplementing<IRadarColorModifier>().FirstOrDefault();
|
||||
}
|
||||
|
||||
public void PopulateRadarSignatureCells(Actor self, List<Pair<CPos, Color>> destinationBuffer)
|
||||
public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer)
|
||||
{
|
||||
var viewer = self.World.RenderPlayer ?? self.World.LocalPlayer;
|
||||
if (IsTraitDisabled || (viewer != null && !Info.ValidStances.HasStance(self.Owner.Stances[viewer])))
|
||||
@@ -51,12 +51,12 @@ namespace OpenRA.Mods.Common.Traits.Radar
|
||||
|
||||
if (Info.UseLocation)
|
||||
{
|
||||
destinationBuffer.Add(Pair.New(self.Location, color));
|
||||
destinationBuffer.Add((self.Location, color));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var cell in self.OccupiesSpace.OccupiedCells())
|
||||
destinationBuffer.Add(Pair.New(cell.First, color));
|
||||
destinationBuffer.Add((cell.Cell, color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,12 +87,12 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public class RenderSprites : IRender, ITick, INotifyOwnerChanged, INotifyEffectiveOwnerChanged, IActorPreviewInitModifier
|
||||
{
|
||||
static readonly Pair<DamageState, string>[] DamagePrefixes =
|
||||
static readonly (DamageState DamageState, string Prefix)[] DamagePrefixes =
|
||||
{
|
||||
Pair.New(DamageState.Critical, "critical-"),
|
||||
Pair.New(DamageState.Heavy, "damaged-"),
|
||||
Pair.New(DamageState.Medium, "scratched-"),
|
||||
Pair.New(DamageState.Light, "scuffed-")
|
||||
(DamageState.Critical, "critical-"),
|
||||
(DamageState.Heavy, "damaged-"),
|
||||
(DamageState.Medium, "scratched-"),
|
||||
(DamageState.Light, "scuffed-")
|
||||
};
|
||||
|
||||
class AnimationWrapper
|
||||
@@ -251,9 +251,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
// Remove existing damage prefix
|
||||
foreach (var s in DamagePrefixes)
|
||||
{
|
||||
if (sequence.StartsWith(s.Second, StringComparison.Ordinal))
|
||||
if (sequence.StartsWith(s.Prefix, StringComparison.Ordinal))
|
||||
{
|
||||
sequence = sequence.Substring(s.Second.Length);
|
||||
sequence = sequence.Substring(s.Prefix.Length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -267,8 +267,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
sequence = UnnormalizeSequence(sequence);
|
||||
|
||||
foreach (var s in DamagePrefixes)
|
||||
if (state >= s.First && anim.HasSequence(s.Second + sequence))
|
||||
return s.Second + sequence;
|
||||
if (state >= s.DamageState && anim.HasSequence(s.Prefix + sequence))
|
||||
return s.Prefix + sequence;
|
||||
|
||||
return sequence;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
SendParatroopers(self, order.Target.CenterPosition, facing);
|
||||
}
|
||||
|
||||
public Pair<Actor[], Actor[]> SendParatroopers(Actor self, WPos target, WAngle? facing = null)
|
||||
public (Actor[] Aircraft, Actor[] Units) SendParatroopers(Actor self, WPos target, WAngle? facing = null)
|
||||
{
|
||||
var aircraft = new List<Actor>();
|
||||
var units = new List<Actor>();
|
||||
@@ -266,7 +266,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
});
|
||||
|
||||
return Pair.New(aircraft.ToArray(), units.ToArray());
|
||||
return (aircraft.ToArray(), units.ToArray());
|
||||
}
|
||||
|
||||
void RemoveCamera(Actor camera)
|
||||
|
||||
@@ -359,20 +359,20 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
foreach (var c in ios.OccupiedCells())
|
||||
{
|
||||
var uv = c.First.ToMPos(map);
|
||||
var uv = c.Cell.ToMPos(map);
|
||||
if (!influence.Contains(uv))
|
||||
continue;
|
||||
|
||||
var layer = c.First.Layer == 0 ? influence : customInfluence[c.First.Layer];
|
||||
layer[uv] = new InfluenceNode { Next = layer[uv], SubCell = c.Second, Actor = self };
|
||||
var layer = c.Cell.Layer == 0 ? influence : customInfluence[c.Cell.Layer];
|
||||
layer[uv] = new InfluenceNode { Next = layer[uv], SubCell = c.SubCell, Actor = self };
|
||||
|
||||
List<CellTrigger> triggers;
|
||||
if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
if (CellUpdated != null)
|
||||
CellUpdated(c.First);
|
||||
CellUpdated(c.Cell);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,22 +380,22 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
foreach (var c in ios.OccupiedCells())
|
||||
{
|
||||
var uv = c.First.ToMPos(map);
|
||||
var uv = c.Cell.ToMPos(map);
|
||||
if (!influence.Contains(uv))
|
||||
continue;
|
||||
|
||||
var layer = c.First.Layer == 0 ? influence : customInfluence[c.First.Layer];
|
||||
var layer = c.Cell.Layer == 0 ? influence : customInfluence[c.Cell.Layer];
|
||||
var temp = layer[uv];
|
||||
RemoveInfluenceInner(ref temp, self);
|
||||
layer[uv] = temp;
|
||||
|
||||
List<CellTrigger> triggers;
|
||||
if (cellTriggerInfluence.TryGetValue(c.First, out triggers))
|
||||
if (cellTriggerInfluence.TryGetValue(c.Cell, out triggers))
|
||||
foreach (var t in triggers)
|
||||
t.Dirty = true;
|
||||
|
||||
if (CellUpdated != null)
|
||||
CellUpdated(c.First);
|
||||
CellUpdated(c.Cell);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
foreach (var c in ios.OccupiedCells())
|
||||
CellUpdated(c.First);
|
||||
CellUpdated(c.Cell);
|
||||
}
|
||||
|
||||
void ITick.Tick(Actor self)
|
||||
|
||||
@@ -315,11 +315,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return nodes;
|
||||
}
|
||||
|
||||
public void PopulateRadarSignatureCells(Actor self, List<Pair<CPos, Color>> destinationBuffer)
|
||||
public void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer)
|
||||
{
|
||||
foreach (var previewsForCell in cellMap)
|
||||
foreach (var preview in previewsForCell.Value)
|
||||
destinationBuffer.Add(Pair.New(previewsForCell.Key, preview.RadarColor));
|
||||
destinationBuffer.Add((previewsForCell.Key, preview.RadarColor));
|
||||
}
|
||||
|
||||
public EditorActorPreview this[string id]
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
class LegacyBridgeLayer : IWorldLoaded
|
||||
{
|
||||
readonly LegacyBridgeLayerInfo info;
|
||||
readonly Dictionary<ushort, Pair<string, int>> bridgeTypes = new Dictionary<ushort, Pair<string, int>>();
|
||||
readonly Dictionary<ushort, (string Template, int Health)> bridgeTypes = new Dictionary<ushort, (string, int)>();
|
||||
|
||||
CellLayer<Bridge> bridges;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var bi = w.Map.Rules.Actors[bridge].TraitInfo<BridgeInfo>();
|
||||
foreach (var template in bi.Templates)
|
||||
bridgeTypes.Add(template.First, Pair.New(bridge, template.Second));
|
||||
bridgeTypes.Add(template.Template, (bridge, template.Health));
|
||||
}
|
||||
|
||||
// Take all templates to overlay from the map
|
||||
@@ -73,11 +73,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var nj = cell.Y - index / template.Size.X;
|
||||
|
||||
// Create a new actor for this bridge and keep track of which subtiles this bridge includes
|
||||
var bridge = w.CreateActor(bridgeTypes[tile].First, new TypeDictionary
|
||||
var bridge = w.CreateActor(bridgeTypes[tile].Template, new TypeDictionary
|
||||
{
|
||||
new LocationInit(new CPos(ni, nj)),
|
||||
new OwnerInit(w.WorldActor.Owner),
|
||||
new HealthInit(bridgeTypes[tile].Second, true),
|
||||
new HealthInit(bridgeTypes[tile].Health, true),
|
||||
}).Trait<Bridge>();
|
||||
|
||||
var subTiles = new Dictionary<CPos, byte>();
|
||||
|
||||
@@ -133,8 +133,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var n = taken.Count == 0 || !separateTeamSpawns
|
||||
? world.SharedRandom.Next(available.Count)
|
||||
: available // pick the most distant spawnpoint from everyone else
|
||||
.Select((k, i) => Pair.New(k, i))
|
||||
.MaxBy(a => taken.Sum(t => (t - a.First).LengthSquared)).Second;
|
||||
.Select((k, i) => (Cell: k, Index: i))
|
||||
.MaxBy(a => taken.Sum(t => (t - a.Cell).LengthSquared)).Index;
|
||||
|
||||
var sp = available[n];
|
||||
available.RemoveAt(n);
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Allow resource to spawn on ramp tiles.")]
|
||||
public readonly bool AllowOnRamps = false;
|
||||
|
||||
void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<Pair<MPos, Color>> destinationBuffer)
|
||||
void IMapPreviewSignatureInfo.PopulateMapPreviewSignatureCells(Map map, ActorInfo ai, ActorReference s, List<(MPos, Color)> destinationBuffer)
|
||||
{
|
||||
var tileSet = map.Rules.TileSet;
|
||||
var color = tileSet[tileSet.GetTerrainIndex(TerrainType)].Color;
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var cell = new MPos(i, j);
|
||||
if (map.Resources[cell].Type == ResourceType)
|
||||
destinationBuffer.Add(new Pair<MPos, Color>(cell, color));
|
||||
destinationBuffer.Add((cell, color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public interface IRadarSignature
|
||||
{
|
||||
void PopulateRadarSignatureCells(Actor self, List<Pair<CPos, Color>> destinationBuffer);
|
||||
void PopulateRadarSignatureCells(Actor self, List<(CPos Cell, Color Color)> destinationBuffer);
|
||||
}
|
||||
|
||||
public interface IRadarColorModifier { Color RadarColorOverride(Actor self, Color color); }
|
||||
@@ -476,7 +476,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[RequireExplicitImplementation]
|
||||
public interface ITargetableCells
|
||||
{
|
||||
Pair<CPos, SubCell>[] TargetableCells();
|
||||
(CPos Cell, SubCell SubCell)[] TargetableCells();
|
||||
}
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
|
||||
@@ -17,7 +17,7 @@ using OpenRA.FileSystem;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules
|
||||
{
|
||||
using YamlFileSet = List<Tuple<IReadWritePackage, string, List<MiniYamlNode>>>;
|
||||
using YamlFileSet = List<(IReadWritePackage, string, List<MiniYamlNode>)>;
|
||||
|
||||
public static class UpdateUtils
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
continue;
|
||||
}
|
||||
|
||||
yaml.Add(Tuple.Create((IReadWritePackage)package, name, MiniYaml.FromStream(package.GetStream(name), name, false)));
|
||||
yaml.Add(((IReadWritePackage)package, name, MiniYaml.FromStream(package.GetStream(name), name, false)));
|
||||
}
|
||||
|
||||
return yaml;
|
||||
@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
{
|
||||
var fileSet = new YamlFileSet()
|
||||
{
|
||||
Tuple.Create<IReadWritePackage, string, List<MiniYamlNode>>(null, "map.yaml", yaml.Nodes)
|
||||
(null, "map.yaml", yaml.Nodes)
|
||||
};
|
||||
|
||||
var files = FieldLoader.GetValue<string[]>("value", yaml.Value);
|
||||
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
{
|
||||
// Ignore any files that aren't in the map bundle
|
||||
if (!filename.Contains("|") && mapPackage.Contains(filename))
|
||||
fileSet.Add(Tuple.Create(mapPackage, filename, MiniYaml.FromStream(mapPackage.GetStream(filename), filename, false)));
|
||||
fileSet.Add((mapPackage, filename, MiniYaml.FromStream(mapPackage.GetStream(filename), filename, false)));
|
||||
else if (modData.ModFiles.Exists(filename))
|
||||
externalFilenames.Add(filename);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
}
|
||||
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromStream(mapStream, mapPackage.Name, false));
|
||||
files = new YamlFileSet() { Tuple.Create(mapPackage, "map.yaml", yaml.Nodes) };
|
||||
files = new YamlFileSet() { (mapPackage, "map.yaml", yaml.Nodes) };
|
||||
|
||||
manualSteps.AddRange(rule.BeforeUpdate(modData));
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.UpdateRules
|
||||
{
|
||||
var mapActors = new YamlFileSet()
|
||||
{
|
||||
Tuple.Create<IReadWritePackage, string, List<MiniYamlNode>>(null, "map.yaml", mapActorsNode.Value.Nodes)
|
||||
(null, "map.yaml", mapActorsNode.Value.Nodes)
|
||||
};
|
||||
|
||||
manualSteps.AddRange(ApplyTopLevelTransform(modData, mapActors, rule.UpdateMapActorNode));
|
||||
|
||||
@@ -46,24 +46,24 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var pr = c.Value.PanelRegion;
|
||||
if (pr != null && pr.Length == 8)
|
||||
{
|
||||
var sides = new[]
|
||||
var sides = new (PanelSides PanelSides, Rectangle Bounds)[]
|
||||
{
|
||||
Pair.New(PanelSides.Top | PanelSides.Left, new Rectangle(pr[0], pr[1], pr[2], pr[3])),
|
||||
Pair.New(PanelSides.Top, new Rectangle(pr[0] + pr[2], pr[1], pr[4], pr[3])),
|
||||
Pair.New(PanelSides.Top | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1], pr[6], pr[3])),
|
||||
Pair.New(PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3], pr[2], pr[5])),
|
||||
Pair.New(PanelSides.Center, new Rectangle(pr[0] + pr[2], pr[1] + pr[3], pr[4], pr[5])),
|
||||
Pair.New(PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3], pr[6], pr[5])),
|
||||
Pair.New(PanelSides.Bottom | PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3] + pr[5], pr[2], pr[7])),
|
||||
Pair.New(PanelSides.Bottom, new Rectangle(pr[0] + pr[2], pr[1] + pr[3] + pr[5], pr[4], pr[7])),
|
||||
Pair.New(PanelSides.Bottom | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3] + pr[5], pr[6], pr[7]))
|
||||
(PanelSides.Top | PanelSides.Left, new Rectangle(pr[0], pr[1], pr[2], pr[3])),
|
||||
(PanelSides.Top, new Rectangle(pr[0] + pr[2], pr[1], pr[4], pr[3])),
|
||||
(PanelSides.Top | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1], pr[6], pr[3])),
|
||||
(PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3], pr[2], pr[5])),
|
||||
(PanelSides.Center, new Rectangle(pr[0] + pr[2], pr[1] + pr[3], pr[4], pr[5])),
|
||||
(PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3], pr[6], pr[5])),
|
||||
(PanelSides.Bottom | PanelSides.Left, new Rectangle(pr[0], pr[1] + pr[3] + pr[5], pr[2], pr[7])),
|
||||
(PanelSides.Bottom, new Rectangle(pr[0] + pr[2], pr[1] + pr[3] + pr[5], pr[4], pr[7])),
|
||||
(PanelSides.Bottom | PanelSides.Right, new Rectangle(pr[0] + pr[2] + pr[4], pr[1] + pr[3] + pr[5], pr[6], pr[7]))
|
||||
};
|
||||
|
||||
foreach (var s in sides)
|
||||
{
|
||||
var r = s.Second;
|
||||
if (c.Value.PanelSides.HasSide(s.First))
|
||||
regions.Add("[\"{0}.<{1}>\",{2},{3},{4},{5}]".F(c.Key, s.First, r.X, r.Y, r.Width, r.Height));
|
||||
var r = s.Bounds;
|
||||
if (c.Value.PanelSides.HasSide(s.PanelSides))
|
||||
regions.Add("[\"{0}.<{1}>\",{2},{3},{4},{5}]".F(c.Key, s.PanelSides, r.X, r.Y, r.Width, r.Height));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
||||
|
||||
var required = RequiredTraitNames(cg);
|
||||
return ScriptMemberWrapper.WrappableMembers(cg).Select(mi => Tuple.Create(category, mi, required));
|
||||
return ScriptMemberWrapper.WrappableMembers(cg).Select(mi => (category, mi, required));
|
||||
}).GroupBy(g => g.Item1).OrderBy(g => g.Key);
|
||||
|
||||
foreach (var kv in actorCategories)
|
||||
@@ -132,7 +132,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var category = catAttr != null ? catAttr.Category : "Unsorted";
|
||||
|
||||
var required = RequiredTraitNames(cg);
|
||||
return ScriptMemberWrapper.WrappableMembers(cg).Select(mi => Tuple.Create(category, mi, required));
|
||||
return ScriptMemberWrapper.WrappableMembers(cg).Select(mi => (category, mi, required));
|
||||
}).GroupBy(g => g.Item1).OrderBy(g => g.Key);
|
||||
|
||||
foreach (var kv in playerCategories)
|
||||
|
||||
@@ -251,17 +251,17 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
var actorCount = Map.ActorDefinitions.Count;
|
||||
var wps = waypointSection
|
||||
.Where(kv => Exts.ParseIntegerInvariant(kv.Value) > 0)
|
||||
.Select(kv => Pair.New(Exts.ParseIntegerInvariant(kv.Key),
|
||||
LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
||||
.Select(kv => (WaypointNumber: Exts.ParseIntegerInvariant(kv.Key),
|
||||
Location: LocationFromMapOffset(Exts.ParseIntegerInvariant(kv.Value), MapSize)));
|
||||
|
||||
// Add waypoint actors skipping duplicate entries
|
||||
foreach (var kv in wps.DistinctBy(location => location.Second))
|
||||
foreach (var kv in wps.DistinctBy(location => location.Location))
|
||||
{
|
||||
if (!singlePlayer && kv.First <= 7)
|
||||
if (!singlePlayer && kv.WaypointNumber <= 7)
|
||||
{
|
||||
var ar = new ActorReference("mpspawn")
|
||||
{
|
||||
new LocationInit((CPos)kv.Second),
|
||||
new LocationInit((CPos)kv.Location),
|
||||
new OwnerInit("Neutral")
|
||||
};
|
||||
|
||||
@@ -272,11 +272,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
var ar = new ActorReference("waypoint")
|
||||
{
|
||||
new LocationInit((CPos)kv.Second),
|
||||
new LocationInit((CPos)kv.Location),
|
||||
new OwnerInit("Neutral")
|
||||
};
|
||||
|
||||
SaveWaypoint(kv.First, ar);
|
||||
SaveWaypoint(kv.WaypointNumber, ar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ using OpenRA.Mods.Common.UpdateRules;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
using YamlFileSet = List<Tuple<IReadWritePackage, string, List<MiniYamlNode>>>;
|
||||
using YamlFileSet = List<(IReadWritePackage, string, List<MiniYamlNode>)>;
|
||||
|
||||
class UpdateMapCommand : IUtilityCommand
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ using OpenRA.Mods.Common.UpdateRules;
|
||||
|
||||
namespace OpenRA.Mods.Common.UtilityCommands
|
||||
{
|
||||
using YamlFileSet = List<Tuple<IReadWritePackage, string, List<MiniYamlNode>>>;
|
||||
using YamlFileSet = List<(IReadWritePackage, string, List<MiniYamlNode>)>;
|
||||
|
||||
class UpdateModCommand : IUtilityCommand
|
||||
{
|
||||
|
||||
@@ -61,18 +61,18 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>()
|
||||
.Where(Exts.IsTraitEnabled)
|
||||
.Select(s => Pair.New(s, s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Second);
|
||||
.Select(s => (HitShape: s, Distance: s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Distance);
|
||||
|
||||
// Cannot be damaged without an active HitShape.
|
||||
if (closestActiveShape.First == null)
|
||||
if (closestActiveShape.HitShape == null)
|
||||
continue;
|
||||
|
||||
var falloffDistance = 0;
|
||||
switch (DamageCalculationType)
|
||||
{
|
||||
case DamageCalculationType.HitShape:
|
||||
falloffDistance = closestActiveShape.Second.Length;
|
||||
falloffDistance = closestActiveShape.Distance.Length;
|
||||
break;
|
||||
case DamageCalculationType.ClosestTargetablePosition:
|
||||
falloffDistance = victim.GetTargetablePositions().Select(x => (x - pos).Length).Min();
|
||||
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
ImpactOrientation = impactOrientation,
|
||||
};
|
||||
|
||||
InflictDamage(victim, firedBy, closestActiveShape.First, updatedWarheadArgs);
|
||||
InflictDamage(victim, firedBy, closestActiveShape.HitShape, updatedWarheadArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,18 +38,18 @@ namespace OpenRA.Mods.Common.Warheads
|
||||
|
||||
var closestActiveShape = victim.TraitsImplementing<HitShape>()
|
||||
.Where(Exts.IsTraitEnabled)
|
||||
.Select(s => Pair.New(s, s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Second);
|
||||
.Select(s => (HitShape: s, Distance: s.DistanceFromEdge(victim, pos)))
|
||||
.MinByOrDefault(s => s.Distance);
|
||||
|
||||
// Cannot be damaged without an active HitShape.
|
||||
if (closestActiveShape.First == null)
|
||||
if (closestActiveShape.HitShape == null)
|
||||
continue;
|
||||
|
||||
// Cannot be damaged if HitShape is outside Spread.
|
||||
if (closestActiveShape.Second > Spread)
|
||||
if (closestActiveShape.Distance > Spread)
|
||||
continue;
|
||||
|
||||
InflictDamage(victim, firedBy, closestActiveShape.First, args);
|
||||
InflictDamage(victim, firedBy, closestActiveShape.HitShape, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,25 +20,25 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public class LabelWithHighlightWidget : LabelWidget
|
||||
{
|
||||
public Color HighlightColor = ChromeMetrics.Get<Color>("TextHighlightColor");
|
||||
readonly CachedTransform<string, Pair<string, bool>[]> textComponents;
|
||||
readonly CachedTransform<string, (string Text, bool Highlighted)[]> textComponents;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public LabelWithHighlightWidget()
|
||||
: base()
|
||||
{
|
||||
textComponents = new CachedTransform<string, Pair<string, bool>[]>(MakeComponents);
|
||||
textComponents = new CachedTransform<string, (string, bool)[]>(MakeComponents);
|
||||
}
|
||||
|
||||
protected LabelWithHighlightWidget(LabelWithHighlightWidget other)
|
||||
: base(other)
|
||||
{
|
||||
HighlightColor = other.HighlightColor;
|
||||
textComponents = new CachedTransform<string, Pair<string, bool>[]>(MakeComponents);
|
||||
textComponents = new CachedTransform<string, (string, bool)[]>(MakeComponents);
|
||||
}
|
||||
|
||||
Pair<string, bool>[] MakeComponents(string text)
|
||||
(string, bool)[] MakeComponents(string text)
|
||||
{
|
||||
List<Pair<string, bool>> components = new List<Pair<string, bool>>();
|
||||
var components = new List<(string, bool)>();
|
||||
foreach (var l in text.Split(new[] { "\\n" }, StringSplitOptions.None))
|
||||
{
|
||||
var line = l;
|
||||
@@ -54,18 +54,18 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
// Normal line segment before highlight
|
||||
var lineNormal = line.Substring(0, highlightStart);
|
||||
components.Add(Pair.New(lineNormal, false));
|
||||
components.Add((lineNormal, false));
|
||||
}
|
||||
|
||||
// Highlight line segment
|
||||
var lineHighlight = line.Substring(highlightStart + 1, highlightEnd - highlightStart - 1);
|
||||
components.Add(Pair.New(lineHighlight, true));
|
||||
components.Add((lineHighlight, true));
|
||||
line = line.Substring(highlightEnd + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Final normal line segment
|
||||
components.Add(Pair.New(line, false));
|
||||
components.Add((line, false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -79,8 +79,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var advance = 0;
|
||||
foreach (var c in textComponents.Update(text))
|
||||
{
|
||||
base.DrawInner(c.First, font, c.Second ? HighlightColor : color, position + new int2(advance, 0));
|
||||
advance += font.Measure(c.First).X;
|
||||
base.DrawInner(c.Text, font, c.Highlighted ? HighlightColor : color, position + new int2(advance, 0));
|
||||
advance += font.Measure(c.Text).X;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
playerPanel.RemoveChildren();
|
||||
|
||||
var teams = world.Players.Where(p => !p.NonCombatant && p.Playable)
|
||||
.Select(p => new Pair<Player, PlayerStatistics>(p, p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.Second != null ? p.Second.Experience : 0)
|
||||
.GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.First.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.Second != null ? gg.Second.Experience : 0));
|
||||
.Select(p => (Player: p, PlayerStatistics: p.PlayerActor.TraitOrDefault<PlayerStatistics>()))
|
||||
.OrderByDescending(p => p.PlayerStatistics != null ? p.PlayerStatistics.Experience : 0)
|
||||
.GroupBy(p => (world.LobbyInfo.ClientWithIndex(p.Player.ClientIndex) ?? new Session.Client()).Team)
|
||||
.OrderByDescending(g => g.Sum(gg => gg.PlayerStatistics != null ? gg.PlayerStatistics.Experience : 0));
|
||||
|
||||
foreach (var t in teams)
|
||||
{
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
teamHeader.Get<LabelWidget>("TEAM").GetText = () => t.Key == 0 ? "No Team" : "Team {0}".F(t.Key);
|
||||
var teamRating = teamHeader.Get<LabelWidget>("TEAM_SCORE");
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
var teamMemberScores = t.Select(tt => tt.Second).Where(s => s != null).ToArray().Select(s => s.Experience);
|
||||
var teamMemberScores = t.Select(tt => tt.PlayerStatistics).Where(s => s != null).ToArray().Select(s => s.Experience);
|
||||
teamRating.GetText = () => scoreCache.Update(teamMemberScores.Sum());
|
||||
|
||||
playerPanel.AddChild(teamHeader);
|
||||
@@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
foreach (var p in t.ToList())
|
||||
{
|
||||
var pp = p.First;
|
||||
var pp = p.Player;
|
||||
var client = world.LobbyInfo.ClientWithIndex(pp.ClientIndex);
|
||||
var item = playerTemplate.Clone();
|
||||
LobbyUtils.SetupProfileWidget(item, client, orderManager, worldRenderer);
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
var scoreCache = new CachedTransform<int, string>(s => s.ToString());
|
||||
item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.Second != null ? p.Second.Experience : 0);
|
||||
item.Get<LabelWidget>("SCORE").GetText = () => scoreCache.Update(p.PlayerStatistics != null ? p.PlayerStatistics.Experience : 0);
|
||||
|
||||
playerPanel.AddChild(item);
|
||||
}
|
||||
@@ -133,13 +133,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var nameFont = Game.Renderer.Fonts[nameLabel.Font];
|
||||
|
||||
var suffixLength = new CachedTransform<string, int>(s => nameFont.Measure(s).X);
|
||||
var name = new CachedTransform<Pair<string, string>, string>(c =>
|
||||
WidgetUtils.TruncateText(c.First, nameLabel.Bounds.Width - suffixLength.Update(c.Second), nameFont) + c.Second);
|
||||
var name = new CachedTransform<(string Name, string Suffix), string>(c =>
|
||||
WidgetUtils.TruncateText(c.Name, nameLabel.Bounds.Width - suffixLength.Update(c.Suffix), nameFont) + c.Suffix);
|
||||
|
||||
nameLabel.GetText = () =>
|
||||
{
|
||||
var suffix = client.State == Session.ClientState.Disconnected ? " (Gone)" : "";
|
||||
return name.Update(Pair.New(client.Name, suffix));
|
||||
return name.Update((client.Name, suffix));
|
||||
};
|
||||
|
||||
var kickButton = item.Get<ButtonWidget>("KICK");
|
||||
|
||||
@@ -442,8 +442,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (powerRes != null)
|
||||
{
|
||||
var power = template.Get<LabelWidget>("POWER");
|
||||
var powerText = new CachedTransform<Pair<int, int>, string>(p => p.First + "/" + p.Second);
|
||||
power.GetText = () => powerText.Update(new Pair<int, int>(powerRes.PowerDrained, powerRes.PowerProvided));
|
||||
var powerText = new CachedTransform<(int PowerDrained, int PowerProvided), string>(p => p.PowerDrained + "/" + p.PowerProvided);
|
||||
power.GetText = () => powerText.Update((powerRes.PowerDrained, powerRes.PowerProvided));
|
||||
power.GetColor = () => GetPowerColor(powerRes.PowerState);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,15 +162,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
/// <summary>Splits a string into two parts on the first instance of a given token.</summary>
|
||||
static Pair<string, string> SplitOnFirstToken(string input, string token = "\\n")
|
||||
static (string First, string Second) SplitOnFirstToken(string input, string token = "\\n")
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return Pair.New<string, string>(null, null);
|
||||
return (null, null);
|
||||
|
||||
var split = input.IndexOf(token, StringComparison.Ordinal);
|
||||
var first = split > 0 ? input.Substring(0, split) : input;
|
||||
var second = split > 0 ? input.Substring(split + token.Length) : null;
|
||||
return Pair.New(first, second);
|
||||
return (first, second);
|
||||
}
|
||||
|
||||
public static void ShowFactionDropDown(DropDownButtonWidget dropdown, Session.Client client,
|
||||
@@ -253,9 +253,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var spawnSize = ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed").Size.XY;
|
||||
var selectedSpawn = preview.SpawnPoints
|
||||
.Select((sp, i) => Pair.New(mapPreview.ConvertToPreview(sp, preview.GridType), i))
|
||||
.Where(a => ((a.First - mi.Location).ToFloat2() / spawnSize * 2).LengthSquared <= 1)
|
||||
.Select(a => a.Second + 1)
|
||||
.Select((sp, i) => (SpawnLocation: mapPreview.ConvertToPreview(sp, preview.GridType), Index: i))
|
||||
.Where(a => ((a.SpawnLocation - mi.Location).ToFloat2() / spawnSize * 2).LengthSquared <= 1)
|
||||
.Select(a => a.Index + 1)
|
||||
.FirstOrDefault();
|
||||
|
||||
var locals = orderManager.LobbyInfo.Clients.Where(c => c.Index == orderManager.LocalClient.Index || (Game.IsHost && c.Bot != null));
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -182,20 +181,20 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
// Order categories alphabetically
|
||||
var categories = categoryDict
|
||||
.Select(kv => Pair.New(kv.Key, kv.Value))
|
||||
.OrderBy(p => p.First)
|
||||
.Select(kv => (Category: kv.Key, Count: kv.Value))
|
||||
.OrderBy(p => p.Category)
|
||||
.ToList();
|
||||
|
||||
// 'all game types' extra item
|
||||
categories.Insert(0, Pair.New(null as string, tabMaps[tab].Count()));
|
||||
categories.Insert(0, (null as string, tabMaps[tab].Count()));
|
||||
|
||||
Func<Pair<string, int>, string> showItem = x => "{0} ({1})".F(x.First ?? "All Maps", x.Second);
|
||||
Func<(string Category, int Count), string> showItem = x => "{0} ({1})".F(x.Category ?? "All Maps", x.Count);
|
||||
|
||||
Func<Pair<string, int>, ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
|
||||
Func<(string Category, int Count), ScrollItemWidget, ScrollItemWidget> setupItem = (ii, template) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(template,
|
||||
() => category == ii.First,
|
||||
() => { category = ii.First; EnumerateMaps(tab, itemTemplate); });
|
||||
() => category == ii.Category,
|
||||
() => { category = ii.Category; EnumerateMaps(tab, itemTemplate); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => showItem(ii);
|
||||
return item;
|
||||
};
|
||||
@@ -205,9 +204,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
gameModeDropdown.GetText = () =>
|
||||
{
|
||||
var item = categories.FirstOrDefault(m => m.First == category);
|
||||
if (item == default(Pair<string, int>))
|
||||
item.First = "No matches";
|
||||
var item = categories.FirstOrDefault(m => m.Category == category);
|
||||
if (item == default((string, int)))
|
||||
item.Category = "No matches";
|
||||
|
||||
return showItem(item);
|
||||
};
|
||||
|
||||
@@ -138,25 +138,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (ddb != null)
|
||||
{
|
||||
// Using list to maintain the order
|
||||
var options = new List<Pair<GameType, string>>
|
||||
var options = new List<(GameType GameType, string Text)>
|
||||
{
|
||||
Pair.New(GameType.Any, ddb.GetText()),
|
||||
Pair.New(GameType.Singleplayer, "Singleplayer"),
|
||||
Pair.New(GameType.Multiplayer, "Multiplayer")
|
||||
(GameType.Any, ddb.GetText()),
|
||||
(GameType.Singleplayer, "Singleplayer"),
|
||||
(GameType.Multiplayer, "Multiplayer")
|
||||
};
|
||||
|
||||
var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
|
||||
var lookup = options.ToDictionary(kvp => kvp.GameType, kvp => kvp.Text);
|
||||
|
||||
ddb.GetText = () => lookup[filter.Type];
|
||||
ddb.OnMouseDown = _ =>
|
||||
{
|
||||
Func<Pair<GameType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
Func<(GameType GameType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(
|
||||
tpl,
|
||||
() => filter.Type == option.First,
|
||||
() => { filter.Type = option.First; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||
() => filter.Type == option.GameType,
|
||||
() => { filter.Type = option.GameType; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -171,28 +171,28 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (ddb != null)
|
||||
{
|
||||
// Using list to maintain the order
|
||||
var options = new List<Pair<DateType, string>>
|
||||
var options = new List<(DateType DateType, string Text)>
|
||||
{
|
||||
Pair.New(DateType.Any, ddb.GetText()),
|
||||
Pair.New(DateType.Today, "Today"),
|
||||
Pair.New(DateType.LastWeek, "Last 7 days"),
|
||||
Pair.New(DateType.LastFortnight, "Last 14 days"),
|
||||
Pair.New(DateType.LastMonth, "Last 30 days")
|
||||
(DateType.Any, ddb.GetText()),
|
||||
(DateType.Today, "Today"),
|
||||
(DateType.LastWeek, "Last 7 days"),
|
||||
(DateType.LastFortnight, "Last 14 days"),
|
||||
(DateType.LastMonth, "Last 30 days")
|
||||
};
|
||||
|
||||
var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
|
||||
var lookup = options.ToDictionary(kvp => kvp.DateType, kvp => kvp.Text);
|
||||
|
||||
ddb.GetText = () => lookup[filter.Date];
|
||||
ddb.OnMouseDown = _ =>
|
||||
{
|
||||
Func<Pair<DateType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
Func<(DateType DateType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(
|
||||
tpl,
|
||||
() => filter.Date == option.First,
|
||||
() => { filter.Date = option.First; ApplyFilter(); });
|
||||
() => filter.Date == option.DateType,
|
||||
() => { filter.Date = option.DateType; ApplyFilter(); });
|
||||
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -207,27 +207,27 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
if (ddb != null)
|
||||
{
|
||||
// Using list to maintain the order
|
||||
var options = new List<Pair<DurationType, string>>
|
||||
var options = new List<(DurationType DurationType, string Text)>
|
||||
{
|
||||
Pair.New(DurationType.Any, ddb.GetText()),
|
||||
Pair.New(DurationType.VeryShort, "Under 5 min"),
|
||||
Pair.New(DurationType.Short, "Short (10 min)"),
|
||||
Pair.New(DurationType.Medium, "Medium (30 min)"),
|
||||
Pair.New(DurationType.Long, "Long (60+ min)")
|
||||
(DurationType.Any, ddb.GetText()),
|
||||
(DurationType.VeryShort, "Under 5 min"),
|
||||
(DurationType.Short, "Short (10 min)"),
|
||||
(DurationType.Medium, "Medium (30 min)"),
|
||||
(DurationType.Long, "Long (60+ min)")
|
||||
};
|
||||
|
||||
var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
|
||||
var lookup = options.ToDictionary(kvp => kvp.DurationType, kvp => kvp.Text);
|
||||
|
||||
ddb.GetText = () => lookup[filter.Duration];
|
||||
ddb.OnMouseDown = _ =>
|
||||
{
|
||||
Func<Pair<DurationType, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
Func<(DurationType DurationType, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(
|
||||
tpl,
|
||||
() => filter.Duration == option.First,
|
||||
() => { filter.Duration = option.First; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||
() => filter.Duration == option.DurationType,
|
||||
() => { filter.Duration = option.DurationType; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||
return item;
|
||||
};
|
||||
|
||||
@@ -244,25 +244,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
ddb.IsDisabled = () => string.IsNullOrEmpty(filter.PlayerName);
|
||||
|
||||
// Using list to maintain the order
|
||||
var options = new List<Pair<WinState, string>>
|
||||
var options = new List<(WinState WinState, string Text)>
|
||||
{
|
||||
Pair.New(WinState.Undefined, ddb.GetText()),
|
||||
Pair.New(WinState.Lost, "Defeat"),
|
||||
Pair.New(WinState.Won, "Victory")
|
||||
(WinState.Undefined, ddb.GetText()),
|
||||
(WinState.Lost, "Defeat"),
|
||||
(WinState.Won, "Victory")
|
||||
};
|
||||
|
||||
var lookup = options.ToDictionary(kvp => kvp.First, kvp => kvp.Second);
|
||||
var lookup = options.ToDictionary(kvp => kvp.WinState, kvp => kvp.Text);
|
||||
|
||||
ddb.GetText = () => lookup[filter.Outcome];
|
||||
ddb.OnMouseDown = _ =>
|
||||
{
|
||||
Func<Pair<WinState, string>, ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
Func<(WinState WinState, string Text), ScrollItemWidget, ScrollItemWidget> setupItem = (option, tpl) =>
|
||||
{
|
||||
var item = ScrollItemWidget.Setup(
|
||||
tpl,
|
||||
() => filter.Outcome == option.First,
|
||||
() => { filter.Outcome = option.First; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Second;
|
||||
() => filter.Outcome == option.WinState,
|
||||
() => { filter.Outcome = option.WinState; ApplyFilter(); });
|
||||
item.Get<LabelWidget>("LABEL").GetText = () => option.Text;
|
||||
return item;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
@@ -26,22 +25,22 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
// Increment the version number when adding new stats
|
||||
const int SystemInformationVersion = 4;
|
||||
|
||||
static Dictionary<string, Pair<string, string>> GetSystemInformation()
|
||||
static Dictionary<string, (string Label, string Value)> GetSystemInformation()
|
||||
{
|
||||
var lang = CultureInfo.InstalledUICulture.TwoLetterISOLanguageName;
|
||||
return new Dictionary<string, Pair<string, string>>()
|
||||
return new Dictionary<string, (string, string)>()
|
||||
{
|
||||
{ "id", Pair.New("Anonymous ID", Game.Settings.Debug.UUID) },
|
||||
{ "platform", Pair.New("OS Type", Platform.CurrentPlatform.ToString()) },
|
||||
{ "os", Pair.New("OS Version", Environment.OSVersion.ToString()) },
|
||||
{ "x64", Pair.New("OS is 64 bit", Environment.Is64BitOperatingSystem.ToString()) },
|
||||
{ "x64process", Pair.New("Process is 64 bit", Environment.Is64BitProcess.ToString()) },
|
||||
{ "runtime", Pair.New(".NET Runtime", Platform.RuntimeVersion) },
|
||||
{ "gl", Pair.New("OpenGL Version", Game.Renderer.GLVersion) },
|
||||
{ "windowsize", Pair.New("Window Size", "{0}x{1}".F(Game.Renderer.NativeResolution.Width, Game.Renderer.NativeResolution.Height)) },
|
||||
{ "windowscale", Pair.New("Window Scale", Game.Renderer.NativeWindowScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "uiscale", Pair.New("UI Scale", Game.Settings.Graphics.UIScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "lang", Pair.New("System Language", lang) }
|
||||
{ "id", ("Anonymous ID", Game.Settings.Debug.UUID) },
|
||||
{ "platform", ("OS Type", Platform.CurrentPlatform.ToString()) },
|
||||
{ "os", ("OS Version", Environment.OSVersion.ToString()) },
|
||||
{ "x64", ("OS is 64 bit", Environment.Is64BitOperatingSystem.ToString()) },
|
||||
{ "x64process", ("Process is 64 bit", Environment.Is64BitProcess.ToString()) },
|
||||
{ "runtime", (".NET Runtime", Platform.RuntimeVersion) },
|
||||
{ "gl", ("OpenGL Version", Game.Renderer.GLVersion) },
|
||||
{ "windowsize", ("Window Size", "{0}x{1}".F(Game.Renderer.NativeResolution.Width, Game.Renderer.NativeResolution.Height)) },
|
||||
{ "windowscale", ("Window Scale", Game.Renderer.NativeWindowScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "uiscale", ("UI Scale", Game.Settings.Graphics.UIScale.ToString("F2", CultureInfo.InvariantCulture)) },
|
||||
{ "lang", ("System Language", lang) }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
return "&sysinfoversion={0}&".F(SystemInformationVersion)
|
||||
+ GetSystemInformation()
|
||||
.Select(kv => kv.Key + "=" + Uri.EscapeUriString(kv.Value.Second))
|
||||
.Select(kv => kv.Key + "=" + Uri.EscapeUriString(kv.Value.Value))
|
||||
.JoinWith("&");
|
||||
}
|
||||
|
||||
@@ -75,7 +74,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
foreach (var info in GetSystemInformation().Values)
|
||||
{
|
||||
var label = template.Clone() as LabelWidget;
|
||||
var text = info.First + ": " + info.Second;
|
||||
var text = info.Label + ": " + info.Value;
|
||||
label.GetText = () => text;
|
||||
sysInfoData.AddChild(label);
|
||||
}
|
||||
|
||||
@@ -206,8 +206,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
void UpdateTerrainColor(MPos uv)
|
||||
{
|
||||
var colorPair = playerRadarTerrain != null && playerRadarTerrain.IsInitialized ? playerRadarTerrain[uv] : PlayerRadarTerrain.GetColor(world.Map, uv);
|
||||
var leftColor = colorPair.First;
|
||||
var rightColor = colorPair.Second;
|
||||
var leftColor = colorPair.Left;
|
||||
var rightColor = colorPair.Right;
|
||||
|
||||
var stride = radarSheet.Size.Width;
|
||||
|
||||
@@ -386,7 +386,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var stride = radarSheet.Size.Width;
|
||||
Array.Clear(radarData, 4 * actorSprite.Bounds.Top * stride, 4 * actorSprite.Bounds.Height * stride);
|
||||
|
||||
var cells = new List<Pair<CPos, Color>>();
|
||||
var cells = new List<(CPos Cell, Color Color)>();
|
||||
|
||||
unsafe
|
||||
{
|
||||
@@ -403,11 +403,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
t.Trait.PopulateRadarSignatureCells(t.Actor, cells);
|
||||
foreach (var cell in cells)
|
||||
{
|
||||
if (!world.Map.Contains(cell.First))
|
||||
if (!world.Map.Contains(cell.Cell))
|
||||
continue;
|
||||
|
||||
var uv = cell.First.ToMPos(world.Map.Grid.Type);
|
||||
var color = cell.Second.ToArgb();
|
||||
var uv = cell.Cell.ToMPos(world.Map.Grid.Type);
|
||||
var color = cell.Color.ToArgb();
|
||||
if (isRectangularIsometric)
|
||||
{
|
||||
// Odd rows are shifted right by 1px
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
readonly int timestep;
|
||||
readonly IEnumerable<SupportPowerInstance> powers;
|
||||
readonly Color bgDark, bgLight;
|
||||
Pair<string, Color>[] texts;
|
||||
(string Text, Color Color)[] texts;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public SupportPowerTimerWidget(World world)
|
||||
@@ -67,7 +67,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var color = !p.Ready || Game.LocalTick % 50 < 25 ? playerColor : Color.White;
|
||||
|
||||
return Pair.New(text, color);
|
||||
return (text, color);
|
||||
}).ToArray();
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
foreach (var t in texts)
|
||||
{
|
||||
var font = Game.Renderer.Fonts[Font];
|
||||
font.DrawTextWithShadow(t.First, new float2(Bounds.Location) + new float2(0, y), t.Second, bgDark, bgLight, 1);
|
||||
y += (font.Measure(t.First).Y + 5) * (int)Order;
|
||||
font.DrawTextWithShadow(t.Text, new float2(Bounds.Location) + new float2(0, y), t.Color, bgDark, bgLight, 1);
|
||||
y += (font.Measure(t.Text).Y + 5) * (int)Order;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -337,19 +337,19 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
var client = p.World.LobbyInfo.ClientWithIndex(p.ClientIndex);
|
||||
var nameFont = Game.Renderer.Fonts[label.Font];
|
||||
var name = new CachedTransform<Tuple<string, WinState, Session.ClientState>, string>(c =>
|
||||
var name = new CachedTransform<(string Name, WinState WinState, Session.ClientState ClientState), string>(c =>
|
||||
{
|
||||
var suffix = c.Item2 == WinState.Undefined ? "" : " (" + c.Item2 + ")";
|
||||
if (c.Item3 == Session.ClientState.Disconnected)
|
||||
var suffix = c.WinState == WinState.Undefined ? "" : " (" + c.Item2 + ")";
|
||||
if (c.ClientState == Session.ClientState.Disconnected)
|
||||
suffix = " (Gone)";
|
||||
|
||||
return TruncateText(c.Item1, label.Bounds.Width - nameFont.Measure(suffix).X, nameFont) + suffix;
|
||||
return TruncateText(c.Name, label.Bounds.Width - nameFont.Measure(suffix).X, nameFont) + suffix;
|
||||
});
|
||||
|
||||
label.GetText = () =>
|
||||
{
|
||||
var clientState = client != null ? client.State : Session.ClientState.Ready;
|
||||
return name.Update(Tuple.Create(p.PlayerName, p.WinState, clientState));
|
||||
return name.Update((p.PlayerName, p.WinState, clientState));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user