GetImage() public method

public GetImage ( Actor self ) : string
self Actor
return string
Esempio n. 1
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);
        }
Esempio n. 2
0
        public WithAttackOverlay(ActorInitializer init, WithAttackOverlayInfo info)
        {
            this.info = info;

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

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

            renderSprites.Add(new AnimationWithOffset(overlay, null, () => !attacking),
                              info.Palette, info.IsPlayerPalette);
        }
Esempio n. 3
0
        void INotifyKilled.Killed(Actor self, AttackInfo e)
        {
            // Actors with Crushable trait will spawn CrushedSequence.
            if (crushed || IsTraitDisabled)
            {
                return;
            }

            var palette = Info.DeathSequencePalette;

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

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

                return;
            }

            var sequence = Info.DeathSequence;

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

                sequence += Info.DeathTypes[damageType].Random(self.World.SharedRandom);
            }

            SpawnDeathAnimation(self, self.CenterPosition, rs.GetImage(self), sequence, palette);
        }
Esempio n. 4
0
        protected WithSpriteBody(ActorInitializer init, WithSpriteBodyInfo info, Func <WAngle> baseFacing)
            : base(info)
        {
            rs = init.Self.Trait <RenderSprites>();

            Func <bool> paused = () => IsTraitPaused &&
                                 DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);

            Func <WVec> subtractDAT = null;

            if (info.ForceToGround)
            {
                subtractDAT = () => new WVec(0, 0, -init.Self.World.Map.DistanceAboveTerrain(init.Self.CenterPosition).Length);
            }

            DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
            rs.Add(new AnimationWithOffset(DefaultAnimation, subtractDAT, () => IsTraitDisabled));

            // Cache the bounds from the default sequence to avoid flickering when the animation changes
            boundsAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
            boundsAnimation.PlayRepeating(info.Sequence);
        }
        public WithChargeOverlay(Actor self, WithChargeOverlayInfo info)
        {
            this.info = info;
            rs        = self.Trait <RenderSprites>();
            wsb       = self.Trait <WithSpriteBody>();

            var attackCharges     = self.Trait <AttackCharges>();
            var attackChargesInfo = (AttackChargesInfo)attackCharges.Info;

            overlay = new Animation(self.World, rs.GetImage(self));
            overlay.PlayFetchIndex(wsb.NormalizeSequence(self, info.Sequence),
                                   () => int2.Lerp(0, overlay.CurrentSequence.Length, attackCharges.ChargeLevel, attackChargesInfo.ChargeLevel + 1));

            rs.Add(new AnimationWithOffset(overlay, null, () => !buildComplete, 1024),
                   info.Palette, info.IsPlayerPalette);
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public WithResourceLevelOverlay(Actor self, WithResourceLevelOverlayInfo info)
            : base(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, () => IsTraitDisabled, 1024);
            rs.Add(anim, info.Palette, info.IsPlayerPalette);
        }
Esempio n. 8
0
        public WithSpriteBarrel(Actor self, WithSpriteBarrelInfo 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), () => WAngle.FromFacing(turreted.TurretFacing));
            DefaultAnimation.PlayRepeating(NormalizeSequence(self, Info.Sequence));
            rs.Add(new AnimationWithOffset(
                       DefaultAnimation, () => BarrelOffset(), () => IsTraitDisabled, p => RenderUtils.ZOffsetFromCenter(self, p, 0)));

            // Restrict turret facings to match the sprite
            turreted.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
        }
Esempio n. 9
0
        public WithSpriteTurret(Actor self, WithSpriteTurretInfo info)
            : base(info)
        {
            rs   = self.Trait <RenderSprites>();
            body = self.Trait <BodyOrientation>();
            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.WorldOrientation.Yaw);
            DefaultAnimation.PlayRepeating(NormalizeSequence(self, info.Sequence));
            rs.Add(new AnimationWithOffset(DefaultAnimation,
                                           () => TurretOffset(self),
                                           () => IsTraitDisabled,
                                           p => RenderUtils.ZOffsetFromCenter(self, p, 1)), info.Palette, info.IsPlayerPalette);

            // Restrict turret facings to match the sprite
            t.QuantizedFacings = DefaultAnimation.CurrentSequence.Facings;
        }
Esempio n. 10
0
        protected WithSpriteBody(ActorInitializer init, WithSpriteBodyInfo info, Func <int> baseFacing)
            : base(info)
        {
            rs = init.Self.Trait <RenderSprites>();

            Func <bool> paused = () => IsTraitPaused &&
                                 DefaultAnimation.CurrentSequence.Name == NormalizeSequence(init.Self, Info.Sequence);

            DefaultAnimation = new Animation(init.World, rs.GetImage(init.Self), baseFacing, paused);
            rs.Add(new AnimationWithOffset(DefaultAnimation, null, () => IsTraitDisabled));

            if (info.StartSequence != null)
            {
                PlayCustomAnimation(init.Self, info.StartSequence,
                                    () => PlayCustomAnimationRepeating(init.Self, info.Sequence));
            }
            else
            {
                DefaultAnimation.PlayRepeating(NormalizeSequence(init.Self, info.Sequence));
            }
        }
Esempio n. 11
0
        public WithSpriteTurret(Actor self, WithSpriteTurretInfo 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();
            buildComplete = !self.Info.HasTraitInfo <BuildingInfo>();            // always render instantly for units

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

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