public void Activate(Actor attachable) { IsValid = false; var target = Target.FromPos(attachable.CenterPosition); attachable.World.AddFrameEndTask(w => weaponInfo.Impact(target, AttachedBy, Enumerable.Empty <int>())); }
void Explode(World world, bool removeProjectile) { if (removeProjectile) { world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); }); } if (detonated) { return; } weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty <int>()); world.WorldActor.Trait <ScreenShaker>().AddEffect(20, pos, 5); foreach (var flash in world.WorldActor.TraitsImplementing <FlashPaletteEffect>()) { if (flash.Info.Type == flashType) { flash.Enable(-1); } } detonated = true; }
void Explode(World world, bool removeProjectile) { if (removeProjectile) { world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); }); } if (detonated) { return; } var target = Target.FromPos(pos); var warheadArgs = new WarheadArgs { Weapon = weapon, Source = target.CenterPosition, SourceActor = firedBy.PlayerActor, WeaponTarget = target }; weapon.Impact(target, warheadArgs); foreach (var flash in world.WorldActor.TraitsImplementing <FlashPaletteEffect>()) { if (flash.Info.Type == flashType) { flash.Enable(-1); } } detonated = true; }
void Explode(World world, bool removeProjectile) { if (removeProjectile) { world.AddFrameEndTask(w => { w.Remove(this); w.ScreenMap.Remove(this); }); } if (detonated) { return; } var target = Target.FromPos(pos); var warheadArgs = new WarheadArgs { Weapon = weapon, Source = target.CenterPosition, SourceActor = firedBy.PlayerActor, WeaponTarget = target }; weapon.Impact(target, warheadArgs); detonated = true; }
void ITick.Tick(Actor self) { if (IsTraitDisabled) { return; } if (--fireDelay < 0) { var localoffset = body != null ? body.LocalToWorld(info.LocalOffset.Rotate(body.QuantizeOrientation(self, self.Orientation))) : info.LocalOffset; if (weapon.Report != null && weapon.Report.Any()) { Game.Sound.Play(weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } weapon.Impact(Target.FromPos(self.CenterPosition + localoffset), self, self.TraitsImplementing <IFirepowerModifier>().Select(a => a.GetFirepowerModifier()).ToArray()); if (--burst > 0) { fireDelay = weapon.BurstDelay; } else { var modifiers = self.TraitsImplementing <IReloadModifier>() .Select(m => m.GetReloadModifier()); fireDelay = Util.ApplyPercentageModifiers(weapon.ReloadDelay, modifiers); burst = weapon.Burst; } } }
public void Activate(Actor attachable) { IsValid = false; var target = Target.FromPos(attachable.CenterPosition); attachable.World.AddFrameEndTask(w => weaponInfo.Impact(target, args)); }
public void Tick(World world) { anim.Tick(); if (!impacted && weaponDelay-- <= 0) { weapon.Impact(target, firedBy.PlayerActor, Enumerable.Empty <int>()); impacted = true; } }
public void Tick(Actor self) { if (health.HP <= damageThreshold || --damageTicks > 0) { return; } weapon.Impact(Target.FromActor(self), self.World.WorldActor, Enumerable.Empty <int>()); damageTicks = weapon.ReloadDelay; }
void Explode(World world) { world.AddFrameEndTask(w => w.Remove(this)); weapon.Impact(Target.FromPos(pos), firedBy.PlayerActor, Enumerable.Empty <int>()); world.WorldActor.Trait <ScreenShaker>().AddEffect(20, pos, 5); foreach (var flash in world.WorldActor.TraitsImplementing <FlashPaletteEffect>()) { if (flash.Info.Type == flashType) { flash.Enable(-1); } } }
public void Tick(World world) { entryAnimation.Tick(); if (!impacted && weaponDelay-- <= 0) { var warheadArgs = new WarheadArgs { Weapon = weapon, Source = target.CenterPosition, SourceActor = firedBy.PlayerActor, WeaponTarget = target }; weapon.Impact(target, warheadArgs); impacted = true; } }
void ITick.Tick(Actor self) { for (var i = 0; i < delayedActions.Count; i++) { var x = delayedActions[i]; if (--x.First <= 0) { x.Second(); } delayedActions[i] = x; } delayedActions.RemoveAll(a => a.First <= 0); if (IsTraitDisabled) { return; } if (--fireDelay < 0) { if (ammoPool != null && !ammoPool.TakeAmmo(self, 1)) { return; } var localoffset = body != null ? body.LocalToWorld(info.LocalOffset.Rotate(body.QuantizeOrientation(self, self.Orientation))) : info.LocalOffset; weapon.Impact(Target.FromPos(self.CenterPosition + localoffset), self, self.TraitsImplementing <IFirepowerModifier>().Select(a => a.GetFirepowerModifier()).ToArray()); if (weapon.Report != null && weapon.Report.Any()) { Game.Sound.Play(SoundType.World, weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } if (burst == weapon.Burst && weapon.StartBurstReport != null && weapon.StartBurstReport.Any()) { Game.Sound.Play(SoundType.World, weapon.StartBurstReport.Random(self.World.SharedRandom), self.CenterPosition); } if (--burst > 0) { if (weapon.BurstDelays.Length == 1) { fireDelay = weapon.BurstDelays[0]; } else { fireDelay = weapon.BurstDelays[weapon.Burst - (burst + 1)]; } } else { var modifiers = self.TraitsImplementing <IReloadModifier>() .Select(m => m.GetReloadModifier()); fireDelay = Util.ApplyPercentageModifiers(weapon.ReloadDelay, modifiers); burst = weapon.Burst; if (weapon.AfterFireSound != null && weapon.AfterFireSound.Any()) { ScheduleDelayedAction(weapon.AfterFireSoundDelay, () => Game.Sound.Play(SoundType.World, weapon.AfterFireSound.Random(self.World.SharedRandom), self.CenterPosition)); } } } }
public override void Activate(Actor self, Order order, SupportPowerManager manager) { base.Activate(self, order, manager); self.World.AddFrameEndTask(w => { WPos targetPos = order.Target.CenterPosition; PlayLaunchSounds(); if (!string.IsNullOrEmpty(info.EnvironmentEffectType)) { EnvironmentPaletteEffect environmentEffect = null; var effetcs = w.WorldActor.TraitsImplementing <EnvironmentPaletteEffect>(); foreach (var effect in effetcs) { if (effect.Info.Type == info.EnvironmentEffectType) { environmentEffect = effect; break; } } if (environmentEffect != null) { environmentEffect.Enable(-1); } } for (int i = 0; i < info.WeaponInfos.Count; i++) { WeaponInfo weaponInfo = info.WeaponInfos[i].Weapon; if (weaponInfo.Report != null && weaponInfo.Report.Any()) { Game.Sound.Play(SoundType.World, weaponInfo.Report.Random(self.World.SharedRandom), order.Target.CenterPosition); } //Boooooom...... WVec offset = new WVec( info.WeaponInfos[i].OffsetX, info.WeaponInfos[i].OffsetY, info.WeaponInfos[i].OffsetZ ); WPos newPos = targetPos + offset; weaponInfo.Impact(Target.FromPos(newPos), self, Enumerable.Empty <int>()); var victimActors = w.FindActorsInCircle(targetPos, weaponInfo.Range); foreach (Actor actor in victimActors) { foreach (IWarhead warhead in weaponInfo.Warheads) { if (warhead is SpreadDamageWarhead) { actor.InflictDamage(self, new Damage(((SpreadDamageWarhead)warhead).Damage)); } } } } if (info.ChangeOwner) { var aliveActors = w.FindActorsInCircle(targetPos, WDist.FromCells(info.ChangeRange)); foreach (Actor aliveActor in aliveActors) { try { TargetableInfo ti = aliveActor.Info.TraitInfo <TargetableInfo>(); if (ti == null) { continue; } foreach (var tti in ti.GetTargetTypes()) { if (info.ChangeTargets.Contains(tti) && aliveActor.Owner.Stances[self.Owner] == Stance.Enemy) { aliveActor.ChangeOwner(self.Owner); break; } } } catch { continue; } } } }); }
void ITick.Tick(Actor self) { for (var i = 0; i < delayedActions.Count; i++) { var x = delayedActions[i]; if (--x.First <= 0) { x.Second(); } delayedActions[i] = x; } delayedActions.RemoveAll(a => a.First <= 0); if (IsTraitDisabled) { return; } if (--fireDelay + Info.InitialDelay < 0) { if (ammoPool != null && !ammoPool.TakeAmmo(self, 1)) { return; } var localoffset = body != null ? body.LocalToWorld(info.LocalOffset.Rotate(body.QuantizeOrientation(self, self.Orientation))) : info.LocalOffset; var args = new WarheadArgs { Weapon = weapon, DamageModifiers = self.TraitsImplementing <IFirepowerModifier>().Select(a => a.GetFirepowerModifier()).ToArray(), Source = self.CenterPosition, SourceActor = self, WeaponTarget = Target.FromPos(self.CenterPosition + localoffset) }; weapon.Impact(Target.FromPos(self.CenterPosition + localoffset), args); if (weapon.Report != null && weapon.Report.Any()) { Game.Sound.Play(SoundType.World, weapon.Report.Random(self.World.SharedRandom), self.CenterPosition); } if (burst == weapon.Burst && weapon.StartBurstReport != null && weapon.StartBurstReport.Any()) { Game.Sound.Play(SoundType.World, weapon.StartBurstReport.Random(self.World.SharedRandom), self.CenterPosition); } if (--burst > 0) { if (weapon.BurstDelays.Length == 1) { fireDelay = weapon.BurstDelays[0]; } else { fireDelay = weapon.BurstDelays[weapon.Burst - (burst + 1)]; } } else { // here the cost of all passengers and their passengers is calculated var summedCost = 0; foreach (var p in self.TraitOrDefault <Cargo>().Passengers) { summedCost += p.Info.TraitInfos <ValuedInfo>().First().Cost; if (p.TraitOrDefault <Cargo>() != null) { foreach (var p2 in p.TraitOrDefault <Cargo>().Passengers) { summedCost += p2.Info.TraitInfos <ValuedInfo>().First().Cost; } } } var modifiers = self.TraitsImplementing <IReloadModifier>() .Select(m => m.GetReloadModifier()); fireDelay = Util.ApplyPercentageModifiers(weapon.ReloadDelay, modifiers); burst = weapon.Burst; fireDelay *= summedCost / 200; // Here is the factor which determines how fast units are spawned, higher = faster //Game.Debug(String.Join("; ", fireDelay )); if (weapon.AfterFireSound != null && weapon.AfterFireSound.Any()) { ScheduleDelayedAction(weapon.AfterFireSoundDelay, () => { Game.Sound.Play(SoundType.World, weapon.AfterFireSound.Random(self.World.SharedRandom), self.CenterPosition); }); } } } }