public void Loot() { var aPileOfLoot = ParentWorld.NearbyObject(this, 1, Interactivity.Lootable); if (aPileOfLoot.Count > 0) { WorldObject loot = aPileOfLoot[0]; if (loot is AttackItem weapon) { if (Weapon != null) { ParentWorld.Add(Weapon); Weapon.Position = Position; } ParentWorld.Remove(weapon); Weapon = weapon; Tracer1.TraceEvent($"{this} looted a weapon"); } else if (loot is DefenceItem armor) { if (Armor != null) { ParentWorld.Add(Armor); Armor.Position = Position; } ParentWorld.Remove(armor); Armor = armor; Tracer1.TraceEvent($"{this} looted a piece of armor"); } } }
public void Hit() { if (Weapon == null) { return; } var cretures = ParentWorld.NearbyObject(this, Weapon.Range, Interactivity.Attackable); foreach (WorldObject worldObject in cretures) { if (worldObject is Creature creature) { Tracer1.TraceEvent($"{this} attacked {creature}"); creature.ReceiveHit(Weapon.Damage); if (!Weapon.Splash) { break; } } } }