Exemplo n.º 1
0
        public void Killed(Actor self, AttackInfo attackInfo)
        {
            //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 (attackInfo.Damage.DamageTypes.Count == 0)
            {
                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(attackInfo.Damage.DamageTypes.Contains);
                if (damageType == null)
                {
                    return;
                }

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

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

            Func <bool> paused = null;

            if (info.PauseAnimationWhenDisabled)
            {
                paused = () => init.Self.IsDisabled() && 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));
            }
        }