GetImage() public method

public GetImage ( Actor self ) : string
self Actor
return string
Beispiel #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);
            }
        }
 public void SpawnDeathAnimation(Actor self, string sequence, string palette)
 {
     self.World.AddFrameEndTask(w =>
     {
         if (!self.Disposed)
         {
             w.Add(new Corpse(w, self.CenterPosition, rs.GetImage(self), sequence, palette));
         }
     });
 }
Beispiel #3
0
        public void Killed(Actor self, AttackInfo e)
        {
            // Actors with Crushable trait will spawn CrushedSequence.
            if (crushed)
            {
                return;
            }

            var palette = Info.DeathSequencePalette;

            if (Info.DeathPaletteIsPlayerPalette)
            {
                palette += self.Owner.InternalName;
            }

            // Killed by some non-standard means
            if (e.Warhead == null || !(e.Warhead is DamageWarhead))
            {
                if (Info.FallbackSequence != null)
                {
                    SpawnDeathAnimation(self, self.CenterPosition, rs.GetImage(self), Info.FallbackSequence, palette);
                }

                return;
            }

            var sequence = Info.DeathSequence;

            if (Info.UseDeathTypeSuffix)
            {
                var warhead    = e.Warhead as DamageWarhead;
                var damageType = Info.DeathTypes.Keys.FirstOrDefault(warhead.DamageTypes.Contains);
                if (damageType == null)
                {
                    return;
                }

                sequence += Info.DeathTypes[damageType];
            }

            SpawnDeathAnimation(self, self.CenterPosition, rs.GetImage(self), sequence, palette);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
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;
		}
Beispiel #7
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;
        }
Beispiel #8
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;
        }