Use Tuple syntax

This commit is contained in:
teinarss
2020-08-02 13:41:03 +02:00
committed by Paul Chote
parent 8a74f6ea18
commit 19b02875c7
90 changed files with 738 additions and 826 deletions

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -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]);
}
}
}