From 5f3b932338531998ffa3c29c8dc0228dcc18e36e Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 5 Jun 2025 15:39:55 +0100 Subject: [PATCH] Add file --- src/Dodge/Equipment.hs | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/Dodge/Equipment.hs diff --git a/src/Dodge/Equipment.hs b/src/Dodge/Equipment.hs new file mode 100644 index 000000000..45cf44ef3 --- /dev/null +++ b/src/Dodge/Equipment.hs @@ -0,0 +1,64 @@ +module Dodge.Equipment ( + effectOnRemove, + effectOnEquip, +) where + +import Dodge.Creature.Test +import Dodge.Creature.HandPos +import Geometry +import Dodge.Wall.Move +import Dodge.Wall.ForceField +import qualified IntMapHelp as IM +import Dodge.Wall.Delete +import Dodge.Item.Location +import Control.Lens +import Dodge.Data.World +import Data.Maybe + +effectOnRemove :: Item -> Creature -> World -> World +effectOnRemove itm = case itm ^. itType of + EQUIP WRISTARMOUR -> onRemoveWristShield' itm + _ -> \_ -> id + +onRemoveWristShield' :: Item -> Creature -> World -> World +onRemoveWristShield' itm _ = + --(pointerToItem itm . itUse . uequipEffect . eeParams .~ NoEquipParams) . mremovewall + (pointerToItem itm . itParams .~ NoParams) . mremovewall + where + mremovewall = fromMaybe id $ do + --i <- itm ^? itUse . uequipEffect . eeParams . eparamID + i <- itm ^? itParams . itParamID + return $ deleteWallID i + +effectOnEquip :: Item -> Creature -> World -> World +effectOnEquip itm = case itm ^. itType of + EQUIP WRISTARMOUR -> onEquipWristShield' itm + _ -> \_ -> id + +onEquipWristShield' :: Item -> Creature -> World -> World +onEquipWristShield' itm cr w = + w +-- & pointerToItem itm . itUse . uequipEffect . eeParams .~ EquipID i + & pointerToItem itm . itParams .~ ItemParamID {_itParamID = i} + & cWorld . lWorld . walls . at i ?~ forceField{_wlID = i} + & setWristShieldPos (itm + -- & itUse . uequipEffect . eeParams .~ EquipID i + & itParams .~ ItemParamID {_itParamID = i} + ) cr + where + i = IM.newKey (w ^. cWorld . lWorld . walls) + +setWristShieldPos :: Item -> Creature -> World -> World +setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline + where + --i = _eparamID $ _eeParams $ _uequipEffect $ _itUse itm + i = _itParamID $ _itParams itm + wlline = (f (V3 (-10) 7 0), f (V3 10 7 0)) + invid = _ilInvID (_itLocation itm) + handtrans = case cr ^? crInv . ix invid . itLocation . ilEquipSite . _Just of + Just OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g + _ -> translatePointToRightHand + g + | twists cr = (+.+.+ V3 (-5) 10 0) + | otherwise = id + f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans cr