public Contrail(Actor self, ContrailInfo info) { this.info = info; color = info.UsePlayerColor ? ContrailRenderable.ChooseColor(self) : info.Color; trail = new ContrailRenderable(self.World, color, info.TrailWidth, info.TrailLength, 0, info.ZOffset); body = self.Trait <BodyOrientation>(); }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; hFacing = args.Facing; gravity = new WVec(0, 0, -info.Gravity); targetPosition = args.PassiveTarget; rangeLimit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range; minLaunchSpeed = info.MinimumLaunchSpeed.Length > -1 ? info.MinimumLaunchSpeed.Length : info.Speed.Length; maxLaunchSpeed = info.MaximumLaunchSpeed.Length > -1 ? info.MaximumLaunchSpeed.Length : info.Speed.Length; maxSpeed = info.Speed.Length; minLaunchAngle = info.MinimumLaunchAngle; maxLaunchAngle = info.MaximumLaunchAngle; var world = args.SourceActor.World; if (world.SharedRandom.Next(100) <= info.LockOnProbability) { lockOn = true; } var inaccuracy = lockOn && info.LockOnInaccuracy.Length > -1 ? info.LockOnInaccuracy.Length : info.Inaccuracy.Length; if (inaccuracy > 0) { inaccuracy = Util.ApplyPercentageModifiers(inaccuracy, args.InaccuracyModifiers); offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024; } DetermineLaunchSpeedAndAngle(world, out speed, out vFacing); velocity = new WVec(0, -speed, 0) .Rotate(new WRot(WAngle.FromFacing(vFacing), WAngle.Zero, WAngle.Zero)) .Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(hFacing))); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, () => renderFacing); anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; hFacing = args.Facing; targetPosition = args.PassiveTarget; var world = args.SourceActor.World; if (info.Inaccuracy.Length > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024; } DetermineLaunchSpeedAndAngle(world, out speed, out vFacing); velocity = new WVec(0, -speed, 0) .Rotate(new WRot(WAngle.FromFacing(vFacing), WAngle.Zero, WAngle.Zero)) .Rotate(new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(hFacing))); if (world.SharedRandom.Next(100) <= info.LockOnProbability) { lockOn = true; } if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, () => renderFacing); anim.PlayRepeating(info.Sequence); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } }
public Bullet(BulletInfo info, ProjectileArgs args) { this.info = info; this.args = args; this.pos = args.Source; var world = args.SourceActor.World; if (info.Angle.Length > 1 && info.Speed.Length > 1) { angle = new WAngle(world.SharedRandom.Next(info.Angle[0].Angle, info.Angle[1].Angle)); speed = new WRange(world.SharedRandom.Next(info.Speed[0].Range, info.Speed[1].Range)); } else { angle = info.Angle[0]; speed = info.Speed[0]; } target = args.PassiveTarget; if (info.Inaccuracy.Range > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers); var maxOffset = inaccuracy * (target - pos).Length / args.Weapon.Range.Range; target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024; } facing = OpenRA.Traits.Util.GetFacing(target - pos, 0); length = Math.Max((target - pos).Length / speed.Range, 1); if (info.Image != null) { anim = new Animation(world, info.Image, GetEffectiveFacing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; trail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0); } smokeTicks = info.TrailDelay; }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; var world = args.SourceActor.World; if (world.SharedRandom.Next(100) <= info.LockOnProbability) { lockOn = true; } if (info.Inaccuracy.Length > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers); offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024; } if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, () => facing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } }
public Bullet(BulletInfo info, ProjectileArgs args) { this.info = info; this.args = args; this.pos = args.Source; // Convert ProjectileArg definitions to world coordinates // TODO: Change the yaml definitions so we don't need this var range = new WRange((int)(1024 * args.Weapon.Range)); // Range in world units var inaccuracy = new WRange((int)(info.Inaccuracy * 1024 / Game.CellSize)); // Offset in world units at max range var speed = (int)(info.Speed * 4 * 1024 / (10 * Game.CellSize)); // Speed in world units per tick angle = WAngle.ArcTan((int)(info.Angle * 4 * 1024), 1024); // Angle in world angle target = args.PassiveTarget; if (info.Inaccuracy > 0) { var maxOffset = inaccuracy.Range * (target - pos).Length / range.Range; target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024; } facing = Traits.Util.GetFacing(target - pos, 0); length = Math.Max((target - pos).Length / speed, 1); if (info.Image != null) { anim = new Animation(info.Image, GetEffectiveFacing); anim.PlayRepeating("idle"); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0); } smokeTicks = info.TrailDelay; }
public BulletCA(BulletCAInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; source = args.Source; var world = args.SourceActor.World; if (info.LaunchAngle.Length > 1) { angle = new WAngle(world.SharedRandom.Next(info.LaunchAngle[0].Angle, info.LaunchAngle[1].Angle)); } else { angle = info.LaunchAngle[0]; } if (info.Speed.Length > 1) { speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length)); } else { speed = info.Speed[0]; } target = args.PassiveTarget; if (info.Inaccuracy.Length > 0) { var maxInaccuracyOffset = Common.Util.GetProjectileInaccuracy(info.Inaccuracy.Length, info.InaccuracyType, args); target += WVec.FromPDF(world.SharedRandom, 2) * maxInaccuracyOffset / 1024; } if (info.AirburstAltitude > WDist.Zero) { target += new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude); } facing = (target - pos).Yaw; length = Math.Max((target - pos).Length / speed.Length, 1); if (!string.IsNullOrEmpty(info.Image)) { anim = new Animation(world, info.Image, new Func <WAngle>(GetEffectiveFacing)); anim.PlayRepeating(info.Sequences.Random(world.SharedRandom)); } if (info.ContrailLength > 0) { var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor; contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset); } trailPalette = info.TrailPalette; if (info.TrailUsePlayerPalette) { trailPalette += args.SourceActor.Owner.InternalName; } smokeTicks = info.TrailDelay; remainingBounces = info.BounceCount; }