Changed code to use object initializers everywhere

This commit is contained in:
penev92
2022-01-20 01:07:24 +02:00
committed by abcdefg30
parent 70e2769a85
commit ab09ce21b4
9 changed files with 58 additions and 31 deletions

View File

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

View File

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

View File

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