本文整理匯總了C#中WCell.RealmServer.Entities.WorldObject.IsHostileWith方法的典型用法代碼示例。如果您正苦於以下問題:C# WorldObject.IsHostileWith方法的具體用法?C# WorldObject.IsHostileWith怎麽用?C# WorldObject.IsHostileWith使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WCell.RealmServer.Entities.WorldObject
的用法示例。
在下文中一共展示了WorldObject.IsHostileWith方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckValidTarget
/// <summary>
/// Checks whether the given target is valid for the given caster.
/// Is called automatically when SpellCast selects Targets.
/// Does not do maximum range check.
/// </summary>
public SpellFailedReason CheckValidTarget(WorldObject caster, WorldObject target)
{
if (target is Unit)
{
// AuraState
if (RequiredTargetAuraState != 0 || ExcludeTargetAuraState != 0)
{
var state = ((Unit)target).AuraState;
if ((RequiredTargetAuraState != 0 && !state.HasAnyFlag(RequiredTargetAuraState)) ||
(ExcludeTargetAuraState != 0 && state.HasAnyFlag(ExcludeTargetAuraState)))
{
return SpellFailedReason.TargetAurastate;
}
}
// Required Auras
if ((ExcludeTargetAuraId != 0 && ((Unit)target).Auras.Contains(ExcludeTargetAuraId)) ||
(RequiredTargetAuraId != 0 && !((Unit)target).Auras.Contains(RequiredTargetAuraId)))
{
return SpellFailedReason.TargetAurastate;
}
}
// Make sure that we have a GameObject if the Spell requires one
if (TargetFlags.HasAnyFlag(SpellTargetFlags.UnkUnit_0x100) &&
(!(target is GameObject) || !target.IsInWorld))
{
return SpellFailedReason.BadTargets;
}
// CreatureTypes
if (TargetCreatureTypes != TargetCreatureMask.None &&
(!(target is NPC) || !((NPC)target).CheckCreatureType(TargetCreatureTypes)))
{
return SpellFailedReason.BadImplicitTargets;
}
if (!CanCastOnPlayer && target is Character)
{
return SpellFailedReason.BadImplicitTargets;
}
// Corpse target
if (ReqDeadTarget)
{
if (TargetFlags.HasAnyFlag(SpellTargetFlags.PvPCorpse | SpellTargetFlags.Corpse))
{
if (!(target is Corpse) ||
(TargetFlags.HasAnyFlag(SpellTargetFlags.PvPCorpse) && !caster.IsHostileWith(target)))
{
return SpellFailedReason.BadImplicitTargets;
}
}
else if (!(target is NPC) || ((NPC)target).IsAlive || target.Loot != null)
{
// need to be dead and looted empty
return SpellFailedReason.TargetNotDead;
}
}
else
{
if (target is Unit && !((Unit)target).IsAlive)
{
return SpellFailedReason.TargetsDead;
}
}
// Rogues do it from behind
if (AttributesExB.HasFlag(SpellAttributesExB.RequiresBehindTarget))
{
if (!caster.IsBehind(target))
{
return SpellFailedReason.NotBehind;
}
}
if (AttributesExC.HasFlag(SpellAttributesExC.NoInitialAggro))
{
if (target is Unit && ((Unit)target).IsInCombat)
{
return SpellFailedReason.TargetAffectingCombat;
}
}
if (Range.MinDist > 0 &&
//caster.IsInRadius(target, caster.GetSpellMinRange(Range.MinDist, target)))
caster.IsInRadius(target, Range.MinDist))
{
return SpellFailedReason.TooClose;
}
return SpellFailedReason.Ok;
}
示例2: ValidateAndTrigger
public void ValidateAndTrigger(Spell spell, Unit triggerOwner, WorldObject target, IUnitAction action = null, SpellEffect triggerEffect = null)
{
WorldObject[] targets;
if (triggerOwner == null)
{
_log.Warn("triggerOwner is null when trying to proc spell: {0} (target: {1})", spell, target);
return;
}
if (spell.CasterIsTarget || !spell.HasTargets)
{
targets = new[] { triggerOwner };
}
else if (target != null)
{
if (spell.IsAreaSpell ||
CasterObject == null ||
spell.IsHarmfulFor(CasterReference, target) != target.IsHostileWith(CasterObject))
{
targets = null;
}
else
{
targets = new[] { target };
}
}
else
{
targets = null;
}
if (action != null)
{
action.ReferenceCount++;
TriggerAction = action;
}
Start(spell, triggerEffect, true, targets);
}