public override void Click(Entity entity, ItemStack item) { if (!(entity is CharacterEntity)) { // TODO: Non-character support? return; } CharacterEntity character = (CharacterEntity)entity; double range = RangeBase * item.GetAttributeF("range_mod", 1f); double strength = StrengthBase * item.GetAttributeF("strength_mod", 1f) * GetStrength(); Location start = character.GetEyePosition(); // TODO: ItemPosition? Location forw = character.ForwardVector(); Location mid = start + forw * range; // TODO: base the pull on extent of the entity rather than its center. IE, if the side of a big ent is targeted, it should be rotated by the force. List <Entity> ents = character.TheRegion.GetEntitiesInRadius(mid, range); foreach (Entity ent in ents) { if (ent is PhysicsEntity) // TODO: Support for primitive ents? { PhysicsEntity pent = (PhysicsEntity)ent; Location rel = (start - ent.GetPosition()); double distsq = rel.LengthSquared(); if (distsq < 1) { distsq = 1; } pent.ApplyForce((rel / distsq) * strength); } } }