当前位置: 首页>>代码示例>>C#>>正文


C# ActorInfo.TraitInfos方法代码示例

本文整理汇总了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;
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:ActorPreviewWidget.cs

示例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));
					}
				}
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:21,代码来源:CheckVoiceReferences.cs

示例3: HasSufficientPowerForActor

		bool HasSufficientPowerForActor(ActorInfo actorInfo)
		{
			return (actorInfo.TraitInfos<PowerInfo>().Where(i => i.UpgradeMinEnabledLevel < 1)
				.Sum(p => p.Amount) + playerPower.ExcessPower) >= ai.Info.MinimumExcessPower;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:5,代码来源:BaseBuilder.cs

示例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;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:19,代码来源:HackyAI.cs


注:本文中的ActorInfo.TraitInfos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。