示例#1
0
        private void ApplyBuff(MeleeArc arc, string buff)
        {
            if (buff != null)
            {
                if (!BuffRegistry.All.TryGetValue(buff, out var info))
                {
                    Log.Error($"Unknown buff {buff}");

                    return;
                }

                arc.Color = info.Effect.GetColor();

                arc.OnHurt += (p, e) => {
                    if (e.TryGetComponent <BuffsComponent>(out var buffs))
                    {
                        var b = BuffRegistry.Create(buff);

                        if (InfiniteBuff)
                        {
                            b.Infinite = true;
                        }
                        else
                        {
                            b.TimeLeft = b.Duration = BuffDuration;
                        }

                        buffs.Add(b);
                    }
                };
            }
        }
示例#2
0
        private void ApplyBuff(Projectile projectile, string buff, bool explosive)
        {
            if (explosive)
            {
                projectile.Color    = ProjectileColor.Brown;
                projectile.OnDeath += (p, en, t) => {
                    ExplosionMaker.Make(p, 32, false, damage: 4, scale: 0.5f);
                };
            }

            if (buff != null)
            {
                if (!BuffRegistry.All.TryGetValue(buff, out var info))
                {
                    Log.Error($"Unknown buff {buff}");

                    return;
                }

                projectile.Color = info.Effect.GetColor();

                projectile.OnHurt += (p, e) => {
                    if (e.TryGetComponent <BuffsComponent>(out var buffs))
                    {
                        var b = BuffRegistry.Create(buff);

                        if (InfiniteBuff)
                        {
                            b.Infinite = true;
                        }
                        else
                        {
                            b.TimeLeft = b.Duration = BuffDuration;
                        }

                        buffs.Add(b);
                    }
                };
            }
        }
示例#3
0
        public override void Use(Entity entity, Item item)
        {
            var b = BuffRegistry.Create(Buff);

            if (b == null)
            {
                Log.Error($"Unknown buff {Buff}");
                return;
            }

            if (Time < 0)
            {
                b.Infinite = true;
            }
            else
            {
                b.TimeLeft = b.Duration = Time;
            }

            if (entity.TryGetComponent <BuffsComponent>(out var buffs))
            {
                buffs.Add(b);
            }
        }
示例#4
0
 public Buff Add(string id)
 {
     return(Add(BuffRegistry.Create(id)));
 }