public Bullet(BulletInfo info, ProjectileArgs args) { Info = info; Args = args; if (info.Inaccuracy > 0) { var factor = ((Args.dest - Args.src).ToCVec().Length) / args.weapon.Range; Args.dest += (PVecInt) (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); Log.Write("debug", "Bullet with Inaccuracy; factor: #{0}; Projectile dest: {1}", factor, Args.dest); } if (Info.Image != null) { anim = new Animation(Info.Image, GetEffectiveFacing); anim.PlayRepeating("idle"); } if (Info.ContrailLength > 0) { Trail = new ContrailHistory(Info.ContrailLength, Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, Info.ContrailDelay); } }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; // Convert ProjectileArg definitions to world coordinates // TODO: Change the yaml definitions so we don't need this var inaccuracy = (int)(info.Inaccuracy * 1024 / Game.CellSize); speed = info.Speed * 1024 / (5 * Game.CellSize); if (info.Inaccuracy > 0) offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * inaccuracy / 1024; if (info.Image != null) { anim = new Animation(info.Image, () => facing); 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); } }
public GpsSatellite(World world, WPos pos) { this.pos = pos; anim = new Animation(world, "sputnik"); anim.PlayRepeating("idle"); }
public static string NormalizeSequence(Animation anim, DamageState state, string sequence) { var states = new Pair<DamageState, string>[] { Pair.New(DamageState.Critical, "critical-"), Pair.New(DamageState.Heavy, "damaged-"), Pair.New(DamageState.Medium, "scratched-"), Pair.New(DamageState.Light, "scuffed-") }; // Remove existing damage prefix foreach (var s in states) { if (sequence.StartsWith(s.Second)) { sequence = sequence.Substring(s.Second.Length); break; } } foreach (var s in states) if (state >= s.First && anim.HasSequence(s.Second + sequence)) return s.Second + sequence; return sequence; }
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, Func<WPos, int> zOffset) { Animation = a; OffsetFunc = offset; DisableFunc = disable; ZOffset = zOffset; }
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.Range > 0) { var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers); offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024; } if (info.Image != null) { anim = new Animation(world, info.Image, () => facing); 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); } }
public WithFire(Actor self) { var rs = self.Trait<RenderSimple>(); var roof = new Animation(rs.GetImage(self)); roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop")); rs.anims.Add( "fire", new RenderSimple.AnimationWithOffset( roof, () => new float2(7,-15), null ) { ZOffset = 24 } ); }
public Explosion(World world, int2 pixelPos, string style, bool isWater) { this.pos = pixelPos; anim = new Animation("explosion"); anim.PlayThen(style, () => world.AddFrameEndTask(w => w.Remove(this))); }
public IonCannon(Actor firedBy, World world, CPos location) { this.firedBy = firedBy; target = Target.FromCell(location); anim = new Animation("ionsfx"); anim.PlayThen("idle", () => Finish(world)); }
public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType) { this.firedBy = firedBy; this.weapon = weapon; this.delay = delay; this.turn = delay / 2; this.flashType = flashType; var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn); ascendSource = launchPos; ascendTarget = launchPos + offset; descendSource = targetPos + offset; descendTarget = targetPos; anim = new Animation(firedBy.World, weapon); anim.PlayRepeating("up"); pos = launchPos; var weaponRules = firedBy.World.Map.Rules.Weapons[weapon.ToLowerInvariant()]; if (weaponRules.Report != null && weaponRules.Report.Any()) Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos); if (skipAscent) ticks = turn; }
public AnimationWithOffset(Animation a, Func<WVec> offset, Func<bool> disable, Func<WPos, int> zOffset) { this.Animation = a; this.OffsetFunc = offset; this.DisableFunc = disable; this.ZOffset = zOffset; }
public WithRoof(Actor self) { var rs = self.Trait<RenderSimple>(); var roof = new Animation(rs.GetImage(self), () => self.Trait<IFacing>().Facing); roof.Play("roof"); rs.anims.Add( "roof", new RenderSimple.AnimationWithOffset( roof ) { ZOffset = 24 } ); }
public override void Initialize(WidgetArgs args) { base.Initialize(args); icon = new Animation(world, "icon"); clock = new Animation(world, "clock"); }
public SpriteEffect(WPos pos, World world, string sprite, string palette) { this.pos = pos; this.palette = palette; anim = new Animation(world, sprite); anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this))); }
public RenderUnitTurreted(Actor self) : base(self) { var facing = self.Trait<IFacing>(); var turreted = self.Trait<Turreted>(); var attack = self.TraitOrDefault<AttackBase>(); var attackInfo = self.Info.Traits.Get<AttackBaseInfo>(); var turretAnim = new Animation(GetImage(self), () => turreted.turretFacing ); turretAnim.Play( "turret" ); for( var i = 0; i < attack.Turrets.Count; i++ ) { var turret = attack.Turrets[i]; anims.Add( "turret_{0}".F(i), new AnimationWithOffset( turretAnim, () => Combat.GetTurretPosition( self, facing, turret ), null)); if (attackInfo.MuzzleFlash) { var muzzleFlash = new Animation(GetImage(self), () => turreted.turretFacing); muzzleFlash.PlayFetchIndex("muzzle", () => (int)(turret.Recoil * 5.9f)); /* hack: dumb crap */ anims.Add("muzzle_flash_{0}".F(i), new AnimationWithOffset(muzzleFlash, () => Combat.GetTurretPosition(self, facing, turret), () => turret.Recoil <= 0)); } } }
public Missile(MissileInfo info, ProjectileArgs args) { Info = info; Args = args; SubPxPosition = 1024 * Args.src; Altitude = Args.srcAltitude; Facing = Args.facing; if (info.Inaccuracy > 0) offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2(); if (Info.Image != null) { anim = new Animation(Info.Image, () => Facing); anim.PlayRepeating("idle"); } if (Info.ContrailLength > 0) { Trail = new ContrailHistory(Info.ContrailLength, Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor, Info.ContrailDelay); } }
public ObserverSupportPowerIconsWidget(World world, WorldRenderer worldRenderer) { this.world = world; this.worldRenderer = worldRenderer; clocks = new Dictionary<string, Animation>(); icon = new Animation(world, "icon"); }
public Parachute(Actor cargo, WPos dropPosition) { this.cargo = cargo; parachutableInfo = cargo.Info.Traits.GetOrDefault<ParachutableInfo>(); if (parachutableInfo != null) fallVector = new WVec(0, 0, parachutableInfo.FallRate); var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null; if (parachuteSprite != null) { parachute = new Animation(cargo.World, parachuteSprite); parachute.PlayThen("open", () => parachute.PlayRepeating("idle")); } var shadowSprite = parachutableInfo != null ? parachutableInfo.ShadowSequence : null; if (shadowSprite != null) { shadow = new Animation(cargo.World, shadowSprite); shadow.PlayRepeating("idle"); } if (parachutableInfo != null) parachuteOffset = parachutableInfo.ParachuteOffset; // Adjust x,y to match the target subcell cargo.Trait<IPositionable>().SetPosition(cargo, cargo.World.Map.CellContaining(dropPosition)); var cp = cargo.CenterPosition; pos = new WPos(cp.X, cp.Y, dropPosition.Z); }
public ProductionPaletteWidget([ObjectCreator.Param] World world, [ObjectCreator.Param] WorldRenderer worldRenderer) { this.world = world; this.worldRenderer = worldRenderer; tooltipContainer = new Lazy<TooltipContainerWidget>(() => Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer)); cantBuild = new Animation("clock"); cantBuild.PlayFetchIndex("idle", () => 0); clock = new Animation("clock"); iconSprites = Rules.Info.Values .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^') .ToDictionary( u => u.Name, u => Game.modData.SpriteLoader.LoadAllSprites( u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]); overlayFont = Game.Renderer.Fonts["TinyBold"]; holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2; readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2; timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; queuedOffset = new float2(4,2); }
public PowerdownIndicator(Actor a) { this.a = a; anim = new Animation(a.World, "poweroff"); anim.PlayRepeating("offline"); }
public Smoke(World world, PPos pos, string trail) { this.pos = pos; anim = new Animation(trail); anim.PlayThen("idle", () => world.AddFrameEndTask(w => w.Remove(this))); }
public Corpse(World world, float2 pos, string image, string sequence, string paletteName) { this.pos = pos; this.paletteName = paletteName; anim = new Animation(image); anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); }
public Missile(MissileInfo info, ProjectileArgs args) { this.info = info; this.args = args; pos = args.Source; facing = args.Facing; targetPosition = args.PassiveTarget; if (info.Inaccuracy.Range > 0) offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * info.Inaccuracy.Range / 1024; if (info.Image != null) { anim = new Animation(args.SourceActor.World, info.Image, () => facing); 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); } }
public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType) { this.firedBy = firedBy; this.weapon = weapon; this.weaponPalette = weaponPalette; this.downSequence = downSequence; this.delay = delay; turn = delay / 2; this.flashType = flashType; var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn); ascendSource = launchPos; ascendTarget = launchPos + offset; descendSource = targetPos + offset; descendTarget = targetPos; anim = new Animation(firedBy.World, name); anim.PlayRepeating(upSequence); pos = launchPos; if (weapon.Report != null && weapon.Report.Any()) Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), pos); if (skipAscent) ticks = turn; }
public IonCannon(Actor firedBy, World world, int2 location) { this.firedBy = firedBy; Target = location; anim = new Animation("ionsfx"); anim.PlayThen("idle", () => Finish(world)); }
public SpriteActorPreview(Animation animation, WVec offset, int zOffset, PaletteReference pr, float scale) { this.animation = animation; this.offset = offset; this.zOffset = zOffset; this.pr = pr; this.scale = scale; }
public CrateEffect(Actor a, string seq, string palette) { this.a = a; this.palette = palette; anim = new Animation(a.World, "crate-effects"); anim.PlayThen(seq, () => a.World.AddFrameEndTask(w => w.Remove(this))); }
public Explosion(World world, WPos pos, string image, string sequence, string palette) { this.world = world; this.pos = pos; this.palette = palette; anim = new Animation(world, image); anim.PlayThen(sequence, () => world.AddFrameEndTask(w => w.Remove(this))); }
public Explosion(World world, WPos pos, string style) { this.world = world; this.pos = pos; this.cell = pos.ToCPos(); anim = new Animation("explosion"); anim.PlayThen(style, () => world.AddFrameEndTask(w => w.Remove(this))); }
public RenderBuildingWarFactory(ActorInitializer init, RenderBuildingInfo info) : base(init, info) { roof = new Animation(GetImage(init.self)); var offset = new AnimationWithOffset( roof ) { ZOffset = 24 }; offset.DisableFunc = () => !buildComplete; anims.Add("roof", offset); }
public AnimationWithOffset(Animation a, Func <float2> o, Func <bool> d) { this.Animation = a; this.OffsetFunc = o; this.DisableFunc = d; }
public AnimationWithOffset(Animation a, Func <WVec> offset, Func <bool> disable, int zOffset) : this(a, offset, disable, _ => zOffset) { }
public AnimationWithOffset(Animation a, Func <WVec> offset, Func <bool> disable) : this(a, offset, disable, null) { }
public AnimationWithOffset(Animation a) : this(a, null, null) { }