Improve forcefield visuals
This commit is contained in:
@@ -12,6 +12,8 @@ module Dodge.Base.Collide
|
|||||||
, isWalkable
|
, isWalkable
|
||||||
, canSee
|
, canSee
|
||||||
, hasLOSIndirect
|
, hasLOSIndirect
|
||||||
|
, wlIsOpaque
|
||||||
|
, wlIsSeeThrough
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
@@ -126,7 +128,14 @@ collidePointWalkable p1 p2 ws
|
|||||||
-- p3 = p1 +.+ d *.* safeNormalizeV (p2 -.- p1)
|
-- p3 = p1 +.+ d *.* safeNormalizeV (p2 -.- p1)
|
||||||
|
|
||||||
wlIsOpaque :: Wall -> Bool
|
wlIsOpaque :: Wall -> Bool
|
||||||
wlIsOpaque wl = _wlOpacity wl == Opaque
|
wlIsOpaque wl = case _wlOpacity wl of
|
||||||
|
Opaque -> True
|
||||||
|
_ -> False
|
||||||
|
|
||||||
|
wlIsSeeThrough :: Wall -> Bool
|
||||||
|
wlIsSeeThrough wl = case _wlOpacity wl of
|
||||||
|
SeeThrough -> True
|
||||||
|
_ -> False
|
||||||
|
|
||||||
--collidePointUpToIndirect
|
--collidePointUpToIndirect
|
||||||
-- :: Point2 -- ^start point
|
-- :: Point2 -- ^start point
|
||||||
|
|||||||
+2
-1
@@ -1042,8 +1042,8 @@ data Wall = Wall
|
|||||||
data Opacity
|
data Opacity
|
||||||
= SeeThrough
|
= SeeThrough
|
||||||
| SeeAbove
|
| SeeAbove
|
||||||
|
| DrawnWall {_opDraw :: Wall -> SPic}
|
||||||
| Opaque
|
| Opaque
|
||||||
deriving (Eq,Ord,Show)
|
|
||||||
data WallStructure
|
data WallStructure
|
||||||
= StandaloneWall
|
= StandaloneWall
|
||||||
| DoorPart { _wlStDoor :: Int }
|
| DoorPart { _wlStDoor :: Int }
|
||||||
@@ -1585,6 +1585,7 @@ makeLenses ''Modification
|
|||||||
makeLenses ''Particle
|
makeLenses ''Particle
|
||||||
makeLenses ''Wall
|
makeLenses ''Wall
|
||||||
makeLenses ''WallStructure
|
makeLenses ''WallStructure
|
||||||
|
makeLenses ''Opacity
|
||||||
makeLenses ''PressPlate
|
makeLenses ''PressPlate
|
||||||
makeLenses ''Button
|
makeLenses ''Button
|
||||||
makeLenses ''ActionPlan
|
makeLenses ''ActionPlan
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Dodge.Debug.Picture where
|
module Dodge.Debug.Picture where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Base.Window
|
import Dodge.Base.Window
|
||||||
|
import Dodge.Base.Collide
|
||||||
import Geometry
|
import Geometry
|
||||||
import Picture
|
import Picture
|
||||||
|
|
||||||
@@ -46,7 +47,7 @@ pointOnScreen cfig w p = pointInPolygon p . reverse $ screenPolygon cfig w
|
|||||||
|
|
||||||
drawWallFace :: Configuration -> World -> Wall -> Picture
|
drawWallFace :: Configuration -> World -> Wall -> Picture
|
||||||
drawWallFace cfig w wall
|
drawWallFace cfig w wall
|
||||||
| isRHS sightFrom x y || _wlOpacity wall /= Opaque = blank
|
| isRHS sightFrom x y || not (wlIsOpaque wall) = blank
|
||||||
| otherwise = setDepth (-1) . color (withAlpha 0 black) . polygon $ points
|
| otherwise = setDepth (-1) . color (withAlpha 0 black) . polygon $ points
|
||||||
where
|
where
|
||||||
(x,y) = _wlLine wall
|
(x,y) = _wlLine wall
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Dodge.Default.Wall
|
|||||||
import Dodge.Creature.Test
|
import Dodge.Creature.Test
|
||||||
import Dodge.Creature.HandPos
|
import Dodge.Creature.HandPos
|
||||||
import Dodge.Wall
|
import Dodge.Wall
|
||||||
|
import Dodge.Wall.ForceField
|
||||||
import Dodge.Magnet
|
import Dodge.Magnet
|
||||||
import Picture
|
import Picture
|
||||||
import Geometry
|
import Geometry
|
||||||
@@ -80,7 +81,7 @@ wristArmour = defaultEquipment
|
|||||||
onEquipWristShield :: Item -> Creature -> World -> World
|
onEquipWristShield :: Item -> Creature -> World -> World
|
||||||
onEquipWristShield itm cr w = w
|
onEquipWristShield itm cr w = w
|
||||||
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ EquipID i
|
& creatures . ix (_crID cr) . crInv . ix (fromJust (_itInvPos itm)) . itUse . eqEq . eqParams .~ EquipID i
|
||||||
& walls . at i ?~ (shieldWall (_crID cr)) {_wlDraw = True,_wlID = i}
|
& walls . at i ?~ forceField {_wlID = i}
|
||||||
& setWristShieldPos (itm & itUse . eqEq . eqParams .~ EquipID i) cr
|
& setWristShieldPos (itm & itUse . eqEq . eqParams .~ EquipID i) cr
|
||||||
where
|
where
|
||||||
i = IM.newKey (_walls w)
|
i = IM.newKey (_walls w)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Dodge.Data
|
|||||||
import Dodge.Wall.Reflect
|
import Dodge.Wall.Reflect
|
||||||
--import Dodge.Creature.HandPos
|
--import Dodge.Creature.HandPos
|
||||||
import Dodge.WorldEvent
|
import Dodge.WorldEvent
|
||||||
|
import Dodge.Base.Collide
|
||||||
--import Dodge.Default
|
--import Dodge.Default
|
||||||
--import Dodge.Item.Weapon.InventoryDisplay
|
--import Dodge.Item.Weapon.InventoryDisplay
|
||||||
--import Dodge.Item.Weapon.TriggerType
|
--import Dodge.Item.Weapon.TriggerType
|
||||||
@@ -27,7 +28,7 @@ reflectLaserAlong phasev seenWl sp ep w = case find (notseen seenWl)
|
|||||||
Just (p,Right wl)
|
Just (p,Right wl)
|
||||||
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev (wl:seenWl) p
|
| _wlReflect wl -> second (p:) $ reflectLaserAlong phasev (wl:seenWl) p
|
||||||
(p +.+ 800 *.* unitVectorAtAngle (reflDirWall sp p wl)) w
|
(p +.+ 800 *.* unitVectorAtAngle (reflDirWall sp p wl)) w
|
||||||
| _wlOpacity wl == SeeThrough -> second (p:) $ reflectLaserAlong phasev (wl:seenWl) p
|
| wlIsSeeThrough wl -> second (p:) $ reflectLaserAlong phasev (wl:seenWl) p
|
||||||
(refract sp ep wl p) w
|
(refract sp ep wl p) w
|
||||||
| otherwise -> (Just (p,Right wl), [p])
|
| otherwise -> (Just (p,Right wl), [p])
|
||||||
Just (p,obj) -> (Just (p,obj), [p])
|
Just (p,obj) -> (Just (p,obj), [p])
|
||||||
|
|||||||
+2
-2
@@ -38,7 +38,7 @@ doDrawing pdata u = do
|
|||||||
trans = _cameraCenter w
|
trans = _cameraCenter w
|
||||||
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig)
|
||||||
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
|
resFact = resFactorNum $ cfig ^. graphics_resolution_factor
|
||||||
(wallPointsCol,windowPoints) = wallsAndWindows cfig w
|
(wallPointsCol,windowPoints,wallSPics) = wallsToDrawStreams cfig w
|
||||||
lightPoints = lightsForGloom w
|
lightPoints = lightsForGloom w
|
||||||
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
viewFroms@(V2 vfx vfy) = _cameraViewFrom w
|
||||||
viewFrom3d = Vector3 vfx vfy 20
|
viewFrom3d = Vector3 vfx vfy 20
|
||||||
@@ -50,7 +50,7 @@ doDrawing pdata u = do
|
|||||||
shapeCounts <- UMV.replicate 3 0
|
shapeCounts <- UMV.replicate 3 0
|
||||||
wlwiflCounts <- UMV.replicate 3 0
|
wlwiflCounts <- UMV.replicate 3 0
|
||||||
-- attempt to poke in parallel
|
-- attempt to poke in parallel
|
||||||
let (ws,wp) = worldSPic cfig w
|
let (ws,wp) = wallSPics <> worldSPic cfig w
|
||||||
MP.bindM3 (\ _ _ _ -> return ())
|
MP.bindM3 (\ _ _ _ -> return ())
|
||||||
( pokeBindFoldableLayer shadV layerCounts wp)
|
( pokeBindFoldableLayer shadV layerCounts wp)
|
||||||
( pokeWallsWindowsFloor
|
( pokeWallsWindowsFloor
|
||||||
|
|||||||
@@ -1,20 +1,42 @@
|
|||||||
module Dodge.Render.Walls
|
module Dodge.Render.Walls
|
||||||
( wallsAndWindows
|
( wallsToDrawStreams
|
||||||
) where
|
) where
|
||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Zone
|
import Dodge.Zone
|
||||||
|
import Dodge.Base.Collide
|
||||||
import Geometry
|
import Geometry
|
||||||
|
import ShapePicture
|
||||||
|
|
||||||
import Data.List
|
import Control.Lens
|
||||||
import qualified Data.IntMap.Strict as IM
|
--import Data.Maybe
|
||||||
wallsAndWindows
|
import qualified Control.Foldl as L
|
||||||
|
--import Data.List
|
||||||
|
--import qualified Data.IntMap.Strict as IM
|
||||||
|
wallsToDrawStreams
|
||||||
:: Configuration
|
:: Configuration
|
||||||
-> World
|
-> World
|
||||||
-> ( [((Point2,Point2),Point4)] ,[((Point2,Point2),Point4)] )
|
-> ( [((Point2,Point2),Point4)] ,[((Point2,Point2),Point4)], SPic )
|
||||||
wallsAndWindows cfig w
|
wallsToDrawStreams cfig w
|
||||||
= (map f wls, map f wins)
|
= ( wls, wins,spic)
|
||||||
where
|
where
|
||||||
f wl = (_wlLine wl, _wlColor wl)
|
f wl = (_wlLine wl, _wlColor wl)
|
||||||
(wins,wls) = partition theTest . IM.elems . IM.filter _wlDraw $ wallsDoubleScreen cfig w
|
(wls, wins, spic) = L.fold ((,,)
|
||||||
theTest wl = _wlOpacity wl /= Opaque
|
<$> L.prefilter wlOpaqueDraw (L.premap f L.list)
|
||||||
|
<*> L.prefilter wlSeeThroughDraw (L.premap f L.list)
|
||||||
|
<*> L.premap getWallSPic L.mconcat
|
||||||
|
) (wallsDoubleScreen cfig w)
|
||||||
|
wlOpaqueDraw :: Wall -> Bool
|
||||||
|
wlOpaqueDraw wl = wlIsOpaque wl && _wlDraw wl
|
||||||
|
wlSeeThroughDraw :: Wall -> Bool
|
||||||
|
wlSeeThroughDraw wl = wlIsSeeThrough wl && _wlDraw wl
|
||||||
|
|
||||||
|
getWallSPic :: Wall -> SPic
|
||||||
|
getWallSPic wl = case wl ^? wlOpacity . opDraw of
|
||||||
|
Nothing -> mempty
|
||||||
|
Just f -> f wl
|
||||||
|
|
||||||
|
-- (wins,wls) = partition theTest . IM.elems . IM.filter _wlDraw $ wallsDoubleScreen cfig w
|
||||||
|
-- theTest wl = case _wlOpacity wl of
|
||||||
|
-- Opaque -> False
|
||||||
|
-- _ -> True
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -399,7 +399,7 @@ crCrSpring c1 c2 w
|
|||||||
{- Finds the visible walls from a point to another point. -}
|
{- Finds the visible walls from a point to another point. -}
|
||||||
visibleWalls :: Point2 -> Point2 -> IM.IntMap Wall -> [Wall]
|
visibleWalls :: Point2 -> Point2 -> IM.IntMap Wall -> [Wall]
|
||||||
visibleWalls p1 p2 ws
|
visibleWalls p1 p2 ws
|
||||||
= takeUntil isOpaque
|
= takeUntil wlIsOpaque
|
||||||
. map snd
|
. map snd
|
||||||
. sortOn (dist p1 . fromJust . fst)
|
. sortOn (dist p1 . fromJust . fst)
|
||||||
. filter (isJust . fst)
|
. filter (isJust . fst)
|
||||||
@@ -407,7 +407,6 @@ visibleWalls p1 p2 ws
|
|||||||
$ IM.elems ws
|
$ IM.elems ws
|
||||||
where
|
where
|
||||||
f wl = (uncurry intersectSegSeg (_wlLine wl) p1 p2, wl)
|
f wl = (uncurry intersectSegSeg (_wlLine wl) p1 p2, wl)
|
||||||
isOpaque wl = _wlOpacity wl == Opaque
|
|
||||||
|
|
||||||
updateDelayedEvents :: World -> World
|
updateDelayedEvents :: World -> World
|
||||||
updateDelayedEvents w = let (neww,newde) = mapAccumR f w (_delayedEvents w)
|
updateDelayedEvents w = let (neww,newde) = mapAccumR f w (_delayedEvents w)
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ module Dodge.Wall.ForceField where
|
|||||||
import Dodge.Data
|
import Dodge.Data
|
||||||
import Dodge.Default.Wall
|
import Dodge.Default.Wall
|
||||||
import Color
|
import Color
|
||||||
|
import Picture
|
||||||
|
import ShapePicture
|
||||||
|
|
||||||
forceField :: Wall
|
forceField :: Wall
|
||||||
forceField = defaultWall
|
forceField = defaultWall
|
||||||
{_wlColor = orange
|
{_wlColor = orange
|
||||||
,_wlOpacity = SeeAbove
|
,_wlOpacity = DrawnWall drawForceField
|
||||||
,_wlPathable = True
|
,_wlPathable = True
|
||||||
,_wlWalkable = True
|
,_wlWalkable = True
|
||||||
,_wlFireThrough = True
|
,_wlFireThrough = True
|
||||||
@@ -15,3 +17,13 @@ forceField = defaultWall
|
|||||||
,_wlRotateTo = False
|
,_wlRotateTo = False
|
||||||
,_wlStructure = StandaloneWall
|
,_wlStructure = StandaloneWall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
drawForceField :: Wall -> SPic
|
||||||
|
drawForceField wl = (mempty
|
||||||
|
, setLayer BloomLayer
|
||||||
|
. setDepth 20
|
||||||
|
. color (_wlColor wl)
|
||||||
|
$ thickLine 5 [a,b]
|
||||||
|
)
|
||||||
|
where
|
||||||
|
(a,b) = _wlLine wl
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module FoldableHelp
|
|||||||
, safeMinimumOnMaybeF
|
, safeMinimumOnMaybeF
|
||||||
, safeMinimumOnMaybeL
|
, safeMinimumOnMaybeL
|
||||||
, safeMinMaybeL
|
, safeMinMaybeL
|
||||||
|
, filter3
|
||||||
, module Data.Foldable
|
, module Data.Foldable
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@@ -62,6 +63,16 @@ safeMinimumOnMaybe f ys = fst <$> go Nothing ys
|
|||||||
_ -> go (Just (y,cmin)) xs
|
_ -> go (Just (y,cmin)) xs
|
||||||
go m _ = m
|
go m _ = m
|
||||||
|
|
||||||
|
filter3 :: Foldable t
|
||||||
|
=> (a -> Bool)
|
||||||
|
-> (a -> Bool)
|
||||||
|
-> (a -> Bool)
|
||||||
|
-> t a
|
||||||
|
-> ([a],[a],[a])
|
||||||
|
filter3 t1 t2 t3 = L.fold $ (,,)
|
||||||
|
<$> L.prefilter t1 L.list
|
||||||
|
<*> L.prefilter t2 L.list
|
||||||
|
<*> L.prefilter t3 L.list
|
||||||
|
|
||||||
--{- | Partial. -}
|
--{- | Partial. -}
|
||||||
--minimumOn :: Ord b => (a -> b) -> [a] -> a
|
--minimumOn :: Ord b => (a -> b) -> [a] -> a
|
||||||
|
|||||||
Reference in New Issue
Block a user