Replace .WithInterface<T>().Any() => .HasTraitInfo<T>()
This commit is contained in:
@@ -279,7 +279,7 @@ namespace OpenRA.Traits
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface Requires<T> where T : class, ITraitInfo { }
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1302:InterfaceNamesMustBeginWithI", Justification = "Not a real interface, but more like a tag.")]
|
||||
public interface UsesInit<T> where T : IActorInit { }
|
||||
public interface UsesInit<T> : ITraitInfo where T : IActorInit { }
|
||||
|
||||
public interface INotifySelected { void Selected(Actor self); }
|
||||
public interface INotifySelection { void SelectionChanged(); }
|
||||
|
||||
@@ -96,13 +96,13 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
var facing = underCursor.Init<FacingInit>();
|
||||
if (facing != null)
|
||||
underCursor.ReplaceInit(new FacingInit((facing.Value(world) + mi.ScrollDelta) % 256));
|
||||
else if (underCursor.Info.Traits.WithInterface<UsesInit<FacingInit>>().Any())
|
||||
else if (underCursor.Info.HasTraitInfo<UsesInit<FacingInit>>())
|
||||
underCursor.ReplaceInit(new FacingInit(mi.ScrollDelta));
|
||||
|
||||
var turret = underCursor.Init<TurretFacingInit>();
|
||||
if (turret != null)
|
||||
underCursor.ReplaceInit(new TurretFacingInit((turret.Value(world) + mi.ScrollDelta) % 256));
|
||||
else if (underCursor.Info.Traits.WithInterface<UsesInit<TurretFacingInit>>().Any())
|
||||
else if (underCursor.Info.HasTraitInfo<UsesInit<TurretFacingInit>>())
|
||||
underCursor.ReplaceInit(new TurretFacingInit(mi.ScrollDelta));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
this.info = info;
|
||||
manager = self.Trait<UpgradeManager>();
|
||||
checkTerrainType = info.AllowedTerrainTypes.Count > 0;
|
||||
canTurn = self.Info.Traits.WithInterface<IFacingInfo>().Any();
|
||||
canTurn = self.Info.HasTraitInfo<IFacingInfo>();
|
||||
body = Exts.Lazy(self.TraitOrDefault<ISpriteBody>);
|
||||
}
|
||||
|
||||
@@ -168,4 +168,4 @@ namespace OpenRA.Mods.Common.Traits
|
||||
manager.RevokeUpgrade(self, up, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
var assets = template.Get<LabelWidget>("ASSETS");
|
||||
assets.GetText = () => "$" + world.Actors
|
||||
.Where(a => a.Owner == player && !a.IsDead && a.Info.Traits.WithInterface<ValuedInfo>().Any())
|
||||
.Where(a => a.Owner == player && !a.IsDead && a.Info.HasTraitInfo<ValuedInfo>())
|
||||
.Sum(a => a.Info.Traits.WithInterface<ValuedInfo>().First().Cost);
|
||||
|
||||
var harvesters = template.Get<LabelWidget>("HARVESTERS");
|
||||
|
||||
Reference in New Issue
Block a user