From 480fc2df5e53b30a8d889a91e5ac69cc1061eab1 Mon Sep 17 00:00:00 2001 From: justin Date: Tue, 28 Jun 2022 03:29:55 +0100 Subject: [PATCH] Continue refactor --- src/Dodge/Item/Weapon/SonicGuns.hs | 2 +- src/Dodge/Item/Weapon/UseEffect.hs | 1 - src/Dodge/Placement/PlaceSpot/Block.hs | 2 +- src/Dodge/Render.hs | 2 +- src/Dodge/Render/Walls.hs | 9 ++++----- src/Dodge/WorldEvent/ThingsHit.hs | 24 +++++++++--------------- src/Dodge/Zone.hs | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/Dodge/Item/Weapon/SonicGuns.hs b/src/Dodge/Item/Weapon/SonicGuns.hs index 572d7fefa..16991f525 100644 --- a/src/Dodge/Item/Weapon/SonicGuns.hs +++ b/src/Dodge/Item/Weapon/SonicGuns.hs @@ -5,7 +5,7 @@ import Dodge.Creature.HandPos --import Dodge.Particle.TeslaArc --import Dodge.SoundLogic.LoadSound --import Dodge.WorldEvent -import Dodge.WorldEvent.ThingsHit +--import Dodge.WorldEvent.ThingsHit --import Dodge.Default --import Dodge.Item.Weapon.InventoryDisplay import Dodge.Item.Weapon.TriggerType diff --git a/src/Dodge/Item/Weapon/UseEffect.hs b/src/Dodge/Item/Weapon/UseEffect.hs index 9555d62af..400da98f6 100644 --- a/src/Dodge/Item/Weapon/UseEffect.hs +++ b/src/Dodge/Item/Weapon/UseEffect.hs @@ -12,7 +12,6 @@ import Picture import Geometry import LensHelp -import Data.Maybe import qualified Data.IntMap.Strict as IM import qualified Streaming.Prelude as S {- | Creates an outwardly increasing circle that draws creatures, even those behind walls. -} diff --git a/src/Dodge/Placement/PlaceSpot/Block.hs b/src/Dodge/Placement/PlaceSpot/Block.hs index a724d6be2..2b53ce3da 100644 --- a/src/Dodge/Placement/PlaceSpot/Block.hs +++ b/src/Dodge/Placement/PlaceSpot/Block.hs @@ -50,7 +50,7 @@ addBlock (p:ps) wl bl w = w V2 x y = wallZoneOfPoint $ uncurry midPoint (_wlLine wl) wlid = _wlID wl ips = map (unv2 . wallZoneOfPoint) $ uncurry (divideLine (2*wallZoneSize)) (_wlLine wl) - unv2 (V2 x y) = (x,y) + unv2 (V2 x' y') = (x',y') addBlock _ _ _ _ = error "Trying to add a block with incomplete polygon" placeBlock :: [Point2] -> Block -> Wall -> World -> (Int,World) diff --git a/src/Dodge/Render.hs b/src/Dodge/Render.hs index dd4f47d29..2da3dd364 100644 --- a/src/Dodge/Render.hs +++ b/src/Dodge/Render.hs @@ -38,7 +38,7 @@ doDrawing pdata u = do trans = _cameraCenter w wins@(V2 winx winy) = V2 (_windowX cfig) (_windowY cfig) resFact = resFactorNum $ cfig ^. graphics_resolution_factor - (wallPointsCol,windowPoints,wallSPics) = wallsToDrawStreams cfig w + (wallPointsCol,windowPoints,wallSPics) = wallsToDraw w lightPoints = lightsToRender cfig w viewFroms@(V2 vfx vfy) = _cameraViewFrom w viewFrom3d = Vector3 vfx vfy 20 diff --git a/src/Dodge/Render/Walls.hs b/src/Dodge/Render/Walls.hs index b368a2339..a37d3a10d 100644 --- a/src/Dodge/Render/Walls.hs +++ b/src/Dodge/Render/Walls.hs @@ -1,5 +1,5 @@ module Dodge.Render.Walls - ( wallsToDrawStreams + ( wallsToDraw ) where import Dodge.Data import Dodge.Zone @@ -13,11 +13,10 @@ import qualified Control.Foldl as L import qualified Streaming.Prelude as S --import Data.List --import qualified Data.IntMap.Strict as IM -wallsToDrawStreams - :: Configuration - -> World +wallsToDraw + :: World -> ( [((Point2,Point2),Point4)] ,[((Point2,Point2),Point4)], SPic ) -wallsToDrawStreams cfig w +wallsToDraw w = ( wls, wins,spic) where f wl = (_wlLine wl, _wlColor wl) diff --git a/src/Dodge/WorldEvent/ThingsHit.hs b/src/Dodge/WorldEvent/ThingsHit.hs index c96c03f9c..bac81526e 100644 --- a/src/Dodge/WorldEvent/ThingsHit.hs +++ b/src/Dodge/WorldEvent/ThingsHit.hs @@ -57,18 +57,12 @@ thingsHitExceptCr (Just cid) sp ep = S.filter crNotCid . thingsHit sp ep crNotCid (_,Left cr) = _crID cr /= cid crNotCid _ = True ---wallsHit --- :: Point2 -- ^ Line start point --- -> Point2 -- ^ Line end point --- -> World --- -> [(Point2, Wall)] ---wallsHit sp ep w --- | sp == ep = [] --- | otherwise = sortOn (dist sp . fst) wls --- where --- wls = IM.elems $ wallsOnLineHit sp ep --- $ IM.unions [f b $ f a $ _znObjects $ _wallsZone w --- | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]] --- -- $ _walls w --- V2 x y = wallZoneOfPoint (0.5 *.* (sp +.+ ep)) --- f i = fromMaybe IM.empty . IM.lookup i +wallsHit + :: Point2 -- ^ Line start point + -> Point2 -- ^ Line end point + -> World + -> Stream (Of (Point2, Wall)) Identity () +wallsHit sp ep w + | sp == ep = S.each [] + | otherwise = sortStreamOn (dist sp . fst) + . overlapSegWalls sp ep $ wallsAlongLine sp ep w diff --git a/src/Dodge/Zone.hs b/src/Dodge/Zone.hs index 050337ad2..2a0a257a6 100644 --- a/src/Dodge/Zone.hs +++ b/src/Dodge/Zone.hs @@ -7,6 +7,7 @@ module Dodge.Zone , lookLookups , zoneOfSeg , zoneNearPointIP + , zoneNearPoint , cloudZoneOfPoint , cloudsNearPoint , wallsNearZones @@ -34,7 +35,6 @@ import Data.Maybe import Data.List --import Data.IntMap.Merge.Strict import qualified Data.IntMap.Strict as IM -import qualified Data.IntSet as IS import Control.Lens --flattenZones :: Zone (IM.IntMap a) -> IM.IntMap a