Add forgotten files, many updates concerning turrets and shields
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
module Dodge.Wall.Create
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Wall.Zone
|
||||
|
||||
import Control.Lens
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
createWall :: Wall -> World -> (Int,World)
|
||||
createWall wl w = (wlid
|
||||
, w & walls %~ IM.insert wlid newwl
|
||||
& insertWallInZones newwl
|
||||
)
|
||||
where
|
||||
newwl = wl {_wlID = wlid}
|
||||
wlid = IM.newKey $ _walls w
|
||||
@@ -18,6 +18,7 @@ damageWall :: DamageType -> Wall -> World -> World
|
||||
damageWall dt wl = case _wlStructure wl of
|
||||
MachinePart mcid -> machines . ix mcid . mcDamage %~ (dt :)
|
||||
BlockPart blid -> wallEff dt wl . (blocks . ix blid %~ damageBlockWith dt)
|
||||
CreaturePart crid f -> f dt wl crid
|
||||
_ -> wallEff dt wl
|
||||
{- | Damage effects on indestructible walls -}
|
||||
-- TODO take into account damage amount for amount of dust/sparks?
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
module Dodge.Wall.Delete
|
||||
( deleteWallIDs
|
||||
, deleteWallID
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Zone
|
||||
import Geometry
|
||||
import Dodge.Wall.Zone
|
||||
|
||||
import Control.Lens
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import qualified Data.IntSet as IS
|
||||
|
||||
deleteWallID :: Int -> World -> World
|
||||
deleteWallID i w = w & walls %~ IM.delete i
|
||||
& deleteWallFromZones wl
|
||||
where
|
||||
wl = _walls w IM.! i
|
||||
|
||||
deleteWall :: Wall -> World -> World
|
||||
deleteWall wl = (walls %~ IM.delete i)
|
||||
. (wallsZone . znObjects . ix x . ix y %~ IM.delete i)
|
||||
. deleteWallFromZones wl
|
||||
where
|
||||
(x,y) = zoneOfPoint $ uncurry pHalf (_wlLine wl)
|
||||
i = _wlID wl
|
||||
|
||||
deleteWallIDs :: IS.IntSet -> World -> World
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
module Dodge.Wall.Move
|
||||
where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
import Dodge.Wall.Zone
|
||||
|
||||
import Control.Lens
|
||||
moveWallID :: Int -> (Point2,Point2) -> World -> World
|
||||
moveWallID wlid wlline w = case w ^? walls . ix wlid of
|
||||
Nothing -> w
|
||||
Just wl -> moveWall wlid wl wlline w
|
||||
moveWall :: Int -> Wall -> (Point2,Point2) -> World -> World
|
||||
moveWall wlid wl wlline w = w & walls . ix wlid .~ newwl
|
||||
& deleteWallFromZones wl
|
||||
& insertWallInZones newwl
|
||||
where
|
||||
newwl = wl {_wlLine = wlline}
|
||||
@@ -0,0 +1,24 @@
|
||||
module Dodge.Wall.Zone
|
||||
where
|
||||
import Dodge.Data
|
||||
import Geometry
|
||||
import Dodge.Zone
|
||||
import Dodge.Base
|
||||
|
||||
import Control.Lens
|
||||
import Data.Foldable
|
||||
|
||||
zoneOfWall :: Wall -> [(Int,Int)]
|
||||
zoneOfWall wl
|
||||
| uncurry dist wlline <= 2*zoneSize = [zoneOfPoint $ uncurry pHalf wlline ]
|
||||
| otherwise = map zoneOfPoint $ uncurry (divideLine zoneSize) wlline
|
||||
where
|
||||
wlline = _wlLine wl
|
||||
|
||||
insertWallInZones :: Wall -> World -> World
|
||||
insertWallInZones wl = wallsZone . znObjects
|
||||
%~ flip (foldl' (flip $ \(a,b) -> insertIMInZone a b (_wlID wl) wl)) (zoneOfWall wl)
|
||||
|
||||
deleteWallFromZones :: Wall -> World -> World
|
||||
deleteWallFromZones wl = wallsZone . znObjects
|
||||
%~ flip (foldl' (flip $ \(a,b) -> deleteIMInZone a b (_wlID wl))) (zoneOfWall wl)
|
||||
Reference in New Issue
Block a user