本文整理汇总了C#中Actor.HasTrait方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.HasTrait方法的具体用法?C# Actor.HasTrait怎么用?C# Actor.HasTrait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Actor
的用法示例。
在下文中一共展示了Actor.HasTrait方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Damaged
public void Damaged(Actor self, AttackInfo e)
{
// only track last hit against our base
if (!self.HasTrait<Building>())
return;
if (e.Attacker == null)
return;
if (e.Attacker.Owner == self.Owner)
return;
if (e.Attacker == self.World.WorldActor)
return;
if (e.Attacker.Owner.IsAlliedWith(self.Owner) && e.Damage <= 0)
return;
if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25)
{
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Country.Race);
if (radarPings != null)
radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
}
lastAttackTime = self.World.WorldTick;
}
示例2: TargetableBy
public virtual bool TargetableBy(Actor self, Actor viewer)
{
if (cloak == null || (!viewer.IsDead && viewer.HasTrait<IgnoresCloak>()))
return true;
return cloak.IsVisible(self, viewer.Owner);
}
示例3: Damaged
public void Damaged(Actor self, AttackInfo e)
{
if (!Active) return;
if (!self.HasTrait<AttackBase>()) return;
ReturnFire(self, e, false, false, true); // only triggers when standing still
}
示例4: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled || limitedAmmo == null) return NextActivity;
if (--remainingTicks == 0)
{
var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
.FirstOrDefault(a => a.HasTrait<RenderBuilding>());
if (!limitedAmmo.GiveAmmo())
{
var helicopter = self.TraitOrDefault<Helicopter>();
if (helicopter != null)
{
if (helicopter.Info.RepairBuildings.Contains(hostBuilding.Info.Name) && self.HasTrait<Health>())
{
if (self.Trait<Health>().DamageState != DamageState.Undamaged)
return NextActivity;
}
return helicopter.TakeOff(hostBuilding);
}
return NextActivity;
}
if (hostBuilding != null)
hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");
remainingTicks = limitedAmmo.ReloadTimePerAmmo();
}
return this;
}
示例5: Tick
public override Activity Tick(Actor self)
{
Sound.Play("chrono2.aud", self.Location.ToPPos());
Sound.Play("chrono2.aud", destination.ToPPos());
self.Trait<ITeleportable>().SetPosition(self, destination);
if (killCargo && self.HasTrait<Cargo>())
{
var cargo = self.Trait<Cargo>();
while (!cargo.IsEmpty(self))
{
if (chronosphere != null)
chronosphere.Owner.Kills++;
var a = cargo.Unload(self);
a.Owner.Deaths++;
}
}
// Trigger screen desaturate effect
foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
a.Trait.Enable();
if (chronosphere != null && !chronosphere.Destroyed && chronosphere.HasTrait<RenderBuilding>())
chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
return NextActivity;
}
示例6: AmbientSound
public AmbientSound(Actor self, AmbientSoundInfo info)
{
if (self.HasTrait<IOccupySpace>())
Sound.PlayLooped(info.SoundFile, self.CenterPosition);
else
Sound.PlayLooped(info.SoundFile);
}
示例7: Tick
public override Activity Tick(Actor self)
{
if (IsCanceled) return NextActivity;
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
if( !target.OccupiesSpace.OccupiedCells().Any( x => x.First == self.Location ) )
return NextActivity;
foreach (var t in target.TraitsImplementing<IAcceptSpy>())
t.OnInfiltrate(target, self);
if (self.HasTrait<DontDestroyWhenInfiltrating>())
self.World.AddFrameEndTask(w =>
{
if (self.Destroyed) return;
w.Remove(self);
});
else
self.Destroy();
if (target.HasTrait<Building>())
Sound.PlayToPlayer(self.Owner, "bldginf1.aud");
return this;
}
示例8: Tick
public override Activity Tick(Actor self)
{
Sound.Play(sound, self.CenterPosition);
Sound.Play(sound, destination.CenterPosition);
self.Trait<IPositionable>().SetPosition(self, destination);
self.Generation++;
if (killCargo && self.HasTrait<Cargo>())
{
var cargo = self.Trait<Cargo>();
while (!cargo.IsEmpty(self))
{
if (chronosphere != null && chronosphere.HasTrait<UpdatesPlayerStatistics>())
chronosphere.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsKilled++;
var a = cargo.Unload(self);
if (a.HasTrait<UpdatesPlayerStatistics>())
a.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsDead++;
}
}
// Trigger screen desaturate effect
foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
a.Trait.Enable();
if (chronosphere != null && !chronosphere.Destroyed && chronosphere.HasTrait<RenderBuilding>())
chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
return NextActivity;
}
示例9: IssueOrder
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (underCursor != null && underCursor.HasTrait<RenderInfantry>())
return new Order("Disguise", self, underCursor);
return null;
}
示例10: OnActivate
protected override void OnActivate(Actor self)
{
if (!self.HasTrait<AttackBase>()) return;
if (self.Trait<AttackBase>().IsAttacking)
StopAttack(self);
}
示例11: QueueAttack
protected override void QueueAttack( Actor self, Order order )
{
if (self.HasTrait<Building>() && self.Trait<Building>().Disabled)
return;
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
/* todo: choose the appropriate weapon, when only one works against this target */
var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
if (weapon == null)
return;
target = Target.FromOrder(order);
if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
self.QueueActivity( new Follow( target,
Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
}
示例12: RenderGunboat
public RenderGunboat(Actor self)
: base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0)
{
facing = self.Trait<IFacing>();
anim.Play("left");
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
}
示例13: Damaged
public void Damaged(Actor self, AttackInfo e)
{
if (!Active) return;
if (TargetType == ETargetType.None) return;
if (IsReturning) return;
if (!self.HasTrait<AttackBase>()) return;
ReturnFire(self, e, false); // only triggers when standing still
}
示例14: RenderUnit
public RenderUnit(Actor self)
: base(self, () => self.HasTrait<IFacing>() ? self.Trait<IFacing>().Facing : 0)
{
canSmoke = self.Info.Traits.Get<RenderUnitInfo>().Smokes;
anim.Play("idle");
if (canSmoke)
anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
}
示例15: AppearsHostileTo
public static bool AppearsHostileTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[self.Owner];
if (stance == Stance.Ally)
return false; /* otherwise, we'll hate friendly disguised spies */
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.HasTrait<IgnoresDisguise>())
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Enemy;
return stance == Stance.Enemy;
}