Changed code to use object initializers everywhere
This commit is contained in:
@@ -29,8 +29,7 @@ namespace OpenRA.Network
|
||||
|
||||
public string Serialize()
|
||||
{
|
||||
var data = new List<MiniYamlNode>();
|
||||
data.Add(new MiniYamlNode("Handshake", FieldSaver.Save(this)));
|
||||
var data = new List<MiniYamlNode> { new MiniYamlNode("Handshake", FieldSaver.Save(this)) };
|
||||
return data.WriteToString();
|
||||
}
|
||||
}
|
||||
@@ -54,8 +53,10 @@ namespace OpenRA.Network
|
||||
|
||||
public static HandshakeResponse Deserialize(string data)
|
||||
{
|
||||
var handshake = new HandshakeResponse();
|
||||
handshake.Client = new Session.Client();
|
||||
var handshake = new HandshakeResponse
|
||||
{
|
||||
Client = new Session.Client()
|
||||
};
|
||||
|
||||
var ys = MiniYaml.FromString(data);
|
||||
foreach (var y in ys)
|
||||
|
||||
@@ -43,9 +43,12 @@ namespace OpenRA
|
||||
|
||||
try
|
||||
{
|
||||
var psi = new ProcessStartInfo("uname", "-s");
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var psi = new ProcessStartInfo("uname", "-s")
|
||||
{
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
var p = Process.Start(psi);
|
||||
var kernelName = p.StandardOutput.ReadToEnd();
|
||||
if (kernelName.Contains("Darwin"))
|
||||
|
||||
@@ -90,9 +90,11 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
var count = s.ReadUInt8();
|
||||
for (var j = 0; j < count; j++)
|
||||
{
|
||||
var v = new VxlElement();
|
||||
v.Color = s.ReadUInt8();
|
||||
v.Normal = s.ReadUInt8();
|
||||
var v = new VxlElement
|
||||
{
|
||||
Color = s.ReadUInt8(),
|
||||
Normal = s.ReadUInt8()
|
||||
};
|
||||
|
||||
l.VoxelMap[x, y].Add(z, v);
|
||||
z++;
|
||||
@@ -120,8 +122,11 @@ namespace OpenRA.Mods.Cnc.FileFormats
|
||||
Limbs = new VxlLimb[LimbCount];
|
||||
for (var i = 0; i < LimbCount; i++)
|
||||
{
|
||||
Limbs[i] = new VxlLimb();
|
||||
Limbs[i].Name = s.ReadASCII(16);
|
||||
Limbs[i] = new VxlLimb
|
||||
{
|
||||
Name = s.ReadASCII(16)
|
||||
};
|
||||
|
||||
s.Seek(12, SeekOrigin.Current);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,11 @@ namespace OpenRA.Mods.Common.Pathfinder
|
||||
public static IPathSearch Search(World world, Locomotor locomotor, Actor self, BlockedByActor check, Func<CPos, bool> goalCondition)
|
||||
{
|
||||
var graph = new PathGraph(LayerPoolForWorld(world), locomotor, self, world, check);
|
||||
var search = new PathSearch(graph);
|
||||
search.isGoal = goalCondition;
|
||||
search.heuristic = loc => 0;
|
||||
return search;
|
||||
return new PathSearch(graph)
|
||||
{
|
||||
isGoal = goalCondition,
|
||||
heuristic = loc => 0
|
||||
};
|
||||
}
|
||||
|
||||
public static IPathSearch FromPoint(World world, Locomotor locomotor, Actor self, CPos @from, CPos target, BlockedByActor check)
|
||||
|
||||
@@ -42,8 +42,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var rs = self.Trait<RenderSprites>();
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self));
|
||||
anim.IsDecoration = true;
|
||||
anim = new Animation(self.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self))
|
||||
{
|
||||
IsDecoration = true
|
||||
};
|
||||
|
||||
anim.Play(info.Sequence);
|
||||
rs.Add(new AnimationWithOffset(anim,
|
||||
() => body.LocalToWorld(info.LocalOffset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
|
||||
|
||||
@@ -66,8 +66,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
facing = () => f;
|
||||
}
|
||||
|
||||
var anim = new Animation(init.World, Image ?? image, facing);
|
||||
anim.IsDecoration = IsDecoration;
|
||||
var anim = new Animation(init.World, Image ?? image, facing)
|
||||
{
|
||||
IsDecoration = IsDecoration
|
||||
};
|
||||
|
||||
anim.PlayRepeating(RenderSprites.NormalizeSequence(anim, init.GetDamageState(), Sequence));
|
||||
|
||||
var body = init.Actor.TraitInfo<BodyOrientationInfo>();
|
||||
@@ -94,8 +97,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var body = self.Trait<BodyOrientation>();
|
||||
|
||||
var image = info.Image ?? rs.GetImage(self);
|
||||
overlay = new Animation(self.World, image, () => IsTraitPaused);
|
||||
overlay.IsDecoration = info.IsDecoration;
|
||||
overlay = new Animation(self.World, image, () => IsTraitPaused)
|
||||
{
|
||||
IsDecoration = info.IsDecoration
|
||||
};
|
||||
|
||||
if (info.StartSequence != null)
|
||||
overlay.PlayThen(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.StartSequence),
|
||||
() => overlay.PlayRepeating(RenderSprites.NormalizeSequence(overlay, self.GetDamageState(), info.Sequence)));
|
||||
|
||||
@@ -66,11 +66,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
object IAssignSpawnPointsInfo.InitializeState(MapPreview map, Session lobbyInfo)
|
||||
{
|
||||
var state = new AssignSpawnLocationsState();
|
||||
var state = new AssignSpawnLocationsState
|
||||
{
|
||||
// Initialize the list of unoccupied spawn points for AssignSpawnLocations to pick from
|
||||
SpawnLocations = map.SpawnPoints,
|
||||
AvailableSpawnPoints = LobbyUtils.AvailableSpawnPoints(map.SpawnPoints.Length, lobbyInfo)
|
||||
};
|
||||
|
||||
// Initialize the list of unoccupied spawn points for AssignSpawnLocations to pick from
|
||||
state.SpawnLocations = map.SpawnPoints;
|
||||
state.AvailableSpawnPoints = LobbyUtils.AvailableSpawnPoints(map.SpawnPoints.Length, lobbyInfo);
|
||||
foreach (var kv in lobbyInfo.Slots)
|
||||
{
|
||||
var client = lobbyInfo.ClientInSlot(kv.Key);
|
||||
|
||||
@@ -107,8 +107,11 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
panel = p;
|
||||
|
||||
// Mask to prevent any clicks from being sent to other widgets
|
||||
fullscreenMask = new MaskWidget();
|
||||
fullscreenMask.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
|
||||
fullscreenMask = new MaskWidget
|
||||
{
|
||||
Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height)
|
||||
};
|
||||
|
||||
fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); RemovePanel(); };
|
||||
if (onCancel != null)
|
||||
fullscreenMask.OnMouseDown += _ => onCancel();
|
||||
|
||||
@@ -193,9 +193,12 @@ namespace OpenRA.Platforms.Default
|
||||
// Attempt to automatically detect DPI
|
||||
try
|
||||
{
|
||||
var psi = new ProcessStartInfo("/usr/bin/xrdb", "-query");
|
||||
psi.UseShellExecute = false;
|
||||
psi.RedirectStandardOutput = true;
|
||||
var psi = new ProcessStartInfo("/usr/bin/xrdb", "-query")
|
||||
{
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true
|
||||
};
|
||||
|
||||
var p = Process.Start(psi);
|
||||
var lines = p.StandardOutput.ReadToEnd().Split('\n');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user