本文整理汇总了C#中UnityEngine.GameObject.?.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# GameObject.?.GetComponent方法的具体用法?C# GameObject.?.GetComponent怎么用?C# GameObject.?.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.GameObject
的用法示例。
在下文中一共展示了GameObject.?.GetComponent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mod_AdjustDamageDealt
public void mod_AdjustDamageDealt(GameObject enemy, DamageInfo damage, bool testing) {
if (IEModOptions.DisableFriendlyFire && gameObject && enemy?.GetComponent<Faction>()?.IsFriendly(gameObject) == true && base.IsPartyMember) {
damage.IsCriticalHit = damage.Interrupts = damage.IsGraze =damage.IsKillingBlow = false;
damage.IsMiss = true;
return;
}
orig_AdjustDamageDealt(enemy, damage, testing);
}
示例2: FriendlyRightNowAndAlsoWhenConfused
public static bool FriendlyRightNowAndAlsoWhenConfused(GameObject target, GameObject caster) {
var targetFaction = target?.GetComponent<Faction>();
var casterFaction = caster?.GetComponent<Faction>();
var targetAiController = GameUtilities.FindActiveAIController(target);
if (IEModOptions.TargetTurnedEnemies && targetAiController != null && casterFaction != null) {
var targetOriginallyFriendly = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction.CurrentTeam)
== Faction.Relationship.Friendly;
if (!targetOriginallyFriendly) {
return false;
}
}
return targetFaction?.IsFriendly(caster) == true || casterFaction?.IsFriendly(target) == true;
}
示例3: mod_CanActivate
public bool mod_CanActivate(GameObject victim) {
if (!this.m_trap_initialized)
{
Debug.LogError("Cannot activate uninitialized trap!");
return false;
}
if (IEModOptions.DisableFriendlyFire) {
Faction victimFaction = victim?.GetComponent<Faction>();
if (victimFaction?.isPartyMember == true && this.IsPlayerOwnedTrap)
{
return false;
}
}
return orig_CanActivate(victim);
}
示例4: HostileEvenIfConfused
public static bool HostileEvenIfConfused(GameObject target, GameObject caster) {
var targetFaction = target?.GetComponent<Faction>();
var casterFaction = caster?.GetComponent<Faction>();
var targetAiController = GameUtilities.FindActiveAIController(target);
if (targetFaction?.IsHostile(caster) == true || casterFaction?.IsHostile(target) == true) {
//they're actually hostile
return true;
}
if (targetAiController == null) {
//not AI controller. Can never be confused.
return false;
}
if (!IEModOptions.TargetTurnedEnemies) {
//no more checks if the option is disabled.
return false;
}
var targetOriginal = targetAiController.GetOriginalTeam()?.GetRelationship(casterFaction?.CurrentTeam)
== Faction.Relationship.Hostile;
return targetOriginal;
}