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