/*public override void SetToRemove() * { * base.SetToRemove(); * _game.PacketNotifier.NotifyProjectileDestroy(this); * }*/ private void ApplyEffects(IAttackableUnit unit) { ObjectsHit.Add(unit); if (unit != null) { _originSpell.ApplyEffects(unit, this); } }
private void ApplyEffects(IAttackableUnit unit) { ObjectsHit.Add(unit); var attackableUnit = unit; if (attackableUnit != null) { OriginSpell.ApplyEffects(attackableUnit, this); } }
// todo refactor this protected virtual void CheckFlagsForUnit(IAttackableUnit unit) { if (Target == null) { return; } if (Target.IsSimpleTarget) { // Skillshot if (!CheckIfValidTarget(unit)) { return; } ObjectsHit.Add(unit); var attackableUnit = unit; if (attackableUnit != null) { OriginSpell.ApplyEffects(attackableUnit, this); } } else { if (Target is IAttackableUnit u) { // Autoguided spell if (OriginSpell != null) { OriginSpell.ApplyEffects(u, this); } else { // auto attack if (Owner is IObjAiBase ai) { ai.AutoAttackHit(u); } SetToRemove(); } } } }
public override void update(long diff) { if (Target == null) { setToRemove(); return; } if (Target.IsSimpleTarget) { // Skillshot var objects = _game.Map.GetObjects(); foreach (var it in objects) { if (isToRemove()) { return; } if (Collide(it.Value)) { if (ObjectsHit.Contains(it.Value)) { continue; } var u = it.Value as Unit; if (u == null) { continue; } if (u.Team == Owner.Team && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectFriends) > 0)) { continue; } if (u.Team == TeamId.TEAM_NEUTRAL && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectNeutral) > 0)) { continue; } if (u.Team != Owner.Team && u.Team != TeamId.TEAM_NEUTRAL && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectEnemies) > 0)) { continue; } if (u.IsDead && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectDead) > 0)) { continue; } var m = u as Minion; if (m != null && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectMinions) > 0)) { continue; } var p = u as Placeable; if (p != null && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectUseable) > 0)) { continue; } var t = u as BaseTurret; if (t != null && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectTurrets) > 0)) { continue; } var i = u as Inhibitor; var n = u as Nexus; if ((i != null || n != null) && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectBuildings) > 0)) { continue; } var c = u as Champion; if (c != null && !((_flags & (int)SpellFlag.SPELL_FLAG_AffectHeroes) > 0)) { continue; } ObjectsHit.Add(u); _originSpell.applyEffects(u, this); } } } else { var u = Target as Unit; if (u != null && Collide(u)) { // Autoguided spell if (_originSpell != null) { _originSpell.applyEffects(u, this); } else { // auto attack Owner.autoAttackHit(u); setToRemove(); } } } base.update(diff); }
protected virtual void CheckFlagsForUnit(AttackableUnit unit) { if (Target == null) { return; } if (Target.IsSimpleTarget) { // Skillshot if (unit == null || ObjectsHit.Contains(unit)) { return; } if (unit.Team == Owner.Team && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_FRIENDS) > 0)) { return; } if (unit.Team == TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_NEUTRAL) > 0)) { return; } if (unit.Team != Owner.Team && unit.Team != TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_ENEMIES) > 0)) { return; } if (unit.IsDead && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_DEAD) > 0)) { return; } if (unit is Minion m && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_MINIONS) > 0)) { return; } if (unit is Placeable p && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_USEABLE) > 0)) { return; } if (unit is BaseTurret t && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_TURRETS) > 0)) { return; } if ((unit is Inhibitor i || unit is Nexus n) && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_BUILDINGS) > 0)) { return; } if (unit is Champion c && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AFFECT_HEROES) > 0)) { return; } ObjectsHit.Add(unit); var attackableUnit = unit; if (attackableUnit != null) { _originSpell.ApplyEffects(attackableUnit, this); } } else { if (Target is AttackableUnit u) { // Autoguided spell if (_originSpell != null) { _originSpell.ApplyEffects(u, this); } else { // auto attack if (Owner is ObjAiBase ai) { ai.AutoAttackHit(u); } SetToRemove(); } } } }
protected override void CheckFlagsForUnit(AttackableUnit unit) { if (!Target.IsSimpleTarget) { return; } if (unit == null || ObjectsHit.Contains(unit)) { return; } if (unit.Team == Owner.Team && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectFriends) > 0)) { return; } if (unit.Team == TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectNeutral) > 0)) { return; } if (unit.Team != Owner.Team && unit.Team != TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectEnemies) > 0)) { return; } if (unit.IsDead && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectDead) > 0)) { return; } var m = unit as Minion; if (m != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectMinions) > 0)) { return; } var p = unit as Placeable; if (p != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectUseable) > 0)) { return; } var t = unit as BaseTurret; if (t != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectTurrets) > 0)) { return; } var i = unit as Inhibitor; var n = unit as Nexus; if ((i != null || n != null) && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectBuildings) > 0)) { return; } var c = unit as Champion; if (c != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectHeroes) > 0)) { return; } ObjectsHit.Add(unit); var attackableUnit = unit as AttackableUnit; if (attackableUnit != null) { _originSpell.applyEffects(attackableUnit, this); } }
protected virtual void CheckFlagsForUnit(Unit unit) { if (Target == null) { return; } if (Target.IsSimpleTarget) { // Skillshot if (unit == null || ObjectsHit.Contains(unit)) { return; } if (unit.Team == Owner.Team && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectFriends) > 0)) { return; } if (unit.Team == TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectNeutral) > 0)) { return; } if (unit.Team != Owner.Team && unit.Team != TeamId.TEAM_NEUTRAL && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectEnemies) > 0)) { return; } if (unit.IsDead && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectDead) > 0)) { return; } var m = unit as Minion; if (m != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectMinions) > 0)) { return; } var p = unit as Placeable; if (p != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectUseable) > 0)) { return; } var t = unit as BaseTurret; if (t != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectTurrets) > 0)) { return; } var i = unit as Inhibitor; var n = unit as Nexus; if ((i != null || n != null) && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectBuildings) > 0)) { return; } var c = unit as Champion; if (c != null && !((SpellData.Flags & (int)SpellFlag.SPELL_FLAG_AffectHeroes) > 0)) { return; } ObjectsHit.Add(unit); _originSpell.applyEffects(unit, this); } else { var u = Target as Unit; if (u != null) { // Autoguided spell if (_originSpell != null) { _originSpell.applyEffects(u, this); } else { // auto attack Owner.AutoAttackHit(u); setToRemove(); } } } }