Fix RCS1077

This commit is contained in:
RoosterDragon
2023-03-18 12:47:08 +00:00
committed by Gustas
parent 499efa1d0a
commit 330ca92045
60 changed files with 110 additions and 97 deletions

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Scripting;
@@ -24,7 +25,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Returns the player with the specified internal name, or nil if a match is not found.")]
public Player GetPlayer(string name)
{
return Context.World.Players.FirstOrDefault(p => p.InternalName == name);
return Array.Find(Context.World.Players, p => p.InternalName == name);
}
[Desc("Returns a table of players filtered by the specified function.")]

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -33,7 +34,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Returns the count of the actor's specified ammopool.")]
public int AmmoCount(string poolName = "primary")
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
var pool = Array.Find(ammoPools, a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");
@@ -43,7 +44,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Returns the maximum count of ammo the actor can load.")]
public int MaximumAmmoCount(string poolName = "primary")
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
var pool = Array.Find(ammoPools, a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");
@@ -54,7 +55,7 @@ namespace OpenRA.Mods.Common.Scripting
"(Use a negative amount to remove ammo.)")]
public void Reload(string poolName = "primary", int amount = 1)
{
var pool = ammoPools.FirstOrDefault(a => a.Info.Name == poolName);
var pool = Array.Find(ammoPools, a => a.Info.Name == poolName);
if (pool == null)
throw new LuaException($"Invalid ammopool name {poolName} queried on actor {self}.");

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -33,8 +34,7 @@ namespace OpenRA.Mods.Common.Scripting
"If duration > 0 the condition will be automatically revoked after the defined number of ticks.")]
public int GrantCondition(string condition, int duration = 0)
{
var external = externalConditions
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
var external = Array.Find(externalConditions, t => t.Info.Condition == condition && t.CanGrantCondition(this));
if (external == null)
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");

View File

@@ -9,6 +9,7 @@
*/
#endregion
using System;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -32,8 +33,7 @@ namespace OpenRA.Mods.Common.Scripting
"If duration > 0 the condition will be automatically revoked after the defined number of ticks.")]
public int GrantCondition(string condition, int duration = 0)
{
var external = externalConditions
.FirstOrDefault(t => t.Info.Condition == condition && t.CanGrantCondition(this));
var external = Array.Find(externalConditions, t => t.Info.Condition == condition && t.CanGrantCondition(this));
if (external == null)
throw new LuaException($"Condition `{condition}` has not been listed on an enabled ExternalCondition trait");

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Scripting
{
get
{
var c = Player.World.LobbyInfo.Clients.FirstOrDefault(i => i.Index == Player.ClientIndex);
var c = Player.World.LobbyInfo.Clients.Find(i => i.Index == Player.ClientIndex);
return c?.Team ?? 0;
}
}
@@ -57,7 +57,7 @@ namespace OpenRA.Mods.Common.Scripting
{
get
{
var c = Player.World.LobbyInfo.Clients.FirstOrDefault(i => i.Index == Player.ClientIndex);
var c = Player.World.LobbyInfo.Clients.Find(i => i.Index == Player.ClientIndex);
return c?.Handicap ?? 0;
}
}

View File

@@ -187,8 +187,7 @@ namespace OpenRA.Mods.Common.Scripting
if (triggers.HasAnyCallbacksFor(Trigger.OnProduction))
return true;
return queues.Where(q => GetBuildableInfo(actorType).Queue.Contains(q.Info.Type))
.Any(q => q.AllQueued().Any());
return queues.Any(q => GetBuildableInfo(actorType).Queue.Contains(q.Info.Type) && q.AllQueued().Any());
}
BuildableInfo GetBuildableInfo(string actorType)