Start moving creature properties out of records

This commit is contained in:
2025-06-06 08:46:27 +01:00
parent bae75a1e60
commit 4ae7c6ebd6
32 changed files with 609 additions and 672 deletions
+4 -51
View File
@@ -1,27 +1,19 @@
module Dodge.Euse (
createShieldWall,
removeShieldWall,
useE,
equipBackgroundEffect,
) where
import Color
import Dodge.Creature.HandPos
import Dodge.Creature.Test
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.Equipment.Misc
import Dodge.Data.World
import Dodge.Default.Wall
import Dodge.Item.HeldOffset
import Dodge.Item.Location
import Dodge.Wall.Create
import Dodge.Wall.Delete
import Dodge.Wall.Move
import Geometry
import LensHelp
useE :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
useE loc cr = case eo of
equipBackgroundEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr
EQUIP HEADLAMP -> createHeadLamp itm cr
@@ -36,8 +28,7 @@ useMagShield mt _ cr w =
w & cWorld . lWorld . magnets
.:~ Magnet
{ _mgPos = _crPos cr
, --, _mgField = MagnetBuBuCurveAroundField 50 200
_mgField = mt
, _mgField = mt
}
setWristShieldPos :: Item -> Creature -> World -> World
@@ -54,19 +45,6 @@ setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
| otherwise = id
f = (+.+ _crPos cr) . stripZ . rotate3 (_crDir cr) . handtrans cr
shieldWall :: Int -> Wall
shieldWall crid =
defaultWall
{ _wlColor = yellow
, _wlOpacity = SeeAbove
, _wlPathable = True
, _wlWalkable = True
, _wlFireThrough = True
, _wlReflect = True
, _wlRotateTo = False
, _wlStructure = CreaturePart crid -- shieldWallDamage
}
-- TODO the reflection should be controled by the particle
--shieldWallDamage :: Damage -> Wall -> Int -> World -> World
--shieldWallDamage dm _ crid w = case _dmType dm of
@@ -74,31 +52,6 @@ shieldWall crid =
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
-- _ -> w
createShieldWall :: Item -> Creature -> World -> World
createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
Nothing ->
let (wlid, w') = createWall ((shieldWall crid){_wlLine = wlline, _wlID = wlid}) w
in w' & pointerToItem it . itParams .~ FlatShieldParams (Just wlid)
Just wid -> moveWallID wid wlline w
where
crid = _crID cr
wlline = (a, b)
crdirv = unitVectorAtAngle $ _crDir cr
crpos = _crPos cr
rad = _crRad cr + 2
a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
therot
| crIsAiming cr = vNormal
| otherwise = rotateV (twoFlatHRot cr) . vNormal
removeShieldWall :: Item -> Creature -> World -> World
removeShieldWall it _ w = case it ^? itParams . flatShieldWlMIX . _Just of
Nothing -> w
Just wid ->
w & deleteWallID wid
& pointerToItem it . itParams . flatShieldWlMIX .~ Nothing
createHeadLamp :: Item -> Creature -> World -> World
createHeadLamp _ cr =
cWorld . lWorld . lights