Add() public method

public Add ( AnimationWithOffset anim, string palette = null, bool isPlayerPalette = false ) : void
anim OpenRA.Graphics.AnimationWithOffset
palette string
isPlayerPalette bool
return void
Exemplo n.º 1
0
        public void AddedToWorld(Actor self)
        {
            var width        = bi.Dimensions.X;
            var bibOffset    = bi.Dimensions.Y - 1;
            var centerOffset = FootprintUtils.CenterOffset(self.World, bi);
            var location     = self.Location;
            var rows         = info.HasMinibib ? 1 : 2;
            var map          = self.World.Map;

            for (var i = 0; i < rows * width; i++)
            {
                var index      = i;
                var anim       = new Animation(self.World, rs.GetImage(self));
                var cellOffset = new CVec(i % width, i / width + bibOffset);
                var cell       = location + cellOffset;

                // Some mods may define terrain-specific bibs
                var terrain      = map.GetTerrainInfo(cell).Type;
                var testSequence = info.Sequence + "-" + terrain;
                var sequence     = anim.HasSequence(testSequence) ? testSequence : info.Sequence;
                anim.PlayFetchIndex(sequence, () => index);
                anim.IsDecoration = true;

                // Z-order is one set to the top of the footprint
                var offset = self.World.Map.CenterOfCell(cell) - self.World.Map.CenterOfCell(location) - centerOffset;
                var awo    = new AnimationWithOffset(anim, () => offset, null, -(offset.Y + centerOffset.Y + 512));
                anims.Add(awo);
                rs.Add(awo, info.Palette);
            }
        }
Exemplo n.º 2
0
        public WithChargeOverlay(ActorInitializer init, WithChargeOverlayInfo info)
        {
            this.info = info;

            renderSprites = init.Self.Trait <RenderSprites>();

            overlay = new Animation(init.World, renderSprites.GetImage(init.Self));

            renderSprites.Add(new AnimationWithOffset(overlay, null, () => !charging),
                              info.Palette, info.IsPlayerPalette);
        }
Exemplo n.º 3
0
        public WithResources(Actor self, WithResourcesInfo info)
        {
            this.info       = info;
            rs              = self.Trait <RenderSprites>();
            wsb             = self.Trait <WithSpriteBody>();
            playerResources = self.Owner.PlayerActor.Trait <PlayerResources>();

            var a = new Animation(self.World, rs.GetImage(self));

            a.PlayFetchIndex(info.Sequence, () =>
                             playerResources.ResourceCapacity != 0 ?
                             ((10 * a.CurrentSequence.Length - 1) * playerResources.Resources) / (10 * playerResources.ResourceCapacity) :
                             0);

            anim = new AnimationWithOffset(a, null, () => !buildComplete, 1024);
            rs.Add(anim);
        }
Exemplo n.º 4
0
		public WithTurret(Actor self, WithTurretInfo info)
			: base(info)
		{
			rs = self.Trait<RenderSprites>();
			body = self.Trait<BodyOrientation>();
			Attack = self.TraitOrDefault<AttackBase>();
			t = self.TraitsImplementing<Turreted>()
				.First(tt => tt.Name == info.Turret);
			arms = self.TraitsImplementing<Armament>()
				.Where(w => w.Info.Turret == info.Turret).ToArray();

			DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing);
			DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence));
			rs.Add(new AnimationWithOffset(
				DefaultAnimation, () => TurretOffset(self), () => IsTraitDisabled, () => false, p => ZOffsetFromCenter(self, p, 1)));

			// Restrict turret facings to match the sprite
			t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
		}
Exemplo n.º 5
0
        public WithBarrel(Actor self, WithBarrelInfo info)
            : base(info)
        {
            this.self = self;
            body      = self.Trait <BodyOrientation>();
            armament  = self.TraitsImplementing <Armament>()
                        .First(a => a.Info.Name == Info.Armament);
            turreted = self.TraitsImplementing <Turreted>()
                       .First(tt => tt.Name == armament.Info.Turret);

            rs = self.Trait <RenderSprites>();
            DefaultAnimation = new Animation(self.World, rs.GetImage(self), () => turreted.TurretFacing);
            DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence));
            rs.Add(new AnimationWithOffset(
                       DefaultAnimation, () => BarrelOffset(), () => IsTraitDisabled, () => false, p => WithTurret.ZOffsetFromCenter(self, p, 0)));

            // Restrict turret facings to match the sprite
            turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
        }
Exemplo n.º 6
0
        public WithTurret(Actor self, WithTurretInfo info)
            : base(info)
        {
            rs   = self.Trait <RenderSprites>();
            body = self.Trait <IBodyOrientation>();

            ab = self.TraitOrDefault <AttackBase>();
            t  = self.TraitsImplementing <Turreted>()
                 .First(tt => tt.Name == info.Turret);
            arms = self.TraitsImplementing <Armament>()
                   .Where(w => w.Info.Turret == info.Turret);

            anim = new Animation(self.World, rs.GetImage(self), () => t.TurretFacing);
            anim.Play(info.Sequence);
            rs.Add("turret_{0}_{1}".F(info.Turret, info.Sequence), new AnimationWithOffset(
                       anim, () => TurretOffset(self), () => IsTraitDisabled, () => false, p => ZOffsetFromCenter(self, p, 1)));

            // Restrict turret facings to match the sprite
            t.QuantizedFacings = anim.CurrentSequence.Facings;
        }