module Dodge.Creature.Property where import Dodge.Data import Dodge.Item.Data import Geometry import Control.Lens crIsArmouredFrom :: Point2 -> Creature -> Bool crIsArmouredFrom p cr = p /= _crPos cr && any (\it -> it ^? itIdentity == Just FrontArmour) (_crInv cr) && angleVV (unitVectorAtAngle $ _crDir cr) (p -.- _crPos cr) < pi/2 -- even though angleVV can generate NaN, the comparison seems to deal with it crOnSeg :: Point2 -> Point2 -> Creature -> Bool crOnSeg p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr) crNearSeg :: Float -> Point2 -> Point2 -> Creature -> Bool crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d)