Simplify collection initialization
This commit is contained in:
committed by
atlimit8
parent
cae43808d9
commit
aa998a46d9
@@ -35,9 +35,10 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
if (!Context.World.Map.Rules.Actors.TryGetValue(actorType, out var ai))
|
||||
throw new LuaException($"Unknown actor type '{actorType}'");
|
||||
|
||||
var initDict = new TypeDictionary();
|
||||
|
||||
initDict.Add(new OwnerInit(owner));
|
||||
var initDict = new TypeDictionary
|
||||
{
|
||||
new OwnerInit(owner)
|
||||
};
|
||||
|
||||
if (entryLocation.HasValue)
|
||||
{
|
||||
|
||||
@@ -161,9 +161,11 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (specificOwnerInfo != null && !specificOwnerInfo.ValidOwnerNames.Contains(ownerName))
|
||||
ownerName = specificOwnerInfo.ValidOwnerNames.First();
|
||||
|
||||
var reference = new ActorReference(actor.Name);
|
||||
reference.Add(new OwnerInit(ownerName));
|
||||
reference.Add(new FactionInit(owner.Faction));
|
||||
var reference = new ActorReference(actor.Name)
|
||||
{
|
||||
new OwnerInit(ownerName),
|
||||
new FactionInit(owner.Faction)
|
||||
};
|
||||
|
||||
var worldPx = wr.Viewport.ViewToWorldPx(Viewport.LastMousePos) - wr.ScreenPxOffset(actorCenterOffset);
|
||||
var cell = wr.Viewport.ViewToWorld(wr.Viewport.WorldToViewPx(worldPx));
|
||||
|
||||
@@ -181,9 +181,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
continue;
|
||||
|
||||
var actor = a.Actor;
|
||||
var td = new TypeDictionary();
|
||||
td.Add(new OwnerInit(selectedOwner.Name));
|
||||
td.Add(new FactionInit(selectedOwner.Faction));
|
||||
var td = new TypeDictionary
|
||||
{
|
||||
new OwnerInit(selectedOwner.Name),
|
||||
new FactionInit(selectedOwner.Faction)
|
||||
};
|
||||
foreach (var api in actor.TraitInfos<IActorPreviewInitInfo>())
|
||||
foreach (var o in api.ActorPreviewInits(actor, ActorPreviewType.MapEditorSidebar))
|
||||
td.Add(o);
|
||||
|
||||
@@ -418,13 +418,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
? new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height)
|
||||
: w.Parent.Bounds;
|
||||
|
||||
var substitutions = new Dictionary<string, int>();
|
||||
substitutions.Add("WINDOW_RIGHT", Game.Renderer.Resolution.Width);
|
||||
substitutions.Add("WINDOW_BOTTOM", Game.Renderer.Resolution.Height);
|
||||
substitutions.Add("PARENT_RIGHT", parentBounds.Width);
|
||||
substitutions.Add("PARENT_LEFT", parentBounds.Left);
|
||||
substitutions.Add("PARENT_TOP", parentBounds.Top);
|
||||
substitutions.Add("PARENT_BOTTOM", parentBounds.Height);
|
||||
var substitutions = new Dictionary<string, int>
|
||||
{
|
||||
{ "WINDOW_RIGHT", Game.Renderer.Resolution.Width },
|
||||
{ "WINDOW_BOTTOM", Game.Renderer.Resolution.Height },
|
||||
{ "PARENT_RIGHT", parentBounds.Width },
|
||||
{ "PARENT_LEFT", parentBounds.Left },
|
||||
{ "PARENT_TOP", parentBounds.Top },
|
||||
{ "PARENT_BOTTOM", parentBounds.Height }
|
||||
};
|
||||
|
||||
var width = Evaluator.Evaluate(w.Width, substitutions);
|
||||
var height = Evaluator.Evaluate(w.Height, substitutions);
|
||||
|
||||
Reference in New Issue
Block a user