module Dodge.Creature.Property ( crIsArmouredFrom , crNearSeg , crNearPoint ) where import Dodge.Data import Geometry import Control.Lens crIsArmouredFrom :: Point2 -> Creature -> Bool crIsArmouredFrom p cr = p /= _crPos cr && any (\it -> it ^? itType == 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) crNearPoint :: Float -> Point2 -> Creature -> Bool crNearPoint d p cr = dist (_crPos cr) p < d + _crRad cr