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); } }; } }
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); } }; } }
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); } }
public Buff Add(string id) { return(Add(BuffRegistry.Create(id))); }