本文整理汇总了C#中ActorInfo.TraitInfos方法的典型用法代码示例。如果您正苦于以下问题:C# ActorInfo.TraitInfos方法的具体用法?C# ActorInfo.TraitInfos怎么用?C# ActorInfo.TraitInfos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActorInfo
的用法示例。
在下文中一共展示了ActorInfo.TraitInfos方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPreview
public void SetPreview(ActorInfo actor, TypeDictionary td)
{
var init = new ActorPreviewInitializer(actor, worldRenderer, td);
preview = actor.TraitInfos<IRenderActorPreviewInfo>()
.SelectMany(rpi => rpi.RenderPreview(init))
.ToArray();
// Calculate the preview bounds
PreviewOffset = int2.Zero;
IdealPreviewSize = int2.Zero;
var r = preview
.SelectMany(p => p.Render(worldRenderer, WPos.Zero))
.OrderBy(WorldRenderer.RenderableScreenZPositionComparisonKey)
.Select(rr => rr.PrepareRender(worldRenderer));
if (r.Any())
{
var b = r.First().ScreenBounds(worldRenderer);
foreach (var rr in r.Skip(1))
b = Rectangle.Union(b, rr.ScreenBounds(worldRenderer));
IdealPreviewSize = new int2(b.Width, b.Height);
PreviewOffset = -new int2(b.Left, b.Top) - IdealPreviewSize / 2;
}
}
示例2: CheckVoices
void CheckVoices(ActorInfo actorInfo, Action<string> emitError, Ruleset rules, string voiceSet)
{
var soundInfo = rules.Voices[voiceSet.ToLowerInvariant()];
foreach (var traitInfo in actorInfo.TraitInfos<ITraitInfo>())
{
var fields = traitInfo.GetType().GetFields().Where(f => f.HasAttribute<VoiceReferenceAttribute>());
foreach (var field in fields)
{
var voices = LintExts.GetFieldValues(traitInfo, field, emitError);
foreach (var voice in voices)
{
if (string.IsNullOrEmpty(voice))
continue;
if (!soundInfo.Voices.Keys.Contains(voice))
emitError("Actor {0} using voice set {1} does not define {2} voice required by {3}.".F(actorInfo.Name, voiceSet, voice, traitInfo));
}
}
}
}
示例3: HasSufficientPowerForActor
bool HasSufficientPowerForActor(ActorInfo actorInfo)
{
return (actorInfo.TraitInfos<PowerInfo>().Where(i => i.UpgradeMinEnabledLevel < 1)
.Sum(p => p.Amount) + playerPower.ExcessPower) >= ai.Info.MinimumExcessPower;
}
示例4: HasAdequateAirUnitReloadBuildings
// For mods like RA (number of building must match the number of aircraft)
bool HasAdequateAirUnitReloadBuildings(ActorInfo actorInfo)
{
var aircraftInfo = actorInfo.TraitInfoOrDefault<AircraftInfo>();
if (aircraftInfo == null)
return true;
var ammoPoolsInfo = actorInfo.TraitInfos<AmmoPoolInfo>();
if (ammoPoolsInfo.Any(x => !x.SelfReloads))
{
var countOwnAir = CountUnits(actorInfo.Name, Player);
var countBuildings = aircraftInfo.RearmBuildings.Sum(b => CountBuilding(b, Player));
if (countOwnAir >= countBuildings)
return false;
}
return true;
}