Compare commits
9 Commits
902d8e0c00
...
5394450800
| Author | SHA1 | Date | |
|---|---|---|---|
| 5394450800 | |||
| b52964f606 | |||
| 4984ce95c3 | |||
| 508b848204 | |||
| d1c2870d63 | |||
| 3b4cf68a15 | |||
| 13b12f01a8 | |||
| 96c2fb00e1 | |||
| 4cacb45252 |
@@ -21,7 +21,8 @@ itemTriggerType loc
|
|||||||
baseItemTriggerType :: Item -> TriggerType
|
baseItemTriggerType :: Item -> TriggerType
|
||||||
baseItemTriggerType itm = case itm ^. itType of
|
baseItemTriggerType itm = case itm ^. itType of
|
||||||
HELD hit -> heldTriggerType hit
|
HELD hit -> heldTriggerType hit
|
||||||
ATTACH CAPACITOR -> AutoTrigger 10
|
ATTACH CAPACITOR -> AutoTrigger 0
|
||||||
|
-- ATTACH CAPACITOR -> AutoTrigger 10
|
||||||
_ -> NoTrigger
|
_ -> NoTrigger
|
||||||
|
|
||||||
heldTriggerType :: HeldItemType -> TriggerType
|
heldTriggerType :: HeldItemType -> TriggerType
|
||||||
@@ -54,8 +55,7 @@ heldTriggerType = \case
|
|||||||
FLAMETORRENT -> NoTrigger
|
FLAMETORRENT -> NoTrigger
|
||||||
FLAMEWALL -> NoTrigger
|
FLAMEWALL -> NoTrigger
|
||||||
BLOWTORCH -> NoTrigger
|
BLOWTORCH -> NoTrigger
|
||||||
SPARKGUN -> NoTrigger
|
TESLACOIL -> NoTrigger
|
||||||
TESLAGUN -> NoTrigger
|
|
||||||
TRACTORGUN -> NoTrigger
|
TRACTORGUN -> NoTrigger
|
||||||
RLAUNCHER -> SemiAutoTrigger 20
|
RLAUNCHER -> SemiAutoTrigger 20
|
||||||
RLAUNCHERX{} -> SemiAutoTrigger 20
|
RLAUNCHERX{} -> SemiAutoTrigger 20
|
||||||
|
|||||||
+36
-26
@@ -1,20 +1,20 @@
|
|||||||
module Dodge.Block.Debris (
|
module Dodge.Block.Debris (
|
||||||
cubeShape,
|
cubeShape,
|
||||||
-- dirtColor,
|
-- dirtColor,
|
||||||
makeDoorDebris,
|
makeDoorDebris,
|
||||||
makeBlockDebris,
|
makeBlockDebris,
|
||||||
makeDebris,
|
makeDebris,
|
||||||
makeDebrisDirected,
|
makeDebrisDirected,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Dodge.Material.Color
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
|
||||||
import Dodge.ShiftPoint
|
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Dodge.Data.World
|
import Dodge.Data.World
|
||||||
|
import Dodge.Material.Color
|
||||||
import Dodge.Material.Sound
|
import Dodge.Material.Sound
|
||||||
|
import Dodge.ShiftPoint
|
||||||
import Dodge.WorldEvent.Sound
|
import Dodge.WorldEvent.Sound
|
||||||
import Geometry
|
import Geometry
|
||||||
import Grid
|
import Grid
|
||||||
@@ -30,7 +30,7 @@ makeDoorDebris dr w = w & makeDebris mt p
|
|||||||
p = centroid . fmap fst $ (dr ^. drFootPrint) & each . each %~ shiftPointBy p2a
|
p = centroid . fmap fst $ (dr ^. drFootPrint) & each . each %~ shiftPointBy p2a
|
||||||
mt = fromMaybe Stone $ do
|
mt = fromMaybe Stone $ do
|
||||||
wlids <- w ^? cWorld . lWorld . doors . ix (_drID dr) . drFootPrint
|
wlids <- w ^? cWorld . lWorld . doors . ix (_drID dr) . drFootPrint
|
||||||
((wlid,_),_) <- IM.minViewWithKey wlids
|
((wlid, _), _) <- IM.minViewWithKey wlids
|
||||||
w ^? cWorld . lWorld . walls . ix wlid . wlMaterial
|
w ^? cWorld . lWorld . walls . ix wlid . wlMaterial
|
||||||
|
|
||||||
makeBlockDebris :: Block -> World -> World
|
makeBlockDebris :: Block -> World -> World
|
||||||
@@ -44,33 +44,39 @@ makeBlockDebris bl w = foldl' (flip $ makeDebris mt) w ps
|
|||||||
wl <- w ^? cWorld . lWorld . walls . ix wlid
|
wl <- w ^? cWorld . lWorld . walls . ix wlid
|
||||||
return $ _wlMaterial wl
|
return $ _wlMaterial wl
|
||||||
|
|
||||||
--makeDebris :: Material -> Color -> Point2 -> World -> World
|
-- makeDebris :: Material -> Color -> Point2 -> World -> World
|
||||||
makeDebris :: Material -> Point2 -> World -> World
|
makeDebris :: Material -> Point2 -> World -> World
|
||||||
makeDebris = makeDebrisDirected (2 * pi) 0
|
makeDebris = makeDebrisDirected (2 * pi) 0
|
||||||
|
|
||||||
makeDebrisDirected :: Float -> Float -> Material -> Point2 -> World -> World
|
makeDebrisDirected :: Float -> Float -> Material -> Point2 -> World -> World
|
||||||
--makeDebrisDirected :: Float -> Float -> Material -> Color -> Point2 -> World -> World
|
-- makeDebrisDirected :: Float -> Float -> Material -> Color -> Point2 -> World -> World
|
||||||
--makeDebrisDirected arcrad dir bm col p w =
|
-- makeDebrisDirected arcrad dir bm col p w =
|
||||||
makeDebrisDirected arcrad dir bm p w =
|
makeDebrisDirected arcrad dir bm p w =
|
||||||
w
|
w
|
||||||
-- & flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
|
-- & flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
|
||||||
& cWorld . lWorld . debris <>~ thedebris
|
& cWorld
|
||||||
& randGen .~ newg
|
. lWorld
|
||||||
|
. debris
|
||||||
|
<>~ thedebris
|
||||||
|
& randGen
|
||||||
|
.~ newg
|
||||||
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
|
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
|
||||||
where
|
where
|
||||||
(thedebris, newg) = mapM f [35, 55, 75, 95] & runState $ _randGen w
|
(thedebris, newg) = mapM f [35, 55, 75, 95] & runState $ _randGen w
|
||||||
f h = do
|
f h = do
|
||||||
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip 1 2 arcrad
|
v <- rotateV (dir - arcrad / 2) <$> randInArcStrip 1 2 arcrad
|
||||||
spinspeed <- randomR (-0.2, -0.1) & state
|
spinspeed <- randomR (-0.2, -0.1) & state
|
||||||
-- basedebris <- baseDebris bm
|
-- basedebris <- baseDebris bm
|
||||||
return $ DebrisChunk
|
return $
|
||||||
{ _dbPos = p `v2z` h
|
DebrisChunk
|
||||||
-- , _dbType = BlockDebris col
|
{ _dbPos = p `v2z` h
|
||||||
, _dbType = BlockDebris (materialColor bm)
|
, -- , _dbType = BlockDebris col
|
||||||
, _dbVel = v `v2z` 0
|
_dbType = BlockDebris (materialColor bm)
|
||||||
, _dbRot = Q.qID
|
, _dbVel = v `v2z` 0
|
||||||
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) spinspeed
|
, _dbRot = Q.qID
|
||||||
}
|
, _dbSpin = Q.axisAngle (vNormal v `v2z` 0) spinspeed
|
||||||
|
}
|
||||||
|
|
||||||
-- basedebris
|
-- basedebris
|
||||||
-- & prColor .~ col
|
-- & prColor .~ col
|
||||||
-- & prPos .~ p
|
-- & prPos .~ p
|
||||||
@@ -91,9 +97,13 @@ debrisSize mt = case mt of
|
|||||||
Electronics -> 10
|
Electronics -> 10
|
||||||
Flesh -> 10
|
Flesh -> 10
|
||||||
ForceField -> 10
|
ForceField -> 10
|
||||||
|
Photovoltaic -> 10
|
||||||
|
LightningRod -> 10
|
||||||
|
Pyroelectric -> 10
|
||||||
|
Piezoelectric -> 10
|
||||||
|
|
||||||
--shardShape :: Float -> Shape
|
-- shardShape :: Float -> Shape
|
||||||
--shardShape size =
|
-- shardShape size =
|
||||||
-- translateSHz (- size) $
|
-- translateSHz (- size) $
|
||||||
-- upperPrismPolySU
|
-- upperPrismPolySU
|
||||||
-- size
|
-- size
|
||||||
@@ -102,10 +112,10 @@ debrisSize mt = case mt of
|
|||||||
-- , V2 (- size) (-1)
|
-- , V2 (- size) (-1)
|
||||||
-- ]
|
-- ]
|
||||||
--
|
--
|
||||||
--jaggedShape :: State StdGen Shape
|
-- jaggedShape :: State StdGen Shape
|
||||||
--jaggedShape = do
|
-- jaggedShape = do
|
||||||
-- s <- randomR (4, 10) & state
|
-- s <- randomR (4, 10) & state
|
||||||
-- return $ shardShape s
|
-- return $ shardShape s
|
||||||
|
|
||||||
cubeShape :: Float -> Shape
|
cubeShape :: Float -> Shape
|
||||||
cubeShape size = translateSHz (- size) $ upperPrismPolySU (2 * size) $ square size
|
cubeShape size = translateSHz (-size) $ upperPrismPolySU (2 * size) $ square size
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ itemCombinations =
|
|||||||
-- , po [HELD LASGUN, HELD LASGUN, cr HARDWARE] dualBeam
|
-- , po [HELD LASGUN, HELD LASGUN, cr HARDWARE] dualBeam
|
||||||
-- , po [HELD LASGUN, cr TRANSFORMER] (lasWide 2)
|
-- , po [HELD LASGUN, cr TRANSFORMER] (lasWide 2)
|
||||||
-- , po [HELD LASGUN, HELD LASGUN, HELD LASGUN, cr HARDWARE] lasCircle
|
-- , po [HELD LASGUN, HELD LASGUN, HELD LASGUN, cr HARDWARE] lasCircle
|
||||||
, p [o $ cr TRANSFORMER, p 2 $ cr CAN] sparkGun
|
, p [o $ cr TRANSFORMER, p 2 $ cr CAN] teslaCoil
|
||||||
, p [o (HELD SPARKGUN), p 2 $ cr PIPE] teslaGun
|
|
||||||
-- , p [o $ cr TELEPORTMODULE, p 2 $ cr MICROCHIP] blinker
|
-- , p [o $ cr TELEPORTMODULE, p 2 $ cr MICROCHIP] blinker
|
||||||
, p [o $ HELD BLINKER, p 2 $ cr MICROCHIP] unsafeBlinker
|
, p [o $ HELD BLINKER, p 2 $ cr MICROCHIP] unsafeBlinker
|
||||||
, po [cr MAGNET, cr TIN] (magShield MagnetRepulse)
|
, po [cr MAGNET, cr TIN] (magShield MagnetRepulse)
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ inventoryX c = case c of
|
|||||||
[introScan t | t <- [minBound..maxBound]] <>
|
[introScan t | t <- [minBound..maxBound]] <>
|
||||||
[ flameThrower
|
[ flameThrower
|
||||||
, chemFuelPouch
|
, chemFuelPouch
|
||||||
|
, makeTypeCraft PUMP
|
||||||
, fuelPack
|
, fuelPack
|
||||||
, copier ABSOLUTE
|
, copier ABSOLUTE
|
||||||
, nulgate
|
, nulgate
|
||||||
@@ -344,7 +345,7 @@ stackedInventory =
|
|||||||
, megaBattery
|
, megaBattery
|
||||||
, capacitor
|
, capacitor
|
||||||
, makeTypeCraft TRANSFORMER
|
, makeTypeCraft TRANSFORMER
|
||||||
, teslaGun
|
, teslaCoil
|
||||||
, megaBattery
|
, megaBattery
|
||||||
, flameThrower
|
, flameThrower
|
||||||
, chemFuelPouch
|
, chemFuelPouch
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ useItemLoc cr loc pt w
|
|||||||
| LaserWeaponSF <- sf = True
|
| LaserWeaponSF <- sf = True
|
||||||
| HeldPlatformSF <- sf = True
|
| HeldPlatformSF <- sf = True
|
||||||
| PulseBallSF <- sf = True
|
| PulseBallSF <- sf = True
|
||||||
|
| PlasmaSF <- sf = True
|
||||||
| UnderBarrelPlatformSF <- sf = True
|
| UnderBarrelPlatformSF <- sf = True
|
||||||
| otherwise = False
|
| otherwise = False
|
||||||
sf = loc ^. locDT . dtValue . _2
|
sf = loc ^. locDT . dtValue . _2
|
||||||
|
|||||||
@@ -106,8 +106,7 @@ heldItemWeight = \case
|
|||||||
FLAMETORRENT -> 10
|
FLAMETORRENT -> 10
|
||||||
FLAMEWALL -> 10
|
FLAMEWALL -> 10
|
||||||
BLOWTORCH -> 10
|
BLOWTORCH -> 10
|
||||||
SPARKGUN -> 15
|
TESLACOIL -> 15
|
||||||
TESLAGUN -> 15
|
|
||||||
TRACTORGUN -> 10
|
TRACTORGUN -> 10
|
||||||
RLAUNCHER -> 20
|
RLAUNCHER -> 20
|
||||||
RLAUNCHERX{} -> 20
|
RLAUNCHERX{} -> 20
|
||||||
|
|||||||
@@ -220,8 +220,7 @@ heldItemBulkiness = \case
|
|||||||
FLAMETORRENT -> 1
|
FLAMETORRENT -> 1
|
||||||
FLAMEWALL -> 1
|
FLAMEWALL -> 1
|
||||||
BLOWTORCH -> 1
|
BLOWTORCH -> 1
|
||||||
SPARKGUN -> 1
|
TESLACOIL -> 1
|
||||||
TESLAGUN -> 1
|
|
||||||
TRACTORGUN -> 1
|
TRACTORGUN -> 1
|
||||||
RLAUNCHER -> 0.9
|
RLAUNCHER -> 0.9
|
||||||
RLAUNCHERX{} -> 0.9
|
RLAUNCHERX{} -> 0.9
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ data ItemSF -- Structural Function
|
|||||||
| CapacitorSF
|
| CapacitorSF
|
||||||
| TransformerSF
|
| TransformerSF
|
||||||
| PulseBallSF
|
| PulseBallSF
|
||||||
|
| PlasmaSF
|
||||||
| TorchSF
|
| TorchSF
|
||||||
|
| PumpSF
|
||||||
deriving (Eq, Ord, Show, Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
|
|
||||||
type CItem = (Item, ItemSF)
|
type CItem = (Item, ItemSF)
|
||||||
|
|||||||
@@ -5,11 +5,6 @@
|
|||||||
module Dodge.Data.DoubleTree where
|
module Dodge.Data.DoubleTree where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
--import Data.Aeson
|
|
||||||
--import Data.Aeson.TH
|
|
||||||
import Data.Bifunctor
|
|
||||||
|
|
||||||
--import qualified Data.Map.Strict as M
|
|
||||||
|
|
||||||
data DoubleTreeNodeType
|
data DoubleTreeNodeType
|
||||||
= DTRootNode
|
= DTRootNode
|
||||||
@@ -18,67 +13,15 @@ data DoubleTreeNodeType
|
|||||||
| DTMidBelowNode
|
| DTMidBelowNode
|
||||||
| DTBottomNode
|
| DTBottomNode
|
||||||
|
|
||||||
-- for each child, records the link type to the father node
|
|
||||||
data LabelDoubleTreeNodeType a
|
|
||||||
= LDTRootNode
|
|
||||||
| LDTTopNode a
|
|
||||||
| LDTMidAboveNode a
|
|
||||||
| LDTMidBelowNode a
|
|
||||||
| LDTBottomNode a
|
|
||||||
|
|
||||||
data DTree a = DT {_dtValue :: a, _dtLeft :: [DTree a], _dtRight :: [DTree a]}
|
data DTree a = DT {_dtValue :: a, _dtLeft :: [DTree a], _dtRight :: [DTree a]}
|
||||||
deriving (Eq, Ord, Show, Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
|
|
||||||
data LDTree b a = LDT -- LabelDoubleTree
|
|
||||||
{ _ldtValue :: a
|
|
||||||
, _ldtLeft :: [(b, LDTree b a)]
|
|
||||||
, _ldtRight :: [(b, LDTree b a)]
|
|
||||||
}
|
|
||||||
deriving (Eq, Ord, Show, Read)
|
|
||||||
|
|
||||||
-- I am not sure about the double use of records here
|
|
||||||
data ContextLDT b a
|
|
||||||
= TopLDT
|
|
||||||
| LeftwardLDT
|
|
||||||
{ _cldtUp :: ContextLDT b a
|
|
||||||
, _cldtCloseLeft :: [(b, LDTree b a)]
|
|
||||||
, _cldtParent :: a
|
|
||||||
, _cldtLink :: b
|
|
||||||
, _cldtCloseRight :: [(b, LDTree b a)]
|
|
||||||
, _cldtFarRight :: [(b, LDTree b a)]
|
|
||||||
}
|
|
||||||
| RightwardLDT
|
|
||||||
{ _cldtUp :: ContextLDT b a
|
|
||||||
, _cldtFarLeft :: [(b, LDTree b a)]
|
|
||||||
, _cldtCloseLeft :: [(b, LDTree b a)]
|
|
||||||
, _cldtParent :: a
|
|
||||||
, _cldtLink :: b
|
|
||||||
, _cldtCloseRight :: [(b, LDTree b a)]
|
|
||||||
}
|
|
||||||
|
|
||||||
data LocationLDT b a = LocLDT
|
|
||||||
{ _locLdtContext :: ContextLDT b a
|
|
||||||
, _locLDT :: LDTree b a
|
|
||||||
}
|
|
||||||
|
|
||||||
instance Functor DTree where
|
instance Functor DTree where
|
||||||
fmap f (DT x l r) = DT (f x) (fmap (fmap f) l) (fmap (fmap f) r)
|
fmap f (DT x l r) = DT (f x) (fmap (fmap f) l) (fmap (fmap f) r)
|
||||||
|
|
||||||
instance Foldable DTree where
|
instance Foldable DTree where
|
||||||
foldMap f (DT x l r) = foldMap (foldMap f) l <> f x <> foldMap (foldMap f) r
|
foldMap f (DT x l r) = foldMap (foldMap f) l <> f x <> foldMap (foldMap f) r
|
||||||
|
|
||||||
instance Functor (LDTree b) where
|
|
||||||
fmap f (LDT x l r) = LDT (f x) (fmap (second $ fmap f) l) (fmap (second $ fmap f) r)
|
|
||||||
|
|
||||||
instance Bifunctor LDTree where
|
|
||||||
second = fmap
|
|
||||||
first f (LDT x l r) =
|
|
||||||
LDT
|
|
||||||
x
|
|
||||||
(map (bimap f (first f)) l)
|
|
||||||
(map (bimap f (first f)) r)
|
|
||||||
|
|
||||||
|
|
||||||
data ContextDT a
|
data ContextDT a
|
||||||
= TopDT
|
= TopDT
|
||||||
| LeftwardDT
|
| LeftwardDT
|
||||||
@@ -102,35 +45,12 @@ data LocationDT a = LocDT
|
|||||||
}
|
}
|
||||||
|
|
||||||
makeLenses ''DTree
|
makeLenses ''DTree
|
||||||
makeLenses ''LDTree
|
|
||||||
makeLenses ''LocationLDT
|
|
||||||
makeLenses ''ContextLDT
|
|
||||||
makeLenses ''LocationDT
|
makeLenses ''LocationDT
|
||||||
makeLenses ''ContextDT
|
makeLenses ''ContextDT
|
||||||
|
|
||||||
instance Functor (LocationLDT b) where
|
|
||||||
fmap f (LocLDT c t) = LocLDT (fmap f c) (fmap f t)
|
|
||||||
|
|
||||||
instance Functor LocationDT where
|
instance Functor LocationDT where
|
||||||
fmap f (LocDT c t) = LocDT (fmap f c) (fmap f t)
|
fmap f (LocDT c t) = LocDT (fmap f c) (fmap f t)
|
||||||
|
|
||||||
instance Functor (ContextLDT b) where
|
|
||||||
fmap f = \case
|
|
||||||
TopLDT -> TopLDT
|
|
||||||
LeftwardLDT u cl p l cr fr -> LeftwardLDT
|
|
||||||
(fmap f u)
|
|
||||||
(fmap (fmap (fmap f)) cl)
|
|
||||||
(f p)
|
|
||||||
l
|
|
||||||
(fmap (fmap (fmap f)) cr)
|
|
||||||
(fmap (fmap (fmap f)) fr)
|
|
||||||
RightwardLDT u fl cl p l cr -> RightwardLDT (fmap f u)
|
|
||||||
(fmap (fmap (fmap f)) fl)
|
|
||||||
(fmap (fmap (fmap f)) cl)
|
|
||||||
(f p)
|
|
||||||
l
|
|
||||||
(fmap (fmap (fmap f)) cr)
|
|
||||||
|
|
||||||
instance Functor ContextDT where
|
instance Functor ContextDT where
|
||||||
fmap f = \case
|
fmap f = \case
|
||||||
TopDT -> TopDT
|
TopDT -> TopDT
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import System.Random
|
|||||||
data GenWorld = GenWorld
|
data GenWorld = GenWorld
|
||||||
{ _gwWorld :: World
|
{ _gwWorld :: World
|
||||||
, _genRooms :: IM.IntMap Room
|
, _genRooms :: IM.IntMap Room
|
||||||
, _genPmnt :: IM.IntMap Placement
|
, _genPmnt :: IM.IntMap Placement -- stored generated placements
|
||||||
, _genInts :: IM.IntMap Int
|
, _genInts :: IM.IntMap Int
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +100,8 @@ data PlacementSpot
|
|||||||
| PSNoShiftCont {_psPos :: Point2, _psRot :: Float}
|
| PSNoShiftCont {_psPos :: Point2, _psRot :: Float}
|
||||||
| PSPos
|
| PSPos
|
||||||
{ _psSelect :: RoomPos -> Room -> Maybe (PlacementSpot, RoomPos)
|
{ _psSelect :: RoomPos -> Room -> Maybe (PlacementSpot, RoomPos)
|
||||||
|
-- looks for the first rp for which a rp rm returns Just (ps,rp'),
|
||||||
|
-- replaces the rp with rp'
|
||||||
, _psRoomEff :: RoomPos -> Room -> Room
|
, _psRoomEff :: RoomPos -> Room -> Room
|
||||||
, _psFallback :: Maybe Placement
|
, _psFallback :: Maybe Placement
|
||||||
}
|
}
|
||||||
@@ -138,7 +140,8 @@ data Room = Room
|
|||||||
, _rmPos :: [RoomPos]
|
, _rmPos :: [RoomPos]
|
||||||
, _rmPath :: S.Set (Point2, Point2)
|
, _rmPath :: S.Set (Point2, Point2)
|
||||||
, _rmPmnts :: [Placement]
|
, _rmPmnts :: [Placement]
|
||||||
, _rmInPmnt :: [(Int,GenWorld -> Placement)]
|
, _rmInPmnt :: [(Int,GenWorld -> State StdGen Placement)] -- so far as I can tell,
|
||||||
|
-- the first Int only determines the order in which these are applied
|
||||||
, _rmBound :: [[Point2]]
|
, _rmBound :: [[Point2]]
|
||||||
, _rmFloor :: Floor
|
, _rmFloor :: Floor
|
||||||
, _rmName :: String
|
, _rmName :: String
|
||||||
@@ -161,3 +164,12 @@ makeLenses ''RoomType
|
|||||||
makeLenses ''PSType
|
makeLenses ''PSType
|
||||||
makeLenses ''PlacementSpot
|
makeLenses ''PlacementSpot
|
||||||
makeLenses ''Placement
|
makeLenses ''Placement
|
||||||
|
|
||||||
|
-- I may regret this. I believe it satisfies associativity, but haven't thought
|
||||||
|
-- about it too much.
|
||||||
|
instance Semigroup Placement where
|
||||||
|
p <> q = p & plIDCont %~ f
|
||||||
|
where
|
||||||
|
f g gw pl = case g gw pl of
|
||||||
|
Nothing -> Just q
|
||||||
|
Just r -> Just $ r & plIDCont %~ f
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ data AttachType
|
|||||||
| HOMINGMODULE
|
| HOMINGMODULE
|
||||||
| SHELLPAYLOAD {_shellPayload :: Payload}
|
| SHELLPAYLOAD {_shellPayload :: Payload}
|
||||||
| CAPACITOR
|
| CAPACITOR
|
||||||
|
| COMPRESSOR
|
||||||
deriving (Eq, Ord, Show, Read)
|
deriving (Eq, Ord, Show, Read)
|
||||||
|
|
||||||
data AmmoMagType
|
data AmmoMagType
|
||||||
@@ -163,8 +164,7 @@ data HeldItemType
|
|||||||
| FLAMETORRENT
|
| FLAMETORRENT
|
||||||
| FLAMEWALL
|
| FLAMEWALL
|
||||||
| BLOWTORCH
|
| BLOWTORCH
|
||||||
| SPARKGUN
|
| TESLACOIL
|
||||||
| TESLAGUN
|
|
||||||
| TRACTORGUN
|
| TRACTORGUN
|
||||||
| RLAUNCHER
|
| RLAUNCHER
|
||||||
| RLAUNCHERX {_xNum :: Int}
|
| RLAUNCHERX {_xNum :: Int}
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ data Material
|
|||||||
| Flesh
|
| Flesh
|
||||||
| Electronics
|
| Electronics
|
||||||
| ForceField
|
| ForceField
|
||||||
|
| Photovoltaic
|
||||||
|
| LightningRod
|
||||||
|
| Pyroelectric
|
||||||
|
| Piezoelectric
|
||||||
deriving (Eq, Ord, Show, Bounded, Enum, Read) --Generic, Flat)
|
deriving (Eq, Ord, Show, Bounded, Enum, Read) --Generic, Flat)
|
||||||
|
|
||||||
deriveJSON defaultOptions ''Material
|
deriveJSON defaultOptions ''Material
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ data MuzzleEffect
|
|||||||
| MuzzleLaser
|
| MuzzleLaser
|
||||||
| MuzzlePulseLaser
|
| MuzzlePulseLaser
|
||||||
| MuzzlePulseBall
|
| MuzzlePulseBall
|
||||||
|
| MuzzlePlasmaBall
|
||||||
| MuzzleTesla
|
| MuzzleTesla
|
||||||
| MuzzleTractor
|
| MuzzleTractor
|
||||||
| MuzzleRLauncher
|
| MuzzleRLauncher
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ data RoomType
|
|||||||
, _rmWidth :: Float
|
, _rmWidth :: Float
|
||||||
, _rmHeight :: Float
|
, _rmHeight :: Float
|
||||||
}
|
}
|
||||||
|
| RoomNgon
|
||||||
|
{ _rmngonSides :: Int
|
||||||
|
, _rmngonSize :: Float
|
||||||
|
}
|
||||||
deriving (Eq, Ord)
|
deriving (Eq, Ord)
|
||||||
|
|
||||||
data RoomLinkType
|
data RoomLinkType
|
||||||
@@ -80,6 +84,8 @@ data PathFromEdge = PathFromEdge CardinalPoint Int
|
|||||||
data RoomPosFlag
|
data RoomPosFlag
|
||||||
= RoomPosOnGrid {_onGridFromEdges :: S.Set PathFromEdge}
|
= RoomPosOnGrid {_onGridFromEdges :: S.Set PathFromEdge}
|
||||||
| RoomPosOffGrid {_offGridFromEdges :: S.Set PathFromEdge}
|
| RoomPosOffGrid {_offGridFromEdges :: S.Set PathFromEdge}
|
||||||
|
| RoomPosOnFloor
|
||||||
|
| ColoredLightRP
|
||||||
deriving (Eq, Ord, Show)
|
deriving (Eq, Ord, Show)
|
||||||
|
|
||||||
data UsedPos
|
data UsedPos
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@ module Dodge.Debug (debugEvents, drawDebug) where
|
|||||||
|
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Dodge.Render.Label
|
import Dodge.Render.Label
|
||||||
import Dodge.Data.DoubleTree
|
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
import Dodge.DoubleTree
|
import Dodge.DoubleTree
|
||||||
import Dodge.Item.Grammar
|
import Dodge.Item.Grammar
|
||||||
@@ -260,7 +259,7 @@ showMuzzlePositions u = fold $ do
|
|||||||
^? ix invid . _2
|
^? ix invid . _2
|
||||||
return . color red $ setLayer DebugLayer $ reduceLocDT (f cr) loc
|
return . color red $ setLayer DebugLayer $ reduceLocDT (f cr) loc
|
||||||
where
|
where
|
||||||
f cr loc = foldMap (g . muzzlePos loc cr) (itemMuzzles $ loc ^. locDT . dtValue . _1)
|
f cr loc = foldMap (g . muzzlePos loc cr) (itemMuzzles $ loc)
|
||||||
where
|
where
|
||||||
g :: Point3Q -> Picture
|
g :: Point3Q -> Picture
|
||||||
g pq = translate3 (pq ^. _1) $ crossPic 5
|
g pq = translate3 (pq ^. _1) $ crossPic 5
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ updateDisplaySections w cfig =
|
|||||||
(sfclose, sclose) =
|
(sfclose, sclose) =
|
||||||
filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $
|
filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $
|
||||||
w ^? hud . diCloseFilter . _Just
|
w ^? hud . diCloseFilter . _Just
|
||||||
interfaceshead = if null btitems then mempty else makehead "NEARBY INTERFACES"
|
interfaceshead = if null btitems then mempty else makehead "INTERFACES"
|
||||||
btitems =
|
btitems =
|
||||||
IM.fromDistinctAscList . zip [0 ..] $
|
IM.fromDistinctAscList . zip [0 ..] $
|
||||||
mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons)
|
mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons)
|
||||||
|
|||||||
+1
-219
@@ -1,40 +1,13 @@
|
|||||||
{-# LANGUAGE LambdaCase #-}
|
|
||||||
module Dodge.DoubleTree where
|
module Dodge.DoubleTree where
|
||||||
|
|
||||||
import Dodge.Data.DoubleTree
|
import Dodge.Data.DoubleTree
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Bifunctor
|
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
|
||||||
singleDT :: a -> DTree a
|
singleDT :: a -> DTree a
|
||||||
singleDT x = DT x [] []
|
singleDT x = DT x [] []
|
||||||
|
|
||||||
singleLDT :: a -> LDTree b a
|
|
||||||
singleLDT x = LDT x [] []
|
|
||||||
|
|
||||||
ldtToDT :: LDTree b a -> DTree a
|
|
||||||
ldtToDT (LDT x l r) = DT x (map (ldtToDT . snd) l) (map (ldtToDT . snd) r)
|
|
||||||
|
|
||||||
locLDTToLocDT :: LocationLDT b a -> LocationDT a
|
|
||||||
locLDTToLocDT (LocLDT con t) = LocDT (conLDTToConDT con) (ldtToDT t)
|
|
||||||
|
|
||||||
conLDTToConDT :: ContextLDT b a -> ContextDT a
|
|
||||||
conLDTToConDT = \case
|
|
||||||
TopLDT -> TopDT
|
|
||||||
LeftwardLDT u cl p _ cr fr -> LeftwardDT
|
|
||||||
(conLDTToConDT u)
|
|
||||||
(map (ldtToDT . snd) cl)
|
|
||||||
p
|
|
||||||
(map (ldtToDT . snd) cr)
|
|
||||||
(map (ldtToDT . snd) fr)
|
|
||||||
RightwardLDT u fl cl p _ cr -> RightwardDT
|
|
||||||
(conLDTToConDT u)
|
|
||||||
(map (ldtToDT . snd) fl)
|
|
||||||
(map (ldtToDT . snd) cl)
|
|
||||||
p
|
|
||||||
(map (ldtToDT . snd) cr)
|
|
||||||
|
|
||||||
dtStartPropagate :: (a -> c) -> (c -> a -> c) -> DTree a -> DTree c
|
dtStartPropagate :: (a -> c) -> (c -> a -> c) -> DTree a -> DTree c
|
||||||
dtStartPropagate g f (DT x l r) = DT z
|
dtStartPropagate g f (DT x l r) = DT z
|
||||||
(fmap (dtPropagate' f z) l)
|
(fmap (dtPropagate' f z) l)
|
||||||
@@ -49,80 +22,6 @@ dtPropagate' f x (DT y l r) = DT z
|
|||||||
where
|
where
|
||||||
z = f x y
|
z = f x y
|
||||||
|
|
||||||
ldtStartPropagate :: (a -> c) -> (c -> b -> a -> c) -> LDTree b a -> LDTree b c
|
|
||||||
ldtStartPropagate g f (LDT x l r) = LDT z
|
|
||||||
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) l)
|
|
||||||
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) r)
|
|
||||||
where
|
|
||||||
z = g x
|
|
||||||
|
|
||||||
|
|
||||||
ldtPropagate' :: c -> b -> (c -> b -> a -> c) -> LDTree b a -> LDTree b c
|
|
||||||
ldtPropagate' x i f (LDT y l r) = LDT z
|
|
||||||
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) l)
|
|
||||||
(fmap (\(j,t) -> (j,ldtPropagate' z j f t)) r)
|
|
||||||
where
|
|
||||||
z = f x i y
|
|
||||||
|
|
||||||
-- propagate two functions down the links of an LDT tree
|
|
||||||
-- which function is chosen depends on whether it is a left or right branch
|
|
||||||
ldtPropagate ::
|
|
||||||
(c -> b -> c) ->
|
|
||||||
(c -> b -> c) ->
|
|
||||||
c ->
|
|
||||||
LDTree b a ->
|
|
||||||
LDTree c a
|
|
||||||
ldtPropagate lf rf = ildtPropagate (const lf) (const rf)
|
|
||||||
|
|
||||||
-- Propgates a value (of type c) down the branches of the LDT.
|
|
||||||
-- The value is updated according a "left" or "right" function (lf or rf),
|
|
||||||
-- that acts on the parent value, the link, and the child value.
|
|
||||||
-- For each node, the updated value is used to update a final value (of type d).
|
|
||||||
ldtPropagateFold ::
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> a -> d -> d) ->
|
|
||||||
c ->
|
|
||||||
LDTree b a ->
|
|
||||||
d ->
|
|
||||||
d
|
|
||||||
ldtPropagateFold lf rf up x (LDT v l r) =
|
|
||||||
alaf Endo foldMap (\(s, y) -> ldtPropagateFold lf rf up (rf x v s (_ldtValue y)) y) r
|
|
||||||
. alaf Endo foldMap (\(s, y) -> ldtPropagateFold lf rf up (lf x v s (_ldtValue y)) y) l
|
|
||||||
. up x v
|
|
||||||
|
|
||||||
-- Propgates a value (of type c) down the branches of the LDT.
|
|
||||||
-- The value is updated according a "left" or "right" function (lf or rf),
|
|
||||||
-- that acts on the parent value, the link, and the child value.
|
|
||||||
-- For each node-tree, the updated value is used to update a final value (of type d).
|
|
||||||
ldtPropagateFoldTree ::
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> LDTree b a -> d -> d) ->
|
|
||||||
c ->
|
|
||||||
LDTree b a ->
|
|
||||||
d ->
|
|
||||||
d
|
|
||||||
ldtPropagateFoldTree lf rf up x t@(LDT v l r) =
|
|
||||||
alaf Endo foldMap (\(s, y) -> ldtPropagateFoldTree lf rf up (rf x v s (_ldtValue y)) y) r
|
|
||||||
. alaf Endo foldMap (\(s, y) -> ldtPropagateFoldTree lf rf up (lf x v s (_ldtValue y)) y) l
|
|
||||||
. up x t
|
|
||||||
|
|
||||||
ildtPropagate ::
|
|
||||||
(Int -> c -> b -> c) ->
|
|
||||||
(Int -> c -> b -> c) ->
|
|
||||||
c ->
|
|
||||||
LDTree b a ->
|
|
||||||
LDTree c a
|
|
||||||
ildtPropagate lf rf x (LDT v l r) = LDT v (imap (go lf x) l) (imap (go rf x) r)
|
|
||||||
where
|
|
||||||
go f y i (z, t) = (f i y z, ildtPropagate lf rf (f i y z) t)
|
|
||||||
|
|
||||||
ldtPropagateIndices :: LDTree b a -> LDTree b (a, [Either Int Int])
|
|
||||||
ldtPropagateIndices (LDT x l r) = LDT (x, []) (imap (f Left) l) (imap (f Right) r)
|
|
||||||
where
|
|
||||||
f e i (y, t) = (y, second (e i :) <$> ldtPropagateIndices t)
|
|
||||||
|
|
||||||
-- conceptually, in a tree growing from left to right,
|
-- conceptually, in a tree growing from left to right,
|
||||||
-- bottom -> top is equated with left -> right.
|
-- bottom -> top is equated with left -> right.
|
||||||
-- this does not match with thinking of a list as top -> bottom, so take care
|
-- this does not match with thinking of a list as top -> bottom, so take care
|
||||||
@@ -216,36 +115,6 @@ dtToAdjRootParentEither root par f (DT x l r) = do
|
|||||||
where
|
where
|
||||||
g = f . _dtValue
|
g = f . _dtValue
|
||||||
|
|
||||||
ldtToIM :: (a -> Int) -> LDTree b a -> IM.IntMap (LDTree b a)
|
|
||||||
ldtToIM f t@(LDT x l r) = IM.insert (f x) t $ IM.unions $ map (ldtToIM f . snd) $ l <> r
|
|
||||||
|
|
||||||
ldtToIndentList :: LDTree b a -> [(a, Int, LabelDoubleTreeNodeType b)]
|
|
||||||
ldtToIndentList = ldtIL LDTRootNode
|
|
||||||
|
|
||||||
ldtIL :: LabelDoubleTreeNodeType b -> LDTree b a -> [(a, Int, LabelDoubleTreeNodeType b)]
|
|
||||||
ldtIL nt (LDT x l r) =
|
|
||||||
map
|
|
||||||
doindent
|
|
||||||
( concat
|
|
||||||
( headMap
|
|
||||||
(\(lab, c) -> ldtIL (LDTBottomNode lab) c)
|
|
||||||
(\(lab, c) -> ldtIL (LDTMidBelowNode lab) c)
|
|
||||||
l
|
|
||||||
)
|
|
||||||
)
|
|
||||||
++ [(x, 0, nt)]
|
|
||||||
++ map
|
|
||||||
doindent
|
|
||||||
( concat
|
|
||||||
( lastMap
|
|
||||||
(\(lab, c) -> ldtIL (LDTTopNode lab) c)
|
|
||||||
(\(lab, c) -> ldtIL (LDTMidAboveNode lab) c)
|
|
||||||
r
|
|
||||||
)
|
|
||||||
)
|
|
||||||
where
|
|
||||||
doindent (a, b, c) = (a, b + 1, c)
|
|
||||||
|
|
||||||
headMap :: (a -> b) -> (a -> b) -> [a] -> [b]
|
headMap :: (a -> b) -> (a -> b) -> [a] -> [b]
|
||||||
headMap f g (x : xs) = f x : map g xs
|
headMap f g (x : xs) = f x : map g xs
|
||||||
headMap _ _ [] = []
|
headMap _ _ [] = []
|
||||||
@@ -260,31 +129,6 @@ prettyDT f (DT x l r) =
|
|||||||
concatMap (map ('/' :) . prettyDT f) r
|
concatMap (map ('/' :) . prettyDT f) r
|
||||||
++ (f x : concatMap (map ('\\' :) . prettyDT f) l)
|
++ (f x : concatMap (map ('\\' :) . prettyDT f) l)
|
||||||
|
|
||||||
prettyLDT :: (a -> String) -> LDTree b a -> [String]
|
|
||||||
prettyLDT f (LDT x l r) =
|
|
||||||
concatMap (map ('/' :) . prettyLDT f . snd) r
|
|
||||||
++ (f x : concatMap (map ('\\' :) . prettyLDT f . snd) l)
|
|
||||||
|
|
||||||
ldtToLoc :: LDTree b a -> LocationLDT b a
|
|
||||||
ldtToLoc = LocLDT TopLDT
|
|
||||||
|
|
||||||
-- should probably do tests for these
|
|
||||||
locUp :: LocationLDT b a -> Maybe (LocationLDT b a)
|
|
||||||
locUp (LocLDT TopLDT _) = Nothing
|
|
||||||
locUp (LocLDT c@LeftwardLDT{} t) =
|
|
||||||
Just $
|
|
||||||
LocLDT
|
|
||||||
(_cldtUp c)
|
|
||||||
(LDT (_cldtParent c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)) (_cldtFarRight c))
|
|
||||||
locUp (LocLDT c@RightwardLDT{} t) =
|
|
||||||
Just $
|
|
||||||
LocLDT
|
|
||||||
(_cldtUp c)
|
|
||||||
(LDT (_cldtParent c) (_cldtFarLeft c) (_cldtCloseLeft c ++ ((_cldtLink c, t) : _cldtCloseRight c)))
|
|
||||||
|
|
||||||
--locToTop :: LocationLDT b a -> LocationLDT b a
|
|
||||||
--locToTop loc = maybe loc locToTop $ locUp loc
|
|
||||||
|
|
||||||
locUp' :: LocationDT a -> Maybe (LocationDT a)
|
locUp' :: LocationDT a -> Maybe (LocationDT a)
|
||||||
locUp' (LocDT TopDT _) = Nothing
|
locUp' (LocDT TopDT _) = Nothing
|
||||||
locUp' (LocDT c@LeftwardDT{} t) =
|
locUp' (LocDT c@LeftwardDT{} t) =
|
||||||
@@ -301,30 +145,12 @@ locUp' (LocDT c@RightwardDT{} t) =
|
|||||||
locToTop :: LocationDT a -> LocationDT a
|
locToTop :: LocationDT a -> LocationDT a
|
||||||
locToTop loc = maybe loc locToTop $ locUp' loc
|
locToTop loc = maybe loc locToTop $ locUp' loc
|
||||||
|
|
||||||
--locToTop = fix $ \x -> fromMaybe x $ locUp x
|
|
||||||
|
|
||||||
locLeftmost :: LocationLDT b a -> LocationLDT b a
|
|
||||||
locLeftmost loc = maybe loc locLeftmost $ alaf First foldMap Just $ locGoLeft loc
|
|
||||||
|
|
||||||
locRightmost :: LocationLDT b a -> LocationLDT b a
|
|
||||||
locRightmost loc = maybe loc locRightmost $ alaf Last foldMap Just $ locGoRight loc
|
|
||||||
|
|
||||||
locDTLeftmost :: LocationDT a -> LocationDT a
|
locDTLeftmost :: LocationDT a -> LocationDT a
|
||||||
locDTLeftmost loc = maybe loc locDTLeftmost $ alaf First foldMap Just $ locDTGoLeft loc
|
locDTLeftmost loc = maybe loc locDTLeftmost $ alaf First foldMap Just $ locDTGoLeft loc
|
||||||
|
|
||||||
locDTRightmost :: LocationDT a -> LocationDT a
|
locDTRightmost :: LocationDT a -> LocationDT a
|
||||||
locDTRightmost loc = maybe loc locDTRightmost $ alaf Last foldMap Just $ locDTGoRight loc
|
locDTRightmost loc = maybe loc locDTRightmost $ alaf Last foldMap Just $ locDTGoRight loc
|
||||||
|
|
||||||
-- should probably do tests for these
|
|
||||||
locGoLeft :: LocationLDT b a -> [LocationLDT b a]
|
|
||||||
locGoLeft (LocLDT c (LDT v l r)) =
|
|
||||||
[LocLDT (LeftwardLDT c closel v link closer r) t | (closel, (link, t), closer) <- locGoHelp id l]
|
|
||||||
|
|
||||||
-- should probably do tests for these
|
|
||||||
locGoRight :: LocationLDT b a -> [LocationLDT b a]
|
|
||||||
locGoRight (LocLDT c (LDT v l r)) =
|
|
||||||
[LocLDT (RightwardLDT c l closel v link closer) t | (closel, (link, t), closer) <- locGoHelp id r]
|
|
||||||
|
|
||||||
-- should probably do tests for these
|
-- should probably do tests for these
|
||||||
locDTGoLeft :: LocationDT a -> [LocationDT a]
|
locDTGoLeft :: LocationDT a -> [LocationDT a]
|
||||||
locDTGoLeft (LocDT c (DT v l r)) =
|
locDTGoLeft (LocDT c (DT v l r)) =
|
||||||
@@ -351,56 +177,12 @@ locDTGoHelp f = go []
|
|||||||
go cleft (y : ys) = (cleft, f y, ys) : go (cleft <> [y]) ys
|
go cleft (y : ys) = (cleft, f y, ys) : go (cleft <> [y]) ys
|
||||||
go _ [] = []
|
go _ [] = []
|
||||||
|
|
||||||
-- Propgates a value (of type c) down the branches of the ContextLDT.
|
|
||||||
-- The value is updated according a "left" or "right" function (lf or rf),
|
|
||||||
-- that acts on the parent value, the link, and the child value.
|
|
||||||
-- For each context node, the updated value is used to update a final value (of type d).
|
|
||||||
cldtPropagateFold ::
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> a -> b -> a -> c) ->
|
|
||||||
(c -> LocationLDT b a -> d -> d) ->
|
|
||||||
c ->
|
|
||||||
LocationLDT b a ->
|
|
||||||
d ->
|
|
||||||
d
|
|
||||||
cldtPropagateFold lf rf up x loc =
|
|
||||||
alaf
|
|
||||||
Endo
|
|
||||||
foldMap
|
|
||||||
( \(LocLDT con' t') ->
|
|
||||||
cldtPropagateFold
|
|
||||||
lf
|
|
||||||
rf
|
|
||||||
up
|
|
||||||
(lf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
|
||||||
(LocLDT con' t')
|
|
||||||
)
|
|
||||||
(locGoLeft loc)
|
|
||||||
. alaf
|
|
||||||
Endo
|
|
||||||
foldMap
|
|
||||||
( \(LocLDT con' t') ->
|
|
||||||
cldtPropagateFold
|
|
||||||
lf
|
|
||||||
rf
|
|
||||||
up
|
|
||||||
(rf x (_cldtParent con') (_cldtLink con') (_ldtValue t'))
|
|
||||||
(LocLDT con' t')
|
|
||||||
)
|
|
||||||
(locGoRight loc)
|
|
||||||
. up x loc
|
|
||||||
|
|
||||||
reduceLocLDT :: Monoid m => (LocationLDT b a -> m) -> LocationLDT b a -> m
|
|
||||||
reduceLocLDT f x =
|
|
||||||
foldMap (reduceLocLDT f) (locGoLeft x) <> f x
|
|
||||||
<> foldMap (reduceLocLDT f) (locGoRight x)
|
|
||||||
|
|
||||||
reduceLocDT :: Monoid m => (LocationDT a -> m) -> LocationDT a -> m
|
reduceLocDT :: Monoid m => (LocationDT a -> m) -> LocationDT a -> m
|
||||||
reduceLocDT f x =
|
reduceLocDT f x =
|
||||||
foldMap (reduceLocDT f) (locDTGoLeft x) <> f x
|
foldMap (reduceLocDT f) (locDTGoLeft x) <> f x
|
||||||
<> foldMap (reduceLocDT f) (locDTGoRight x)
|
<> foldMap (reduceLocDT f) (locDTGoRight x)
|
||||||
|
|
||||||
-- Propgates a value (of type c) down the branches of the ContextLDT.
|
-- Propgates a value (of type c) down the branches of the ContextDT.
|
||||||
-- The value is updated according a "left" or "right" function (lf or rf),
|
-- The value is updated according a "left" or "right" function (lf or rf),
|
||||||
-- that acts on the parent value and the child value.
|
-- that acts on the parent value and the child value.
|
||||||
-- For each context node, the updated value is used to update a final value (of type d).
|
-- For each context node, the updated value is used to update a final value (of type d).
|
||||||
|
|||||||
+4
-4
@@ -25,13 +25,13 @@ initialRoomTree =
|
|||||||
foldMTRS $
|
foldMTRS $
|
||||||
intersperse
|
intersperse
|
||||||
(zoom lyGen doorCor)
|
(zoom lyGen doorCor)
|
||||||
[ intAnno startRoom
|
[ startRoom
|
||||||
, passthroughLockKeyLists
|
, passthroughLockKeyLists
|
||||||
[(sensorRoomRunPast ElectricSensor, takeOne
|
[(sensorRoomRunPast ElectricSensor, takeOne
|
||||||
[-- CRAFT (ENERGYBALLCRAFT TeslaBall) ,
|
[-- CRAFT (ENERGYBALLCRAFT TeslaBall) ,
|
||||||
HELD SPARKGUN])]
|
HELD TESLACOIL])]
|
||||||
itemRooms
|
itemRooms
|
||||||
, intAnno lasSensorTurretTest
|
, lasSensorTurretTest
|
||||||
, -- , AnRoom $ tanksRoom [] [] <&> rmPmnts .~ []
|
, -- , AnRoom $ tanksRoom [] [] <&> rmPmnts .~ []
|
||||||
-- , AnRoom $ tanksRoom [] []
|
-- , AnRoom $ tanksRoom [] []
|
||||||
-- , AnRoom $ roomCCrits 0
|
-- , AnRoom $ roomCCrits 0
|
||||||
@@ -63,7 +63,7 @@ initialRoomTree =
|
|||||||
$ tanksRoom [] [] >>= rToOnward "empty tanksRoom" . pure . cleatOnward
|
$ tanksRoom [] [] >>= rToOnward "empty tanksRoom" . pure . cleatOnward
|
||||||
, passthroughLockKeyLists lockRoomKeyItems itemRooms
|
, passthroughLockKeyLists lockRoomKeyItems itemRooms
|
||||||
, randomChallenges
|
, randomChallenges
|
||||||
, intAnno lasSensorTurretTest
|
, lasSensorTurretTest
|
||||||
, -- ,[AnTree $ fmap pure roomCCrits]
|
, -- ,[AnTree $ fmap pure roomCCrits]
|
||||||
-- ,[AirlockAno]
|
-- ,[AirlockAno]
|
||||||
-- ,[Corridor]
|
-- ,[Corridor]
|
||||||
|
|||||||
+45
-24
@@ -50,6 +50,7 @@ gadgetEffect :: Int -> LocationDT OItem -> Creature -> World -> World
|
|||||||
gadgetEffect pt loc
|
gadgetEffect pt loc
|
||||||
| UseHeld{} <- loc ^. locDT . dtValue . _1 . itUse = heldEffect pt loc
|
| UseHeld{} <- loc ^. locDT . dtValue . _1 . itUse = heldEffect pt loc
|
||||||
| PulseBallSF <- loc ^. locDT . dtValue . _2 = heldEffect pt loc
|
| PulseBallSF <- loc ^. locDT . dtValue . _2 = heldEffect pt loc
|
||||||
|
| PlasmaSF <- loc ^. locDT . dtValue . _2 = heldEffect pt loc
|
||||||
| DROPPER x <- loc ^. locDT . dtValue . _1 . itType
|
| DROPPER x <- loc ^. locDT . dtValue . _1 . itType
|
||||||
, Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt
|
, Just i <- loc ^? locDT . dtValue . _1 . itUse . uInt
|
||||||
, pt == 0 =
|
, pt == 0 =
|
||||||
@@ -153,17 +154,24 @@ locMuzzles loc
|
|||||||
& ix 0 . mzFlareType .~ TeslaGunFlare
|
& ix 0 . mzFlareType .~ TeslaGunFlare
|
||||||
& ix 0 . mzEffect .~ MuzzlePulseLaser
|
& ix 0 . mzEffect .~ MuzzlePulseLaser
|
||||||
& ix 0 . mzAmmoSlot .~ CapacitorBelow (UseExactly 200)
|
& ix 0 . mzAmmoSlot .~ CapacitorBelow (UseExactly 200)
|
||||||
|
| PlasmaSF <- loc ^. locDT . dtValue . _2 =
|
||||||
|
dbwMuzzles
|
||||||
|
& ix 0 . mzEffect .~ MuzzlePlasmaBall
|
||||||
|
& ix 0 . mzAmmoSlot .~ CapacitorSelf (UseExactly 1)
|
||||||
|
& ix 0 . mzInaccuracy .~ 0
|
||||||
|
& ix 0 . mzFlareType .~ TeslaGunFlare
|
||||||
| PulseBallSF <- loc ^. locDT . dtValue . _2 =
|
| PulseBallSF <- loc ^. locDT . dtValue . _2 =
|
||||||
dbwMuzzles
|
dbwMuzzles
|
||||||
& ix 0 . mzEffect .~ MuzzlePulseBall
|
& ix 0 . mzEffect .~ MuzzlePulseBall
|
||||||
& ix 0 . mzAmmoSlot .~ CapacitorSelf (UseExactly 200)
|
& ix 0 . mzAmmoSlot .~ CapacitorSelf (UseExactly 200)
|
||||||
& ix 0 . mzInaccuracy .~ 0
|
& ix 0 . mzInaccuracy .~ 0
|
||||||
& ix 0 . mzFlareType .~ TeslaGunFlare
|
& ix 0 . mzFlareType .~ TeslaGunFlare
|
||||||
| otherwise = itemMuzzles $ loc ^. locDT . dtValue . _1
|
-- | otherwise = itemMuzzles $ loc ^. locDT . dtValue . _1
|
||||||
|
| otherwise = itemMuzzles $ loc
|
||||||
|
|
||||||
itemMuzzles :: Item -> [Muzzle]
|
itemMuzzles :: LocationDT OItem -> [Muzzle]
|
||||||
itemMuzzles itm = case itm ^. itType of
|
itemMuzzles loc = case itm ^. itType of
|
||||||
HELD hit -> heldItemMuzzles itm hit
|
HELD hit -> heldItemMuzzles loc hit
|
||||||
DETECTOR{} ->
|
DETECTOR{} ->
|
||||||
dbwMuzzles & ix 0 . mzEffect .~ MuzzleDetector
|
dbwMuzzles & ix 0 . mzEffect .~ MuzzleDetector
|
||||||
& ix 0 . mzAmmoSlot . aps .~ UseExactly 100
|
& ix 0 . mzAmmoSlot . aps .~ UseExactly 100
|
||||||
@@ -174,9 +182,11 @@ itemMuzzles itm = case itm ^. itType of
|
|||||||
& ix 0 . mzFlareType .~ LasGunFlare
|
& ix 0 . mzFlareType .~ LasGunFlare
|
||||||
& ix 0 . mzEffect .~ MuzzleLaser
|
& ix 0 . mzEffect .~ MuzzleLaser
|
||||||
_ -> []
|
_ -> []
|
||||||
|
where
|
||||||
|
itm = loc ^. locDT . dtValue . _1
|
||||||
|
|
||||||
heldItemMuzzles :: Item -> HeldItemType -> [Muzzle]
|
heldItemMuzzles :: LocationDT OItem -> HeldItemType -> [Muzzle]
|
||||||
heldItemMuzzles itm = \case
|
heldItemMuzzles loc = \case
|
||||||
ALTERIFLE ->
|
ALTERIFLE ->
|
||||||
dbwMuzzles & ix 0 . mzPos .~ V2 25 0
|
dbwMuzzles & ix 0 . mzPos .~ V2 25 0
|
||||||
& ix 0 . mzAmmoSlot .~ MagBelow (_alteRifleSwitch (_itParams itm)) (UseExactly 1)
|
& ix 0 . mzAmmoSlot .~ MagBelow (_alteRifleSwitch (_itParams itm)) (UseExactly 1)
|
||||||
@@ -246,6 +256,9 @@ heldItemMuzzles itm = \case
|
|||||||
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 magupto15 BasicFlare MuzzleShootBullet 12]
|
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 magupto15 BasicFlare MuzzleShootBullet 12]
|
||||||
GRAPECANNON i -> [Muzzle (V2 30 0) 0 0.5 magupto15 BasicFlare MuzzleShootBullet (12 + 4 * fromIntegral i)]
|
GRAPECANNON i -> [Muzzle (V2 30 0) 0 0.5 magupto15 BasicFlare MuzzleShootBullet (12 + 4 * fromIntegral i)]
|
||||||
LED -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
|
LED -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
|
||||||
|
-- don't care where the pump is, but possibly should know this
|
||||||
|
FLAMETHROWER | any (\dt -> Just PumpSF == dt ^? dtValue . _2) (loc ^. locDT . dtRight)
|
||||||
|
-> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 2 8
|
||||||
FLAMETHROWER -> flameMuzzles
|
FLAMETHROWER -> flameMuzzles
|
||||||
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
|
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
|
||||||
RLAUNCHER ->
|
RLAUNCHER ->
|
||||||
@@ -266,9 +279,9 @@ heldItemMuzzles itm = \case
|
|||||||
<*> pure MuzzleRLauncher
|
<*> pure MuzzleRLauncher
|
||||||
<*> pure 0
|
<*> pure 0
|
||||||
)
|
)
|
||||||
TESLAGUN ->
|
TESLACOIL ->
|
||||||
dbwMuzzles
|
dbwMuzzles
|
||||||
& ix 0 . mzPos .~ V2 10 0
|
& ix 0 . mzPos .~ V2 5 0
|
||||||
& ix 0 . mzInaccuracy .~ 0
|
& ix 0 . mzInaccuracy .~ 0
|
||||||
& ix 0 . mzFlareType .~ TeslaGunFlare
|
& ix 0 . mzFlareType .~ TeslaGunFlare
|
||||||
& ix 0 . mzEffect .~ MuzzleTesla
|
& ix 0 . mzEffect .~ MuzzleTesla
|
||||||
@@ -318,6 +331,7 @@ heldItemMuzzles itm = \case
|
|||||||
where
|
where
|
||||||
maguse1 = MagBelow 0 (UseExactly 1)
|
maguse1 = MagBelow 0 (UseExactly 1)
|
||||||
magupto15 = MagBelow 0 (UseUpTo 15)
|
magupto15 = MagBelow 0 (UseUpTo 15)
|
||||||
|
itm = loc ^. locDT . dtValue . _1
|
||||||
|
|
||||||
baseStickSpread :: Float
|
baseStickSpread :: Float
|
||||||
baseStickSpread = 0.2
|
baseStickSpread = 0.2
|
||||||
@@ -334,7 +348,8 @@ flameMuzzles =
|
|||||||
(MagBelow 0 (UseExactly 1))
|
(MagBelow 0 (UseExactly 1))
|
||||||
NoFlare
|
NoFlare
|
||||||
MuzzleNozzle
|
MuzzleNozzle
|
||||||
{ _nzPressure = ConstFloat 4
|
--{ _nzPressure = ConstFloat 4
|
||||||
|
{ _nzPressure = UniRandFloat 3.5 4
|
||||||
, _nzMaxWalkAngle = 0.2
|
, _nzMaxWalkAngle = 0.2
|
||||||
, _nzWalkSpeed = 0.01
|
, _nzWalkSpeed = 0.01
|
||||||
}
|
}
|
||||||
@@ -414,8 +429,7 @@ itemSidePush = \case
|
|||||||
FLAMETORRENT -> 0
|
FLAMETORRENT -> 0
|
||||||
FLAMEWALL -> 0
|
FLAMEWALL -> 0
|
||||||
BLOWTORCH -> 0
|
BLOWTORCH -> 0
|
||||||
SPARKGUN -> 0
|
TESLACOIL -> 0
|
||||||
TESLAGUN -> 0
|
|
||||||
TRACTORGUN -> 0
|
TRACTORGUN -> 0
|
||||||
RLAUNCHER -> 0
|
RLAUNCHER -> 0
|
||||||
RLAUNCHERX{} -> 0
|
RLAUNCHERX{} -> 0
|
||||||
@@ -497,8 +511,7 @@ recoilAmount itm
|
|||||||
FLAMETORRENT -> 0
|
FLAMETORRENT -> 0
|
||||||
FLAMEWALL -> 0
|
FLAMEWALL -> 0
|
||||||
BLOWTORCH -> 0
|
BLOWTORCH -> 0
|
||||||
SPARKGUN -> 0
|
TESLACOIL -> 0
|
||||||
TESLAGUN -> 0
|
|
||||||
TRACTORGUN -> 0
|
TRACTORGUN -> 0
|
||||||
RLAUNCHER -> 0
|
RLAUNCHER -> 0
|
||||||
RLAUNCHERX _ -> 0
|
RLAUNCHERX _ -> 0
|
||||||
@@ -544,8 +557,7 @@ bgunSound itm
|
|||||||
FLAMETORRENT -> Nothing
|
FLAMETORRENT -> Nothing
|
||||||
FLAMEWALL -> Nothing
|
FLAMEWALL -> Nothing
|
||||||
BLOWTORCH -> Nothing
|
BLOWTORCH -> Nothing
|
||||||
SPARKGUN -> Nothing
|
TESLACOIL -> Nothing
|
||||||
TESLAGUN -> Nothing
|
|
||||||
TRACTORGUN -> Nothing
|
TRACTORGUN -> Nothing
|
||||||
RLAUNCHER -> Just (tap4S, 0)
|
RLAUNCHER -> Just (tap4S, 0)
|
||||||
RLAUNCHERX _ -> Just (tap4S, 0)
|
RLAUNCHERX _ -> Just (tap4S, 0)
|
||||||
@@ -615,8 +627,7 @@ heldTorqueAmount = \case
|
|||||||
FLAMETORRENT -> 0
|
FLAMETORRENT -> 0
|
||||||
FLAMEWALL -> 0
|
FLAMEWALL -> 0
|
||||||
BLOWTORCH -> 0
|
BLOWTORCH -> 0
|
||||||
SPARKGUN -> 0
|
TESLACOIL -> 0.01
|
||||||
TESLAGUN -> 0.01
|
|
||||||
TRACTORGUN -> 0
|
TRACTORGUN -> 0
|
||||||
RLAUNCHER -> 0
|
RLAUNCHER -> 0
|
||||||
RLAUNCHERX{} -> 0
|
RLAUNCHERX{} -> 0
|
||||||
@@ -728,6 +739,7 @@ useLoadedAmmo loc cr mz m w =
|
|||||||
MuzzleLaser -> creatureShootLaser pq' loc (w & randGen .~ g)
|
MuzzleLaser -> creatureShootLaser pq' loc (w & randGen .~ g)
|
||||||
MuzzlePulseLaser -> creatureShootPulseLaser pq' cr (w & randGen .~ g)
|
MuzzlePulseLaser -> creatureShootPulseLaser pq' cr (w & randGen .~ g)
|
||||||
MuzzlePulseBall -> shootPulseBall pq' (w & randGen .~ g)
|
MuzzlePulseBall -> shootPulseBall pq' (w & randGen .~ g)
|
||||||
|
MuzzlePlasmaBall -> shootPlasmaBall pq' (w & randGen .~ g)
|
||||||
MuzzleTesla -> shootTeslaArc pq' loc (w & randGen .~ g)
|
MuzzleTesla -> shootTeslaArc pq' loc (w & randGen .~ g)
|
||||||
MuzzleTractor -> shootTractorBeam cr w
|
MuzzleTractor -> shootTractorBeam cr w
|
||||||
MuzzleRLauncher -> createProjectileR pq loc magtree cr w
|
MuzzleRLauncher -> createProjectileR pq loc magtree cr w
|
||||||
@@ -888,6 +900,18 @@ shootPulseLaser so p dir w =
|
|||||||
}
|
}
|
||||||
& soundStart so p lasPulseS Nothing
|
& soundStart so p lasPulseS Nothing
|
||||||
|
|
||||||
|
shootPlasmaBall :: Point3Q -> World -> World
|
||||||
|
shootPlasmaBall (p, q) w =
|
||||||
|
w
|
||||||
|
& cWorld . lWorld . plasmaBalls .:~
|
||||||
|
PBall
|
||||||
|
{ _pbPos = p ^. _xy
|
||||||
|
, _pbVel = 6 * unitVectorAtAngle (Q.qToAng q)
|
||||||
|
, _pbType = DefaultPlasma
|
||||||
|
}
|
||||||
|
-- & soundStart (PBSound i) (p ^. _xy) energyReleaseS Nothing
|
||||||
|
|
||||||
|
|
||||||
shootPulseBall :: Point3Q -> World -> World
|
shootPulseBall :: Point3Q -> World -> World
|
||||||
shootPulseBall (p, q) w =
|
shootPulseBall (p, q) w =
|
||||||
w
|
w
|
||||||
@@ -1021,8 +1045,7 @@ heldItemMuzVel = \case
|
|||||||
FLAMETORRENT -> ConstFloat 0.8
|
FLAMETORRENT -> ConstFloat 0.8
|
||||||
FLAMEWALL -> ConstFloat 0.8
|
FLAMEWALL -> ConstFloat 0.8
|
||||||
BLOWTORCH -> ConstFloat 0.8
|
BLOWTORCH -> ConstFloat 0.8
|
||||||
SPARKGUN -> ConstFloat 0.8
|
TESLACOIL -> ConstFloat 0.8
|
||||||
TESLAGUN -> ConstFloat 0.8
|
|
||||||
TRACTORGUN -> ConstFloat 0.8
|
TRACTORGUN -> ConstFloat 0.8
|
||||||
RLAUNCHER -> ConstFloat 0
|
RLAUNCHER -> ConstFloat 0
|
||||||
RLAUNCHERX{} -> ConstFloat 0
|
RLAUNCHERX{} -> ConstFloat 0
|
||||||
@@ -1064,8 +1087,7 @@ heldItemRifling = \case
|
|||||||
FLAMETORRENT -> ConstFloat 0.8
|
FLAMETORRENT -> ConstFloat 0.8
|
||||||
FLAMEWALL -> ConstFloat 0.8
|
FLAMEWALL -> ConstFloat 0.8
|
||||||
BLOWTORCH -> ConstFloat 0.8
|
BLOWTORCH -> ConstFloat 0.8
|
||||||
SPARKGUN -> ConstFloat 0.8
|
TESLACOIL -> ConstFloat 0.8
|
||||||
TESLAGUN -> ConstFloat 0.8
|
|
||||||
TRACTORGUN -> ConstFloat 0.8
|
TRACTORGUN -> ConstFloat 0.8
|
||||||
RLAUNCHER -> ConstFloat 0
|
RLAUNCHER -> ConstFloat 0
|
||||||
RLAUNCHERX{} -> ConstFloat 0
|
RLAUNCHERX{} -> ConstFloat 0
|
||||||
@@ -1136,8 +1158,7 @@ gasType hit _ = case hit of
|
|||||||
FLAMETORRENT -> Just CreateFlame
|
FLAMETORRENT -> Just CreateFlame
|
||||||
FLAMEWALL -> Just CreateFlame
|
FLAMEWALL -> Just CreateFlame
|
||||||
BLOWTORCH -> Nothing
|
BLOWTORCH -> Nothing
|
||||||
SPARKGUN -> Nothing
|
TESLACOIL -> Nothing
|
||||||
TESLAGUN -> Nothing
|
|
||||||
TRACTORGUN -> Nothing
|
TRACTORGUN -> Nothing
|
||||||
RLAUNCHER -> Nothing
|
RLAUNCHER -> Nothing
|
||||||
RLAUNCHERX{} -> Nothing
|
RLAUNCHERX{} -> Nothing
|
||||||
@@ -1365,7 +1386,7 @@ dropInventoryPath i ip loc cr = fromMaybe id $ do
|
|||||||
-- guard $ (i + j) `IM.member` (cr ^. crInv)
|
-- guard $ (i + j) `IM.member` (cr ^. crInv)
|
||||||
-- return $ dropItem cr (i + j) w
|
-- return $ dropItem cr (i + j) w
|
||||||
-- RELITEM -> fromMaybe w $ do
|
-- RELITEM -> fromMaybe w $ do
|
||||||
-- j <- loc ^? locLDT . ldtValue . _1 . itLocation . ilInvID
|
-- j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID
|
||||||
-- guard $ (i + j) `IM.member` (cr ^. crInv)
|
-- guard $ (i + j) `IM.member` (cr ^. crInv)
|
||||||
-- return $ dropItem cr (i + j) w
|
-- return $ dropItem cr (i + j) w
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ itemFromAttachType = \case
|
|||||||
HOMINGMODULE -> homingModule
|
HOMINGMODULE -> homingModule
|
||||||
SHELLPAYLOAD p -> shellModule p
|
SHELLPAYLOAD p -> shellModule p
|
||||||
CAPACITOR -> capacitor
|
CAPACITOR -> capacitor
|
||||||
|
COMPRESSOR -> compressor
|
||||||
|
|
||||||
itemFromEquipType :: EquipItemType -> Item
|
itemFromEquipType :: EquipItemType -> Item
|
||||||
itemFromEquipType et = case et of
|
itemFromEquipType et = case et of
|
||||||
|
|||||||
@@ -50,8 +50,7 @@ heldAimStance = \case
|
|||||||
FLAMETORRENT -> TwoHandUnder
|
FLAMETORRENT -> TwoHandUnder
|
||||||
FLAMEWALL -> TwoHandUnder
|
FLAMEWALL -> TwoHandUnder
|
||||||
BLOWTORCH -> TwoHandUnder
|
BLOWTORCH -> TwoHandUnder
|
||||||
SPARKGUN -> TwoHandFlat
|
TESLACOIL -> TwoHandFlat
|
||||||
TESLAGUN -> TwoHandFlat
|
|
||||||
TRACTORGUN -> TwoHandUnder
|
TRACTORGUN -> TwoHandUnder
|
||||||
RLAUNCHER -> TwoHandOver
|
RLAUNCHER -> TwoHandOver
|
||||||
RLAUNCHERX{} -> TwoHandOver
|
RLAUNCHERX{} -> TwoHandOver
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ module Dodge.Item.Ammo (
|
|||||||
megaTinMag,
|
megaTinMag,
|
||||||
megaBattery,
|
megaBattery,
|
||||||
capacitor,
|
capacitor,
|
||||||
|
compressor,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
@@ -70,6 +71,13 @@ capacitor =
|
|||||||
& itUse .~ UseNothing
|
& itUse .~ UseNothing
|
||||||
& itConsumables ?~ 0
|
& itConsumables ?~ 0
|
||||||
|
|
||||||
|
compressor :: Item
|
||||||
|
compressor =
|
||||||
|
defHeldItem
|
||||||
|
& itType .~ ATTACH COMPRESSOR
|
||||||
|
& itUse .~ UseNothing
|
||||||
|
& itConsumables ?~ 0
|
||||||
|
|
||||||
chemFuelPouch :: Item
|
chemFuelPouch :: Item
|
||||||
chemFuelPouch =
|
chemFuelPouch =
|
||||||
defHeldItem
|
defHeldItem
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ heldItemAmmoSlots = \case
|
|||||||
FLAMESPITTER -> singleAmmo GasAmmo
|
FLAMESPITTER -> singleAmmo GasAmmo
|
||||||
FLAMEWALL -> singleAmmo GasAmmo
|
FLAMEWALL -> singleAmmo GasAmmo
|
||||||
BLOWTORCH -> singleAmmo GasAmmo
|
BLOWTORCH -> singleAmmo GasAmmo
|
||||||
TESLAGUN -> singleAmmo ElectricalAmmo
|
TESLACOIL -> singleAmmo ElectricalAmmo
|
||||||
SPARKGUN -> singleAmmo ElectricalAmmo
|
|
||||||
TRACTORGUN -> singleAmmo ElectricalAmmo
|
TRACTORGUN -> singleAmmo ElectricalAmmo
|
||||||
SHATTERGUN -> singleAmmo ElectricalAmmo
|
SHATTERGUN -> singleAmmo ElectricalAmmo
|
||||||
LED -> singleAmmo ElectricalAmmo
|
LED -> singleAmmo ElectricalAmmo
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ showAttachItem = \case
|
|||||||
GIMBAL -> "GIMBAL"
|
GIMBAL -> "GIMBAL"
|
||||||
GYROSCOPE -> "GYROSCOPE"
|
GYROSCOPE -> "GYROSCOPE"
|
||||||
CAPACITOR -> "CAPACITOR"
|
CAPACITOR -> "CAPACITOR"
|
||||||
|
COMPRESSOR -> "COMPRESSOR"
|
||||||
|
|
||||||
showEquipItem :: EquipItemType -> String
|
showEquipItem :: EquipItemType -> String
|
||||||
showEquipItem eit = case eit of
|
showEquipItem eit = case eit of
|
||||||
|
|||||||
@@ -259,8 +259,7 @@ heldItemSPic ht it = case ht of
|
|||||||
FLAMETORRENT -> flamerPic it
|
FLAMETORRENT -> flamerPic it
|
||||||
FLAMEWALL -> flamerPic it
|
FLAMEWALL -> flamerPic it
|
||||||
BLOWTORCH -> flamerPic it
|
BLOWTORCH -> flamerPic it
|
||||||
SPARKGUN -> teslaGunPic
|
TESLACOIL -> teslaGunPic
|
||||||
TESLAGUN -> teslaGunPic
|
|
||||||
TRACTORGUN -> tractorGunPic it
|
TRACTORGUN -> tractorGunPic it
|
||||||
RLAUNCHER -> rlauncherPic it
|
RLAUNCHER -> rlauncherPic it
|
||||||
RLAUNCHERX _ -> rlauncherPic it
|
RLAUNCHERX _ -> rlauncherPic it
|
||||||
|
|||||||
@@ -36,16 +36,19 @@ tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
|
|||||||
|
|
||||||
itemAboveAttachables :: CItem -> [ItemSF]
|
itemAboveAttachables :: CItem -> [ItemSF]
|
||||||
itemAboveAttachables (itm,sf) = case (itm ^. itType, sf) of
|
itemAboveAttachables (itm,sf) = case (itm ^. itType, sf) of
|
||||||
(_, HeldPlatformSF) ->
|
(HELD FLAMETHROWER,_) -> PumpSF:helddefaults
|
||||||
[WeaponTargetingSF, WeaponScopeSF,TorchSF]
|
(_, HeldPlatformSF) -> helddefaults
|
||||||
<> getAutoSpringLinks itm
|
|
||||||
<> extraWeaponLinks itm
|
|
||||||
(DETECTOR {}, _) -> [ARHUDSF,TriggerSF,MapperSF]
|
(DETECTOR {}, _) -> [ARHUDSF,TriggerSF,MapperSF]
|
||||||
--(CRAFT TRANSFORMER, _) -> [LaserWeaponSF]
|
--(CRAFT TRANSFORMER, _) -> [LaserWeaponSF]
|
||||||
(LASER, _) -> [TransformerSF]
|
(LASER, _) -> [TransformerSF]
|
||||||
(MAPPER, _) -> [ARHUDSF]
|
(MAPPER, _) -> [ARHUDSF]
|
||||||
(_, GadgetPlatformSF) -> [TriggerSF, WeaponTargetingSF, WeaponScopeSF]
|
(_, GadgetPlatformSF) -> [TriggerSF, WeaponTargetingSF, WeaponScopeSF]
|
||||||
_ -> []
|
_ -> []
|
||||||
|
where
|
||||||
|
helddefaults =
|
||||||
|
[WeaponTargetingSF, WeaponScopeSF,TorchSF]
|
||||||
|
<> getAutoSpringLinks itm
|
||||||
|
<> extraWeaponLinks itm
|
||||||
|
|
||||||
itemBelowAttachables :: CItem -> [ItemSF]
|
itemBelowAttachables :: CItem -> [ItemSF]
|
||||||
itemBelowAttachables (itm,sf) = case (itm ^. itType, sf) of
|
itemBelowAttachables (itm,sf) = case (itm ^. itType, sf) of
|
||||||
@@ -138,6 +141,7 @@ itemToFunction itm = case itm ^. itType of
|
|||||||
CLICKER{} -> GadgetPlatformSF
|
CLICKER{} -> GadgetPlatformSF
|
||||||
ATTACH CAPACITOR -> CapacitorSF
|
ATTACH CAPACITOR -> CapacitorSF
|
||||||
CRAFT TRANSFORMER -> TransformerSF
|
CRAFT TRANSFORMER -> TransformerSF
|
||||||
|
CRAFT PUMP -> PumpSF
|
||||||
_ -> NoSF
|
_ -> NoSF
|
||||||
|
|
||||||
treeToPotentialFunction :: DTree CItem -> S.Set ItemSF
|
treeToPotentialFunction :: DTree CItem -> S.Set ItemSF
|
||||||
|
|||||||
@@ -58,8 +58,7 @@ itemFromHeldType ht = case ht of
|
|||||||
FLAMETORRENT -> flameTorrent
|
FLAMETORRENT -> flameTorrent
|
||||||
FLAMEWALL -> flameWall
|
FLAMEWALL -> flameWall
|
||||||
BLOWTORCH -> blowTorch
|
BLOWTORCH -> blowTorch
|
||||||
SPARKGUN -> sparkGun
|
TESLACOIL -> teslaCoil
|
||||||
TESLAGUN -> teslaGun
|
|
||||||
-- LASCIRCLE -> lasCircle
|
-- LASCIRCLE -> lasCircle
|
||||||
-- DUALBEAM -> dualBeam
|
-- DUALBEAM -> dualBeam
|
||||||
-- LASWIDE i -> lasWide i
|
-- LASWIDE i -> lasWide i
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
module Dodge.Item.Held.BatteryGuns (
|
module Dodge.Item.Held.BatteryGuns (
|
||||||
sparkGun,
|
teslaCoil,
|
||||||
teslaGun,
|
|
||||||
laser,
|
laser,
|
||||||
tractorGun,
|
tractorGun,
|
||||||
) where
|
) where
|
||||||
@@ -10,17 +9,11 @@ import Dodge.Data.Item
|
|||||||
import Dodge.Default.Item
|
import Dodge.Default.Item
|
||||||
--import Geometry.Data
|
--import Geometry.Data
|
||||||
|
|
||||||
sparkGun :: Item
|
teslaCoil :: Item
|
||||||
sparkGun =
|
teslaCoil =
|
||||||
teslaGun
|
|
||||||
& itType .~ HELD SPARKGUN
|
|
||||||
-- & itParams . arcSize .~ 10
|
|
||||||
|
|
||||||
teslaGun :: Item
|
|
||||||
teslaGun =
|
|
||||||
defHeldItem
|
defHeldItem
|
||||||
& itParams .~ teslaParams
|
& itParams .~ teslaParams
|
||||||
& itType .~ HELD TESLAGUN
|
& itType .~ HELD TESLACOIL
|
||||||
|
|
||||||
teslaParams :: ItemParams
|
teslaParams :: ItemParams
|
||||||
teslaParams =
|
teslaParams =
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ heldHandlePos = \case
|
|||||||
FLAMETORRENT -> V2 3 0
|
FLAMETORRENT -> V2 3 0
|
||||||
FLAMEWALL -> V2 3 0
|
FLAMEWALL -> V2 3 0
|
||||||
BLOWTORCH -> V2 3 0
|
BLOWTORCH -> V2 3 0
|
||||||
SPARKGUN -> V2 3 0
|
TESLACOIL -> V2 3 0
|
||||||
TESLAGUN -> V2 3 0
|
|
||||||
TRACTORGUN -> V2 3 0
|
TRACTORGUN -> V2 3 0
|
||||||
RLAUNCHER -> V2 3 0
|
RLAUNCHER -> V2 3 0
|
||||||
RLAUNCHERX{} -> V2 3 0
|
RLAUNCHERX{} -> V2 3 0
|
||||||
|
|||||||
@@ -121,8 +121,7 @@ heldInfo hit = case hit of
|
|||||||
FLAMETORRENT -> "A weapon that streams out burning fuel in a torrent."
|
FLAMETORRENT -> "A weapon that streams out burning fuel in a torrent."
|
||||||
FLAMEWALL -> "A weapon that squirts out burning fuel all around the user."
|
FLAMEWALL -> "A weapon that squirts out burning fuel all around the user."
|
||||||
BLOWTORCH -> "A weapon that produces a concentrated flame."
|
BLOWTORCH -> "A weapon that produces a concentrated flame."
|
||||||
SPARKGUN -> "A weapon that produces an arc of electricity. The arc will attempt to discharge at a nearby object."
|
TESLACOIL -> "An item that creates an arc of electricity."
|
||||||
TESLAGUN -> "A weapon that discharges a sustained arc of electricity. The arc will attempt to discharge at a nearby object."
|
|
||||||
TRACTORGUN -> "An item that produces a beam of gravitons."
|
TRACTORGUN -> "An item that produces a beam of gravitons."
|
||||||
GLAUNCHER -> "A large tube that can launch projectiles."
|
GLAUNCHER -> "A large tube that can launch projectiles."
|
||||||
RLAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
|
RLAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ itInvHeight x = case x ^. itType of
|
|||||||
|
|
||||||
itDim :: Item -> ItemDimension
|
itDim :: Item -> ItemDimension
|
||||||
itDim x = case x ^. itType of
|
itDim x = case x ^. itType of
|
||||||
HELD TESLAGUN -> ItemDimension 9 (V3 4 0 0) (V3 10 (-5) 3)
|
HELD TESLACOIL -> ItemDimension 9 (V3 4 0 0) (V3 10 (-5) 3)
|
||||||
LASER -> did & dimRad .~ 10
|
LASER -> did & dimRad .~ 10
|
||||||
& dimCenter .~ V3 15 0 0
|
& dimCenter .~ V3 15 0 0
|
||||||
HELD TRACTORGUN -> did & dimRad .~ 10
|
HELD TRACTORGUN -> did & dimRad .~ 10
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ sfInvColor = \case
|
|||||||
PulseLaserSF -> white
|
PulseLaserSF -> white
|
||||||
CapacitorSF -> yellow
|
CapacitorSF -> yellow
|
||||||
PulseBallSF -> white
|
PulseBallSF -> white
|
||||||
|
PlasmaSF -> white
|
||||||
TransformerSF -> yellow
|
TransformerSF -> yellow
|
||||||
|
PumpSF -> yellow
|
||||||
TorchSF{} -> green
|
TorchSF{} -> green
|
||||||
|
|
||||||
--ammoTypeColor :: AmmoType -> Color
|
--ammoTypeColor :: AmmoType -> Color
|
||||||
|
|||||||
+75
-68
@@ -1,25 +1,27 @@
|
|||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
|
|
||||||
module Dodge.Layout (
|
module Dodge.Layout (
|
||||||
generateLevelFromRoomList,
|
generateLevelFromRoomList,
|
||||||
tilesFromRooms,
|
tilesFromRooms,
|
||||||
shuffleRoomPos,
|
shuffleRoomPos,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Vector.Unboxed as UV
|
-- import Dodge.Path.Translate
|
||||||
--import Dodge.Path.Translate
|
|
||||||
import qualified Control.Foldl as L
|
import qualified Control.Foldl as L
|
||||||
import Control.Lens
|
import Control.Lens
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import Data.Function
|
import Data.Function
|
||||||
--import Data.Graph.Inductive (labEdges, labNodes)
|
import Linear
|
||||||
import Data.List (nubBy,sortOn)
|
-- import Data.Graph.Inductive (labEdges, labNodes)
|
||||||
|
import Data.List (nubBy, sortOn)
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Tile
|
import Data.Tile
|
||||||
--import Data.Traversable
|
import qualified Data.Vector.Unboxed as UV
|
||||||
|
-- import Data.Traversable
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Default.Wall
|
import Dodge.Default.Wall
|
||||||
import Dodge.GameRoom
|
import Dodge.GameRoom
|
||||||
--import Dodge.Item.Location.Initialize
|
-- import Dodge.Item.Location.Initialize
|
||||||
import Dodge.LevelGen.LevelStructure
|
import Dodge.LevelGen.LevelStructure
|
||||||
import Dodge.LevelGen.StaticWalls
|
import Dodge.LevelGen.StaticWalls
|
||||||
import Dodge.Path
|
import Dodge.Path
|
||||||
@@ -37,29 +39,27 @@ generateLevelFromRoomList gr' w =
|
|||||||
over gwWorld initWallZoning
|
over gwWorld initWallZoning
|
||||||
. over gwWorld randomCompass
|
. over gwWorld randomCompass
|
||||||
. over gwWorld setupWorldBounds
|
. over gwWorld setupWorldBounds
|
||||||
-- . over (gwWorld . cWorld . lWorld) initItemLocations
|
|
||||||
. doInPlacements
|
. doInPlacements
|
||||||
-- . doOutPlacements
|
|
||||||
. doIndividualPlacements
|
. doIndividualPlacements
|
||||||
. setTiles
|
. setTiles
|
||||||
. worldToGenWorld rs'
|
. worldToGenWorld rs'
|
||||||
$ w & cWorld . lWorld . walls .~ wallsFromRooms rs
|
$ w
|
||||||
|
& cWorld . lWorld . walls .~ wallsFromRooms rs
|
||||||
& cWorld . cwGen . cwgGameRooms .~ gameRoomsFromRooms (IM.elems rs')
|
& cWorld . cwGen . cwgGameRooms .~ gameRoomsFromRooms (IM.elems rs')
|
||||||
& cWorld . incNode .~ inodes
|
& cWorld . incNode .~ inodes
|
||||||
& cWorld . incGraph .~ igraph
|
& cWorld . incGraph .~ igraph
|
||||||
& cWorld . incEdges .~ ipairs
|
& cWorld . incEdges .~ ipairs
|
||||||
& incNodeZoning .~ UV.ifoldl' (\m i p -> zonePn (i,p) m) mempty inodes
|
& incNodeZoning .~ UV.ifoldl' (\m i p -> zonePn (i, p) m) mempty inodes
|
||||||
& incEdgeZoning .~ foldl' (flip (zoneIncPe inodes)) mempty ipairs
|
& incEdgeZoning .~ foldl' (flip (zoneIncPe inodes)) mempty ipairs
|
||||||
where
|
where
|
||||||
pairs = snapToGrid $ foldMap _rmPath rs
|
pairs = snapToGrid $ foldMap _rmPath rs
|
||||||
(inodes,igraph,ipairs) = pairsToIncGraph pairs
|
(inodes, igraph, ipairs) = pairsToIncGraph pairs
|
||||||
rs = map doRoomShift $ IM.elems rs'
|
rs = map doRoomShift $ IM.elems rs'
|
||||||
rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w
|
rs' = mapM shuffleRoomPos gr' & evalState $ _randGen w
|
||||||
|
|
||||||
|
|
||||||
randomCompass :: World -> World
|
randomCompass :: World -> World
|
||||||
randomCompass w = w
|
randomCompass w =
|
||||||
& wCam . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w)
|
w & wCam . camRot .~ (takeOne [0, 0.5 * pi, pi, 1.5 * pi] & evalState $ _randGen w)
|
||||||
|
|
||||||
-- note the order of traversal of the rooms is important
|
-- note the order of traversal of the rooms is important
|
||||||
-- hence the reverse
|
-- hence the reverse
|
||||||
@@ -70,57 +70,61 @@ setTiles gw = foldr setTile gw . reverse . IM.elems $ _genRooms gw
|
|||||||
setTile :: Room -> GenWorld -> GenWorld
|
setTile :: Room -> GenWorld -> GenWorld
|
||||||
setTile r gw = case _rmFloor r of
|
setTile r gw = case _rmFloor r of
|
||||||
Tiled{} -> gw
|
Tiled{} -> gw
|
||||||
InheritFloor -> gw
|
InheritFloor ->
|
||||||
& genRooms . ix (fromJust (_rmMID r)) . rmFloor .~ Tiled [t & tilePoly .~ poly]
|
gw & genRooms . ix (fromJust (_rmMID r)) . rmFloor .~ Tiled [t & tilePoly .~ poly]
|
||||||
where
|
where
|
||||||
t = case _rmMParent r of
|
t = case _rmMParent r of
|
||||||
Nothing -> Tile poly (V2 0 0) (V2 1 0) 16
|
Nothing -> Tile poly (V2 0 0) (V2 1 0) 16
|
||||||
Just pid -> head $ _tiles $ _rmFloor $ _genRooms gw IM.! pid
|
Just pid -> head $ _tiles $ _rmFloor $ _genRooms gw IM.! pid
|
||||||
poly = orderPolygon . convexHullSafe
|
poly =
|
||||||
. nubBy ((==) `on` roundPoint2) $ concat $ _rmPolys r
|
orderPolygon
|
||||||
|
. convexHullSafe
|
||||||
|
. nubBy ((==) `on` roundPoint2)
|
||||||
|
. concat
|
||||||
|
$ _rmPolys r
|
||||||
|
|
||||||
shuffleRoomPos :: RandomGen g => Room -> State g Room
|
shuffleRoomPos :: (RandomGen g) => Room -> State g Room
|
||||||
shuffleRoomPos rm = do
|
shuffleRoomPos = rmPos shuffle
|
||||||
newPos <- shuffle $ _rmPos rm
|
|
||||||
return $ rm & rmPos .~ newPos
|
|
||||||
|
|
||||||
doInPlacements :: GenWorld -> GenWorld
|
doInPlacements :: GenWorld -> GenWorld
|
||||||
doInPlacements w = foldl' (\gw (i,(_,f)) -> placeSpot i gw (f gw)) w
|
doInPlacements w =
|
||||||
. sortOn (fst.snd)
|
foldl' (\gw (i, (_, f)) -> rplaceSpot i gw (f gw)) w
|
||||||
$ foldMap g $ w ^. genRooms
|
. sortOn (fst . snd)
|
||||||
|
. foldMap g
|
||||||
|
$ w ^. genRooms
|
||||||
where
|
where
|
||||||
g rm = (rm^?! rmMID . _Just,) <$> (rm ^. rmInPmnt)
|
g rm = (rm ^?! rmMID . _Just,) <$> (rm ^. rmInPmnt)
|
||||||
-- let (gw, rms) = mapAccumR doRoomInPlacements w (_genRooms w)
|
rplaceSpot i gw rx = placeSpot i (gw & gwWorld . randGen .~ gen) x
|
||||||
-- in gw & genRooms .~ rms
|
where
|
||||||
|
(x,gen) = runState rx (gw ^. gwWorld . randGen)
|
||||||
--doRoomInPlacements :: GenWorld -> Room -> (GenWorld, Room)
|
|
||||||
--doRoomInPlacements w rm = foldr f (w, rm) $ _rmInPmnt rm
|
|
||||||
-- where
|
|
||||||
-- f plf (w', r') = placeSpot (w', r') (plf w')
|
|
||||||
|
|
||||||
doIndividualPlacements :: GenWorld -> GenWorld
|
doIndividualPlacements :: GenWorld -> GenWorld
|
||||||
doIndividualPlacements gw = foldl' doRoomPlacements gw (_genRooms gw)
|
doIndividualPlacements gw = foldl' doRoomPlacements gw (_genRooms gw)
|
||||||
|
|
||||||
doRoomPlacements :: GenWorld -> Room -> GenWorld
|
doRoomPlacements :: GenWorld -> Room -> GenWorld
|
||||||
doRoomPlacements w rm = foldl' (placeSpot i) (w & genRooms . ix i . rmPmnts .~ mempty)
|
doRoomPlacements w rm =
|
||||||
$ _rmPmnts rm
|
foldl' (placeSpot i) (w & genRooms . ix i . rmPmnts .~ mempty)
|
||||||
|
. sortOn plPriority
|
||||||
|
$ _rmPmnts rm
|
||||||
where
|
where
|
||||||
i = rm ^?! rmMID . _Just
|
i = rm ^?! rmMID . _Just
|
||||||
|
|
||||||
--placeSpot' :: Int -> GenWorld -> Placement -> GenWorld
|
plPriority :: Placement -> Int
|
||||||
--placeSpot' = placeSpot
|
plPriority pl = case pl ^. plType of
|
||||||
--placeSpot' i gw x =
|
PutChasm{} -> 0
|
||||||
-- let (gw',r') = placeSpot (gw,(gw ^?! genRooms . ix i)) x
|
PutBlock{} -> 1
|
||||||
-- in gw' & genRooms . ix i .~ r'
|
PutDoor{} -> 2
|
||||||
|
_ -> 3
|
||||||
|
|
||||||
setupWorldBounds :: World -> World
|
setupWorldBounds :: World -> World
|
||||||
setupWorldBounds w =
|
setupWorldBounds w =
|
||||||
w & cWorld . cwGen . cwgWorldBounds
|
w
|
||||||
%~ ( (bdMinX .~ f minx)
|
& cWorld . cwGen . cwgWorldBounds
|
||||||
. (bdMaxX .~ f maxx)
|
%~ ( (bdMinX .~ f minx)
|
||||||
. (bdMinY .~ f miny)
|
. (bdMaxX .~ f maxx)
|
||||||
. (bdMaxY .~ f maxy)
|
. (bdMinY .~ f miny)
|
||||||
)
|
. (bdMaxY .~ f maxy)
|
||||||
|
)
|
||||||
where
|
where
|
||||||
f = fromMaybe 0
|
f = fromMaybe 0
|
||||||
ps = IM.map (fst . _wlLine) $ w ^. cWorld . lWorld . walls -- _walls (_cWorld w)
|
ps = IM.map (fst . _wlLine) $ w ^. cWorld . lWorld . walls -- _walls (_cWorld w)
|
||||||
@@ -154,14 +158,17 @@ gameRoomFromRoom rm =
|
|||||||
GameRoom
|
GameRoom
|
||||||
{ _grViewpoints =
|
{ _grViewpoints =
|
||||||
map doshift $
|
map doshift $
|
||||||
_rmViewpoints rm ++ (map fst . foldl' (flip cutWalls) [] $ _rmPolys rm)
|
_rmViewpoints rm
|
||||||
|
++ (map fst . foldl' (flip cutWalls) [] $ _rmPolys rm)
|
||||||
++ mapMaybe filterUnusedLinks (_rmPos rm)
|
++ mapMaybe filterUnusedLinks (_rmPos rm)
|
||||||
, _grViewpointsEx = concatMap filterUsedLinks (_rmPos rm)
|
, _grViewpointsEx = concatMap filterUsedLinks (_rmPos rm)
|
||||||
, _grBound =
|
, _grBound =
|
||||||
map doshift $
|
map doshift
|
||||||
expandPolyCorners 50 . convexHullSafe . nubBy closePoints
|
$ expandPolyCorners 50
|
||||||
|
. convexHullSafe
|
||||||
|
. nubBy closePoints
|
||||||
. concat
|
. concat
|
||||||
$ _rmBound rm ++ _rmPolys rm
|
$ _rmBound rm ++ _rmPolys rm
|
||||||
, _grRmBounds = map (map doshift) $ _rmBound rm
|
, _grRmBounds = map (map doshift) $ _rmBound rm
|
||||||
, _grDir = getDir $ _rmPos rm
|
, _grDir = getDir $ _rmPos rm
|
||||||
, _grLinkDirs = mapMaybe undir $ _rmPos rm
|
, _grLinkDirs = mapMaybe undir $ _rmPos rm
|
||||||
@@ -172,8 +179,8 @@ gameRoomFromRoom rm =
|
|||||||
doubleShift p a =
|
doubleShift p a =
|
||||||
map
|
map
|
||||||
doshift
|
doshift
|
||||||
[ p +.+ 10 *.* unitVectorAtAngle a
|
[ p + 10 *^ unitVectorAtAngle a
|
||||||
, p -.- 10 *.* unitVectorAtAngle a
|
, p - 10 *^ unitVectorAtAngle a
|
||||||
]
|
]
|
||||||
filterUnusedLinks rp = case _rpType rp of
|
filterUnusedLinks rp = case _rpType rp of
|
||||||
UnusedLink{} -> Just $ _rpPos rp
|
UnusedLink{} -> Just $ _rpPos rp
|
||||||
@@ -202,36 +209,36 @@ getTiles fl = case fl of
|
|||||||
Tiled xs -> xs
|
Tiled xs -> xs
|
||||||
_ -> error "tiles not correctly set for some room"
|
_ -> error "tiles not correctly set for some room"
|
||||||
|
|
||||||
--divideWall :: Wall -> [Wall]
|
-- divideWall :: Wall -> [Wall]
|
||||||
--divideWall wl
|
-- divideWall wl
|
||||||
-- = let (a,b) = _wlLine wl
|
-- = let (a,b) = _wlLine wl
|
||||||
-- ps = divideLine (zoneSize * 2) a b
|
-- ps = divideLine (zoneSize * 2) a b
|
||||||
-- in zipWith (\ x y -> wl & wlLine .~ (x,y) ) (init ps) (tail ps)
|
-- in zipWith (\ x y -> wl & wlLine .~ (x,y) ) (init ps) (tail ps)
|
||||||
|
|
||||||
--divideWallIn :: Wall -> IM.IntMap Wall -> IM.IntMap Wall
|
-- divideWallIn :: Wall -> IM.IntMap Wall -> IM.IntMap Wall
|
||||||
--divideWallIn wl wls =
|
-- divideWallIn wl wls =
|
||||||
-- let (wl':newWls) = divideWall wl
|
-- let (wl':newWls) = divideWall wl
|
||||||
-- k = IM.newKey wls
|
-- k = IM.newKey wls
|
||||||
-- newWls' = zipWith (\i w -> w {_wlID = i}) [k..] newWls
|
-- newWls' = zipWith (\i w -> w {_wlID = i}) [k..] newWls
|
||||||
-- in foldl' (flip $ \w -> IM.insert (_wlID w) w) wls (wl':newWls')
|
-- in foldl' (flip $ \w -> IM.insert (_wlID w) w) wls (wl':newWls')
|
||||||
--
|
--
|
||||||
--divideWalls :: IM.IntMap Wall -> IM.IntMap Wall
|
-- divideWalls :: IM.IntMap Wall -> IM.IntMap Wall
|
||||||
--divideWalls wls = foldl' (flip divideWallIn) wls wls
|
-- divideWalls wls = foldl' (flip divideWallIn) wls wls
|
||||||
|
|
||||||
--insertInZone :: Int -> Int -> a -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)
|
-- insertInZone :: Int -> Int -> a -> IM.IntMap (IM.IntMap a) -> IM.IntMap (IM.IntMap a)
|
||||||
--insertInZone x y obj = IM.insertWith f x $ IM.singleton y obj
|
-- insertInZone x y obj = IM.insertWith f x $ IM.singleton y obj
|
||||||
-- where f _ = IM.insert y obj
|
-- where f _ = IM.insert y obj
|
||||||
|
|
||||||
--shiftRoomTree :: Tree Room -> Tree Room
|
-- shiftRoomTree :: Tree Room -> Tree Room
|
||||||
--shiftRoomTree (Node t []) = Node t []
|
-- shiftRoomTree (Node t []) = Node t []
|
||||||
--shiftRoomTree (Node t ts) = Node t
|
-- shiftRoomTree (Node t ts) = Node t
|
||||||
-- $ zipWith (\l -> shiftRoomTree . applyToRoot (shiftRoomToLink l))
|
-- $ zipWith (\l -> shiftRoomTree . applyToRoot (shiftRoomToLink l))
|
||||||
-- (_rmLinks t)
|
-- (_rmLinks t)
|
||||||
-- ts
|
-- ts
|
||||||
|
|
||||||
--shiftRoomTreeConstruction :: Tree Room -> [Tree Room]
|
-- shiftRoomTreeConstruction :: Tree Room -> [Tree Room]
|
||||||
--shiftRoomTreeConstruction (Node t []) = [Node t []]
|
-- shiftRoomTreeConstruction (Node t []) = [Node t []]
|
||||||
--shiftRoomTreeConstruction (Node t ts) = (Node t [] :) $ concat $
|
-- shiftRoomTreeConstruction (Node t ts) = (Node t [] :) $ concat $
|
||||||
-- zipWith (\l -> shiftRoomTreeConstruction . applyToRoot (shiftRoomBy l . f))
|
-- zipWith (\l -> shiftRoomTreeConstruction . applyToRoot (shiftRoomBy l . f))
|
||||||
-- (_rmLinks t)
|
-- (_rmLinks t)
|
||||||
-- ts
|
-- ts
|
||||||
@@ -240,8 +247,8 @@ getTiles fl = case fl of
|
|||||||
-- where
|
-- where
|
||||||
-- (p,a) = last $ _rmLinks r
|
-- (p,a) = last $ _rmLinks r
|
||||||
|
|
||||||
--addTile :: Float -> Room -> Room
|
-- addTile :: Float -> Room -> Room
|
||||||
--addTile z r
|
-- addTile z r
|
||||||
-- | not (null (_rmFloor r)) || null rp = r
|
-- | not (null (_rmFloor r)) || null rp = r
|
||||||
-- | otherwise = r & rmFloor .~ [makeTileFromPoly poly z]
|
-- | otherwise = r & rmFloor .~ [makeTileFromPoly poly z]
|
||||||
-- where
|
-- where
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ generateWorldFromSeed rdata i = do
|
|||||||
postGenerationProcessing :: RenderData -> GenWorld -> IO World
|
postGenerationProcessing :: RenderData -> GenWorld -> IO World
|
||||||
postGenerationProcessing _ gw = do
|
postGenerationProcessing _ gw = do
|
||||||
let w = _gwWorld gw & cWorld . cwTiles .~ (tilesFromRooms . IM.elems $ _genRooms gw)
|
let w = _gwWorld gw & cWorld . cwTiles .~ (tilesFromRooms . IM.elems $ _genRooms gw)
|
||||||
|
putStrLn $ show $ gw ^. genInts
|
||||||
return $ foldl' assignPushDoors w (w ^. cWorld . lWorld . doors)
|
return $ foldl' assignPushDoors w (w ^. cWorld . lWorld . doors)
|
||||||
|
|
||||||
assignPushDoors :: World -> Door -> World
|
assignPushDoors :: World -> Door -> World
|
||||||
|
|||||||
+12
-10
@@ -1,5 +1,6 @@
|
|||||||
module Dodge.LockAndKey where
|
module Dodge.LockAndKey where
|
||||||
|
|
||||||
|
import Dodge.Item.Ammo
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
import Dodge.Creature
|
import Dodge.Creature
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
@@ -24,13 +25,13 @@ lockRoomMultiItems =
|
|||||||
|
|
||||||
lockRoomKeyItems :: [(Int -> State LayoutVars (MetaTree Room String), State LayoutVars ItemType)]
|
lockRoomKeyItems :: [(Int -> State LayoutVars (MetaTree Room String), State LayoutVars ItemType)]
|
||||||
lockRoomKeyItems =
|
lockRoomKeyItems =
|
||||||
[ (lasCenSensEdge, takeOne [HELD RLAUNCHER, LASER, HELD SPARKGUN, HELD FLATSHIELD])
|
-- [ (lasCenSensEdge, takeOne [LASER,HELD TESLACOIL, HELD FLATSHIELD])
|
||||||
, (sensorRoomRunPast LaserSensor, return LASER)
|
-- , (sensorRoomRunPast LaserSensor, return LASER)
|
||||||
, (const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
|
-- [ (const slowDoorRoomRunPast, return $ HELD (MINIGUNX 3))
|
||||||
, (const longRoomRunPast, takeOne [HELD SNIPERRIFLE, HELD FLATSHIELD])
|
-- [ (const longRoomRunPast, takeOne [HELD SNIPERRIFLE, HELD FLATSHIELD])
|
||||||
, (const glassLessonRunPast, takeOne [LASER])
|
-- [ (const glassLessonRunPast, takeOne [LASER])
|
||||||
, (const $ lasTunnelRunPast 400, takeOne [HELD FLATSHIELD])
|
[ (const $ lasTunnelRunPast 400, takeOne [HELD FLATSHIELD])
|
||||||
, (keyCardRoomRunPast 0, return (HELD $ KEYCARD 0))
|
-- , (keyCardRoomRunPast 0, return (HELD $ KEYCARD 0))
|
||||||
]
|
]
|
||||||
|
|
||||||
keyCardRunPastRand :: RandomGen g => [(Int -> State g (MetaTree Room String), State g ItemType)]
|
keyCardRunPastRand :: RandomGen g => [(Int -> State g (MetaTree Room String), State g ItemType)]
|
||||||
@@ -58,14 +59,15 @@ itemRooms =
|
|||||||
( LASER
|
( LASER
|
||||||
, join $
|
, join $
|
||||||
takeOne
|
takeOne
|
||||||
[ rc $ map makeTypeCraft [PRISM, TRANSFORMER, PIPE]
|
[ rc $ battery : map makeTypeCraft [PRISM, TRANSFORMER, PIPE, TRANSFORMER]
|
||||||
|
, rc $ battery : laser : [makeTypeCraft TRANSFORMER]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
,
|
,
|
||||||
( HELD SPARKGUN
|
( HELD TESLACOIL
|
||||||
, join $
|
, join $
|
||||||
takeOne
|
takeOne
|
||||||
[ rc $ map makeTypeCraft [TRANSFORMER, CAN, CAN]
|
[ rc (battery : map makeTypeCraft [TRANSFORMER, CAN, CAN])
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
,
|
,
|
||||||
|
|||||||
@@ -16,3 +16,7 @@ materialColor = \case
|
|||||||
Flesh -> red
|
Flesh -> red
|
||||||
Electronics -> greyN 0.2
|
Electronics -> greyN 0.2
|
||||||
ForceField -> magenta
|
ForceField -> magenta
|
||||||
|
Photovoltaic -> yellow
|
||||||
|
LightningRod -> yellow
|
||||||
|
Pyroelectric -> yellow
|
||||||
|
Piezoelectric -> yellow
|
||||||
|
|||||||
@@ -25,13 +25,18 @@ damMatSideEffect dm = \case
|
|||||||
Dirt -> damageDirt dm
|
Dirt -> damageDirt dm
|
||||||
Glass -> damageGlass dm
|
Glass -> damageGlass dm
|
||||||
Crystal -> damageCrystal dm
|
Crystal -> damageCrystal dm
|
||||||
|
Photovoltaic -> damagePhotovoltaic dm
|
||||||
|
LightningRod -> damageLightningRod dm
|
||||||
|
Pyroelectric -> damagePyroelectric dm
|
||||||
|
Piezoelectric -> damagePiezoelectric dm
|
||||||
_ -> defDamageMaterial dm
|
_ -> defDamageMaterial dm
|
||||||
|
|
||||||
defDamageMaterial :: Damage -> ECW -> World -> (Int,World)
|
defDamageMaterial :: Damage -> ECW -> World -> (Int,World)
|
||||||
defDamageMaterial dm _ = (dm ^. dmAmount,)
|
defDamageMaterial dm _ = (dm ^. dmAmount,)
|
||||||
|
|
||||||
laserSpark x y -- = makeSpark FireSpark x y
|
laserSpark :: Point2 -> Float -> World -> World
|
||||||
= id
|
--laserSpark x y = makeSpark FireSpark x y
|
||||||
|
laserSpark = makeSpark FireSpark
|
||||||
|
|
||||||
damageStone :: Damage -> ECW -> World -> (Int,World)
|
damageStone :: Damage -> ECW -> World -> (Int,World)
|
||||||
damageStone dm ecw w = case dm of
|
damageStone dm ecw w = case dm of
|
||||||
@@ -65,6 +70,56 @@ damageStone dm ecw w = case dm of
|
|||||||
so = DamageHitSound (w ^. cWorld . lWorld . lClock)
|
so = DamageHitSound (w ^. cWorld . lWorld . lClock)
|
||||||
outTo x t = x -.- squashNormalizeV t
|
outTo x t = x -.- squashNormalizeV t
|
||||||
|
|
||||||
|
damageLightningRod :: Damage -> ECW -> World -> (Int,World)
|
||||||
|
damageLightningRod dm ecw w = case dm of
|
||||||
|
Electrical{} -> (dm ^. dmAmount, w)
|
||||||
|
_ -> damageStone dm ecw w
|
||||||
|
|
||||||
|
damagePyroelectric :: Damage -> ECW -> World -> (Int,World)
|
||||||
|
damagePyroelectric dm ecw w = case dm of
|
||||||
|
Flaming{} -> (dm ^. dmAmount, w)
|
||||||
|
Explosive{} -> (dm ^. dmAmount, w)
|
||||||
|
Sparking{} -> (dm ^. dmAmount, w)
|
||||||
|
_ -> damageStone dm ecw w
|
||||||
|
|
||||||
|
-- this should be correct
|
||||||
|
-- to be honest, we shouldn't just pass an int forward here...
|
||||||
|
damagePiezoelectric :: Damage -> ECW -> World -> (Int,World)
|
||||||
|
damagePiezoelectric = damageStone
|
||||||
|
|
||||||
|
|
||||||
|
damagePhotovoltaic :: Damage -> ECW -> World -> (Int,World)
|
||||||
|
damagePhotovoltaic dm ecw w = case dm of
|
||||||
|
Lasering _ p t -> f (10*dmam) $ laserSpark (outTo p t) (rdir p t)
|
||||||
|
Piercing _ p t ->
|
||||||
|
f dmam $ makeSpark NormalSpark (outTo p t) (rdir p t)
|
||||||
|
. makeDustAt Stone 200 (addZ 20 (outTo p t))
|
||||||
|
-- . randsound p [slapS, slap1S,slap2S,slap3S,slap4S,slap5S,slap6S,slap7S]
|
||||||
|
. randsound p [slapS, slap1S, slap2S]
|
||||||
|
Blunt _ p t -> f dmam $ makeDustAt Stone 200 (addZ 20 (outTo p t))
|
||||||
|
Shattering _ p t -> f dmam $ makeDustAt Stone 200 (addZ 20 (outTo p t))
|
||||||
|
Crushing{} -> f dmam id
|
||||||
|
Explosive{} -> f dmam id
|
||||||
|
Sparking{} -> f 0 id
|
||||||
|
Flaming{} -> f 0 id
|
||||||
|
Electrical{} -> f 0 id
|
||||||
|
Poison{} -> f 0 id
|
||||||
|
Enterrement{} -> f 0 id
|
||||||
|
Flashing{} -> f 0 id
|
||||||
|
where
|
||||||
|
f x g = (x, g w)
|
||||||
|
dmam = dm ^. dmAmount
|
||||||
|
rdir p t = argV $ reflectIn v t
|
||||||
|
where
|
||||||
|
v = case ecw of
|
||||||
|
Right wl -> uncurry (-) $ _wlLine wl
|
||||||
|
Left cr -> vNormal (p - cr ^. crPos . _xy)
|
||||||
|
randsound p xs =
|
||||||
|
let (x, g) = runState (takeOne xs) $ _randGen w
|
||||||
|
in soundStart so p x Nothing . set randGen g
|
||||||
|
so = DamageHitSound (w ^. cWorld . lWorld . lClock)
|
||||||
|
outTo x t = x -.- squashNormalizeV t
|
||||||
|
|
||||||
damageMetal :: Damage -> ECW -> World -> (Int,World)
|
damageMetal :: Damage -> ECW -> World -> (Int,World)
|
||||||
damageMetal dm ecw w = case dm of
|
damageMetal dm ecw w = case dm of
|
||||||
Lasering _ p t -> f 0 $ laserSpark (outTo p t) (rdir p t)
|
Lasering _ p t -> f 0 $ laserSpark (outTo p t) (rdir p t)
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ destroyMatS mat = case mat of
|
|||||||
Electronics -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S,metal7S]
|
Electronics -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S,metal7S]
|
||||||
Flesh -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S]
|
Flesh -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S]
|
||||||
ForceField -> []
|
ForceField -> []
|
||||||
|
Photovoltaic -> [glassShat1S, glassShat2S, glassShat3S, glassShat4S]
|
||||||
|
LightningRod -> [glassShat1S, glassShat2S, glassShat3S, glassShat4S]
|
||||||
|
Pyroelectric -> [glassShat1S, glassShat2S, glassShat3S, glassShat4S]
|
||||||
|
Piezoelectric -> [glassShat1S, glassShat2S, glassShat3S, glassShat4S]
|
||||||
|
|
||||||
--weakenMatS :: Material -> [SoundID]
|
--weakenMatS :: Material -> [SoundID]
|
||||||
--weakenMatS mat = case mat of
|
--weakenMatS mat = case mat of
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
module Dodge.Placement.Instance.LightSource (
|
module Dodge.Placement.Instance.LightSource (
|
||||||
mntLSOn,
|
mntLSOn,
|
||||||
|
mntLSCond,
|
||||||
aShape,
|
aShape,
|
||||||
aBar,
|
aBar,
|
||||||
lShape,
|
lShape,
|
||||||
|
jShape,
|
||||||
|
liShape,
|
||||||
mntLightLnkCond,
|
mntLightLnkCond,
|
||||||
mntLS,
|
mntLS,
|
||||||
vShape,
|
vShape,
|
||||||
@@ -13,6 +16,7 @@ module Dodge.Placement.Instance.LightSource (
|
|||||||
spanLightY,
|
spanLightY,
|
||||||
mntLightLnkCond',
|
mntLightLnkCond',
|
||||||
spanLS,
|
spanLS,
|
||||||
|
mntLightLnkShape,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Color
|
import Color
|
||||||
@@ -145,6 +149,9 @@ mntLightLnkCond ps = do
|
|||||||
shp <- takeOne [vShape, lShape, jShape, liShape]
|
shp <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
return $ mntLSCond (fmap (fmap $ colorSH black) shp) ps
|
return $ mntLSCond (fmap (fmap $ colorSH black) shp) ps
|
||||||
|
|
||||||
|
mntLightLnkShape :: (Point2 -> Point3 -> Shape) -> PlacementSpot -> Placement
|
||||||
|
mntLightLnkShape shp ps = mntLSCond (fmap (fmap $ colorSH black) shp) ps
|
||||||
|
|
||||||
mntLightLnkCond' :: PlacementSpot -> Placement
|
mntLightLnkCond' :: PlacementSpot -> Placement
|
||||||
mntLightLnkCond' = mntLSCond (fmap (fmap $ colorSH black) vShape)
|
mntLightLnkCond' = mntLSCond (fmap (fmap $ colorSH black) vShape)
|
||||||
|
|
||||||
@@ -178,7 +185,8 @@ spanColLightBlackI col h a b =
|
|||||||
V2 x y = 0.5 *.* (a +.+ b)
|
V2 x y = 0.5 *.* (a +.+ b)
|
||||||
|
|
||||||
spanLightI :: Point2 -> Point2 -> Placement
|
spanLightI :: Point2 -> Point2 -> Placement
|
||||||
spanLightI = spanColLightI 0.75 50.1
|
--spanLightI = spanColLightI 0.75 50.1
|
||||||
|
spanLightI = spanColLightI 0.75 95
|
||||||
|
|
||||||
spanLightY :: Point2 -> Point2 -> Point2 -> Point2 -> Placement
|
spanLightY :: Point2 -> Point2 -> Point2 -> Point2 -> Placement
|
||||||
spanLightY l x y z =
|
spanLightY l x y z =
|
||||||
@@ -188,7 +196,7 @@ spanLightY l x y z =
|
|||||||
sps0 $ f z
|
sps0 $ f z
|
||||||
where
|
where
|
||||||
f p = putShape $ thinHighBar h p (l + normalize (l-p))
|
f p = putShape $ thinHighBar h p (l + normalize (l-p))
|
||||||
h = 50
|
h = 95
|
||||||
|
|
||||||
--extendAway :: Point2 -> Point2 -> Point2
|
--extendAway :: Point2 -> Point2 -> Point2
|
||||||
--extendAway p x = p +.+ squashNormalizeV (p -.- x)
|
--extendAway p x = p +.+ squashNormalizeV (p -.- x)
|
||||||
|
|||||||
@@ -17,11 +17,18 @@ damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1) $
|
|||||||
PutMachine
|
PutMachine
|
||||||
(reverse $ square wdth)
|
(reverse $ square wdth)
|
||||||
( defaultMachine
|
( defaultMachine
|
||||||
|
& mcMaterial .~ mattype
|
||||||
& mcMounts . at OTTrigger .~ mtrid
|
& mcMounts . at OTTrigger .~ mtrid
|
||||||
& mcMounts . at OTLightSource ?~ lsid
|
& mcMounts . at OTLightSource ?~ lsid
|
||||||
& mcType .~ McDamSensor (DamSensor 0 dt)
|
& mcType .~ McDamSensor (DamSensor 0 dt)
|
||||||
)
|
)
|
||||||
Nothing
|
Nothing
|
||||||
|
where
|
||||||
|
mattype = case dt of
|
||||||
|
LaserSensor -> Photovoltaic
|
||||||
|
ElectricSensor -> LightningRod
|
||||||
|
ThermalSensor -> Pyroelectric
|
||||||
|
PhysicalSensor -> Piezoelectric
|
||||||
|
|
||||||
lightSensor :: Float -> Maybe Int -> PlacementSpot -> Placement
|
lightSensor :: Float -> Maybe Int -> PlacementSpot -> Placement
|
||||||
lightSensor = damageSensor LaserSensor
|
lightSensor = damageSensor LaserSensor
|
||||||
|
|||||||
@@ -27,15 +27,13 @@ import LensHelp
|
|||||||
import Linear
|
import Linear
|
||||||
import NewInt
|
import NewInt
|
||||||
|
|
||||||
--import System.Random
|
|
||||||
|
|
||||||
-- when placing a placement, we update the world and the room and assign an id
|
-- when placing a placement, we update the world and the room and assign an id
|
||||||
-- to the placement. This id should be associated with the type of placement and
|
-- to the placement. This id should be associated with the type of placement and
|
||||||
-- match up with the created id for the object (creature id, flitid id, etc)
|
-- match up with the created id for the object (creature id, flitid id, etc)
|
||||||
placeSpot :: Int -> GenWorld -> Placement -> GenWorld
|
placeSpot :: Int -> GenWorld -> Placement -> GenWorld
|
||||||
placeSpot rid w plmnt = case plmnt ^. plSpot of
|
placeSpot rid w plmnt = case plmnt ^. plSpot of
|
||||||
PSRoomRand i f -> placeSpotRoomRand rid i f plmnt w
|
PSRoomRand i f -> placeSpotRoomRand rid i f plmnt w
|
||||||
PSPos extract eff fallback -> placeSpotUsingLink w rid plmnt extract eff fallback
|
PSPos extract eff fallback -> placeSpotUsingRoomPos w rid plmnt extract eff fallback
|
||||||
_ -> placePlainPSSpot w rid plmnt shift
|
_ -> placePlainPSSpot w rid plmnt shift
|
||||||
where
|
where
|
||||||
shift = _rmShift $ w ^?! genRooms . ix rid
|
shift = _rmShift $ w ^?! genRooms . ix rid
|
||||||
@@ -64,7 +62,7 @@ placePlainPSSpot w rid plmnt shift = case plmnt ^. plType of
|
|||||||
(w' & genRooms . ix rid . rmPmnts .:~ newplmnt)
|
(w' & genRooms . ix rid . rmPmnts .:~ newplmnt)
|
||||||
|
|
||||||
-- this should be tidied up
|
-- this should be tidied up
|
||||||
placeSpotUsingLink ::
|
placeSpotUsingRoomPos ::
|
||||||
GenWorld ->
|
GenWorld ->
|
||||||
Int ->
|
Int ->
|
||||||
Placement ->
|
Placement ->
|
||||||
@@ -72,7 +70,7 @@ placeSpotUsingLink ::
|
|||||||
(RoomPos -> Room -> Room) ->
|
(RoomPos -> Room -> Room) ->
|
||||||
Maybe Placement ->
|
Maybe Placement ->
|
||||||
GenWorld
|
GenWorld
|
||||||
placeSpotUsingLink w rid plmnt extract eff fallback =
|
placeSpotUsingRoomPos w rid plmnt extract eff fallback =
|
||||||
case searchedPoss (w ^?! genRooms . ix rid . rmPos) of
|
case searchedPoss (w ^?! genRooms . ix rid . rmPos) of
|
||||||
Just (ps, rmposs) ->
|
Just (ps, rmposs) ->
|
||||||
placeSpot
|
placeSpot
|
||||||
@@ -199,7 +197,7 @@ plMachine ::
|
|||||||
plMachine wallpoly mc mitm p rot gw =
|
plMachine wallpoly mc mitm p rot gw =
|
||||||
( mcid
|
( mcid
|
||||||
, gw & tolw . machines . at mcid ?~ themc
|
, gw & tolw . machines . at mcid ?~ themc
|
||||||
& gwWorld %~ placeMachineWalls wallpoly mcid wlid
|
& gwWorld %~ placeMachineWalls (_mcMaterial mc) wallpoly mcid wlid
|
||||||
& tolw %~ maybe id placeturretitm mitm
|
& tolw %~ maybe id placeturretitm mitm
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@@ -215,10 +213,11 @@ plMachine wallpoly mc mitm p rot gw =
|
|||||||
itid = IM.newKey $ gw ^. gwWorld . cWorld . lWorld . items
|
itid = IM.newKey $ gw ^. gwWorld . cWorld . lWorld . items
|
||||||
itm' = itm & itID .~ NInt itid & itLocation .~ OnTurret mcid
|
itm' = itm & itID .~ NInt itid & itLocation .~ OnTurret mcid
|
||||||
|
|
||||||
placeMachineWalls :: [Point2] -> Int -> Int -> World -> World
|
placeMachineWalls :: Material -> [Point2] -> Int -> Int -> World -> World
|
||||||
placeMachineWalls poly mcid = insertStructureWalls MachinePart baseWall poly mcid
|
placeMachineWalls mat poly mcid = insertStructureWalls MachinePart baseWall poly mcid
|
||||||
where
|
where
|
||||||
baseWall = defaultMachineWall & wlStructure . wsMachine .~ mcid
|
baseWall = defaultMachineWall & wlStructure . wsMachine .~ mcid
|
||||||
|
& wlMaterial .~ mat
|
||||||
|
|
||||||
mvLS :: Point3 -> Float -> LightSource -> LightSource
|
mvLS :: Point3 -> Float -> LightSource -> LightSource
|
||||||
mvLS (V3 x y z) rot ls = ls & lsParam . lsPos .~ V3 x y z + startPos
|
mvLS (V3 x y z) rot ls = ls & lsParam . lsPos .~ V3 x y z + startPos
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ decontamRoom i =
|
|||||||
]
|
]
|
||||||
-- & rmOutPmnt . at i ?~
|
-- & rmOutPmnt . at i ?~
|
||||||
-- analyser (NoItemZone ps) (PS 50 0) (PS mcpos 0)
|
-- analyser (NoItemZone ps) (PS 50 0) (PS mcpos 0)
|
||||||
& rmInPmnt .~ [(0, f)]
|
& rmInPmnt .~ [(0, return . f)]
|
||||||
& rmBound .~ [rectNSWE 75 15 0 40, switchcut]
|
& rmBound .~ [rectNSWE 75 15 0 40, switchcut]
|
||||||
where
|
where
|
||||||
f gw = fromMaybe (error "tried to put a door using an empty placement list") $ do
|
f gw = fromMaybe (error "tried to put a door using an empty placement list") $ do
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
--{-# LANGUAGE TupleSections #-}
|
-- {-# LANGUAGE TupleSections #-}
|
||||||
module Dodge.Room.Containing where
|
module Dodge.Room.Containing where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Item.Display
|
import Dodge.Item.Display
|
||||||
@@ -15,14 +16,13 @@ import Dodge.Tree
|
|||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
import Control.Monad
|
|
||||||
|
|
||||||
roomsContaining :: RandomGen g => [Creature] -> [Item] -> State g (MetaTree Room String)
|
roomsContaining :: (RandomGen g) => [Creature] -> [Item] -> State g (MetaTree Room String)
|
||||||
roomsContaining crs its = tToBTree str <$> roomsContaining' crs its
|
roomsContaining crs its = tToBTree str <$> roomsContaining' crs its
|
||||||
where
|
where
|
||||||
str = "roomsContaining " ++ concatMap _crName crs ++ concatMap (head . basicItemDisplay) its
|
str = "roomsContaining " ++ concatMap _crName crs ++ concatMap (head . basicItemDisplay) its
|
||||||
|
|
||||||
roomsContaining' :: RandomGen g => [Creature] -> [Item] -> State g (Tree Room)
|
roomsContaining' :: (RandomGen g) => [Creature] -> [Item] -> State g (Tree Room)
|
||||||
roomsContaining' crs its = do
|
roomsContaining' crs its = do
|
||||||
endroom <-
|
endroom <-
|
||||||
join $
|
join $
|
||||||
@@ -36,7 +36,7 @@ roomsContaining' crs its = do
|
|||||||
]
|
]
|
||||||
return (pure $ cleatOnward endroom)
|
return (pure $ cleatOnward endroom)
|
||||||
|
|
||||||
roomPillarsContaining :: RandomGen g => [Creature] -> [Item] -> State g Room
|
roomPillarsContaining :: (RandomGen g) => [Creature] -> [Item] -> State g Room
|
||||||
roomPillarsContaining crs itms = do
|
roomPillarsContaining crs itms = do
|
||||||
(w, wn) <- takeOne [(240, 2), (340, 3)]
|
(w, wn) <- takeOne [(240, 2), (340, 3)]
|
||||||
(h, hn) <- takeOne [(240, 2), (340, 3)]
|
(h, hn) <- takeOne [(240, 2), (340, 3)]
|
||||||
@@ -47,7 +47,7 @@ crsItmsUnused crs itms =
|
|||||||
map (\it -> sps0 (PutFlIt it) & plSpot .~ anyUnusedSpot) itms
|
map (\it -> sps0 (PutFlIt it) & plSpot .~ anyUnusedSpot) itms
|
||||||
++ map (\cr -> sps0 (PutCrit cr) & plSpot .~ unusedSpotAwayFromLink 50) crs
|
++ map (\cr -> sps0 (PutCrit cr) & plSpot .~ unusedSpotAwayFromLink 50) crs
|
||||||
|
|
||||||
pedestalRoom :: RandomGen g => Item -> State g Room
|
pedestalRoom :: (RandomGen g) => Item -> State g Room
|
||||||
pedestalRoom it = do
|
pedestalRoom it = do
|
||||||
let flit = PutFlIt it
|
let flit = PutFlIt it
|
||||||
x <- state $ randomR (150, 250)
|
x <- state $ randomR (150, 250)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ triggerDoorRoom i =
|
|||||||
-- note no bounds
|
-- note no bounds
|
||||||
}
|
}
|
||||||
where
|
where
|
||||||
f gw = fromMaybe (error "tried to put a door using an empty placement list") $ do
|
f gw = return $ fromMaybe (error "tried to put a door using an empty placement list") $ do
|
||||||
pmnt <- gw ^? genPmnt . ix i
|
pmnt <- gw ^? genPmnt . ix i
|
||||||
return $ putDoubleDoor defaultDoorWall (cond pmnt) (V2 0 20) (V2 40 20) 2
|
return $ putDoubleDoor defaultDoorWall (cond pmnt) (V2 0 20) (V2 40 20) 2
|
||||||
cond pmnt = WdTrig $ fromJust (_plMID pmnt)
|
cond pmnt = WdTrig $ fromJust (_plMID pmnt)
|
||||||
|
|||||||
+321
-215
@@ -13,11 +13,17 @@ module Dodge.Room.LasTurret (
|
|||||||
lasCenRunClose',
|
lasCenRunClose',
|
||||||
lasCenRunClose1,
|
lasCenRunClose1,
|
||||||
lasCenRunCloseLongCor,
|
lasCenRunCloseLongCor,
|
||||||
|
lasRunRand,
|
||||||
|
storeRoomID,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Foldable (fold)
|
import Dodge.Room.Modify
|
||||||
import Dodge.Room.Path
|
import Color
|
||||||
import Dodge.Room.Procedural
|
import Control.Monad
|
||||||
|
import Data.Foldable
|
||||||
|
import Data.Maybe
|
||||||
|
-- import Data.Foldable (fold)
|
||||||
|
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
@@ -30,6 +36,8 @@ import Dodge.Room.Corridor
|
|||||||
import Dodge.Room.Door
|
import Dodge.Room.Door
|
||||||
import Dodge.Room.Link
|
import Dodge.Room.Link
|
||||||
import Dodge.Room.Ngon
|
import Dodge.Room.Ngon
|
||||||
|
import Dodge.Room.Path
|
||||||
|
import Dodge.Room.Procedural
|
||||||
import Dodge.Room.SensorDoor
|
import Dodge.Room.SensorDoor
|
||||||
import Dodge.RoomLink
|
import Dodge.RoomLink
|
||||||
import Dodge.Tree
|
import Dodge.Tree
|
||||||
@@ -37,47 +45,49 @@ import Dodge.Wire
|
|||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
|
import Shape
|
||||||
|
|
||||||
|
-- no lights!
|
||||||
cenLasTur :: (RandomGen g) => State g Room
|
cenLasTur :: (RandomGen g) => State g Room
|
||||||
cenLasTur = do
|
cenLasTur = do
|
||||||
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
|
||||||
roomNgon 8 200
|
roomNgon 8 200
|
||||||
<&> rmPmnts
|
<&> rmPmnts
|
||||||
.~ [ putLasTurret 0.02
|
.~ [ putLasTurret 0.02
|
||||||
, heightWallPS
|
, heightWallPS
|
||||||
(resetPLUse $ rprBoolShift (const . isInLnk) (shiftInBy 100 <&> (,S.singleton UsedPosLow)))
|
(resetPLUse $ rprBoolShift (const . isInLnk) (shiftInBy 120 <&> (,S.singleton UsedPosLow)))
|
||||||
30
|
30
|
||||||
covershape
|
(rectWH 20 10)
|
||||||
, thelight
|
|
||||||
]
|
]
|
||||||
where
|
<&> rmPath
|
||||||
covershape = rectNSWE 10 (-10) (-20) 20
|
%~ addNodesCrossingCirc 0 30
|
||||||
|
|
||||||
lightSensInsideDoor :: Int -> Room -> Room
|
lightSensInsideDoor :: Int -> Room -> Room
|
||||||
lightSensInsideDoor i rm =
|
lightSensInsideDoor i =
|
||||||
rm
|
rmPmnts
|
||||||
& rmPmnts
|
.++~ [ psPt atFstLnkOut (PutForeground $ floorWire (V2 20 0) (V2 20 (-x)))
|
||||||
.++~ [ psPt atFstLnkOut (PutForeground $ floorWire (V2 20 0) (V2 20 (-100)))
|
, psPt atFstLnkOut (PutForeground $ floorWire (V2 0 (-x)) (V2 20 (-x)))
|
||||||
, psPt atFstLnkOut (PutForeground $ floorWire (V2 0 (-100)) (V2 20 (-100)))
|
|
||||||
, psPt atFstLnkOut (PutForeground $ verticalWire (V2 20 0) 0 80)
|
, psPt atFstLnkOut (PutForeground $ verticalWire (V2 20 0) 0 80)
|
||||||
, sensAboveDoor LaserSensor 10 (atFstLnkOutShiftInward 100) & plExternalID ?~ i
|
, sensAboveDoor LaserSensor 10 (atFstLnkOutShiftInward x) & plExternalID ?~ i
|
||||||
]
|
]
|
||||||
|
where
|
||||||
|
x = 120
|
||||||
|
|
||||||
-- & rmOutPmnt . at i ?~ sensAboveDoor LaserSensor 10 (atFstLnkOutShiftInward 100)
|
-- & rmOutPmnt . at i ?~ sensAboveDoor LaserSensor 10 (atFstLnkOutShiftInward 100)
|
||||||
|
|
||||||
lightSensByDoor :: Int -> Room -> Room
|
lightSensByDoor :: Int -> Room -> State LayoutVars Room
|
||||||
lightSensByDoor i rm =
|
lightSensByDoor i rm = do
|
||||||
rm
|
x <- takeOne [100, 120, 140]
|
||||||
& rmPmnts
|
y <- takeOne [100, 110, 120]
|
||||||
.++~ [ psPt atFstLnkOut $ PutForeground $ verticalWire (V2 20 0) 0 80
|
sh1 <- takeOne [rectWH 20 10, square 20]
|
||||||
, heightWallPS (atNthLnkOutShiftInward 1 100) 30 covershape
|
return $
|
||||||
, heightWallPS (atFstLnkOutShiftInward 100) 30 covershape
|
rm
|
||||||
, sensAboveDoor LaserSensor 20 (atFstLnkOutShiftBy sensorshift) & plExternalID ?~ i
|
& rmPmnts
|
||||||
]
|
.++~ [ psPt atFstLnkOut $ PutForeground $ verticalWire (V2 20 0) 0 80
|
||||||
|
, heightWallPS (atNthLnkOutShiftInward 1 x) 30 sh1
|
||||||
|
, heightWallPS (atFstLnkOutShiftInward y) 30 (rectWH 20 10)
|
||||||
|
, sensAboveDoor LaserSensor 20 (atFstLnkOutShiftBy sensorshift) & plExternalID ?~ i
|
||||||
|
]
|
||||||
where
|
where
|
||||||
-- & rmOutPmnt . at i ?~ sensAboveDoor LaserSensor 20 (atFstLnkOutShiftBy sensorshift)
|
|
||||||
|
|
||||||
covershape = rectNSWE 10 (-10) (-20) 20
|
|
||||||
sensorshift (p, a) = ((p +.+ rotateV a (V2 60 (-20)), a), S.singleton UsedPosLow)
|
sensorshift (p, a) = ((p +.+ rotateV a (V2 60 (-20)), a), S.singleton UsedPosLow)
|
||||||
|
|
||||||
keyCardRoomRunPast :: (RandomGen g) => Int -> Int -> State g (MetaTree Room String)
|
keyCardRoomRunPast :: (RandomGen g) => Int -> Int -> State g (MetaTree Room String)
|
||||||
@@ -129,276 +139,372 @@ healthTest n = do
|
|||||||
, cleatOnward door
|
, cleatOnward door
|
||||||
]
|
]
|
||||||
|
|
||||||
lasSensorTurretTest :: (RandomGen g) => Int -> State g (MetaTree Room String)
|
lasSensorTurretTest :: State LayoutVars (MetaTree Room String)
|
||||||
lasSensorTurretTest n = do
|
lasSensorTurretTest = do
|
||||||
cenroom <- shuffleLinks . lightSensInsideDoor n =<< cenLasTur
|
n <- nextLayoutInt
|
||||||
|
cenroom' <- shuffleLinks . lightSensInsideDoor n =<< cenLasTur
|
||||||
|
(i, cenroom'') <- storeRoomID cenroom'
|
||||||
|
lshape <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
|
let alight a rp = mntLSCond (fmap (fmap $ colorSH black) lshape) (PS (rotateV a $ _rpPos rp) (a + _rpDir rp))
|
||||||
|
let cenroom =
|
||||||
|
cenroom''
|
||||||
|
& rmInPmnt
|
||||||
|
<>~ [ (0, return . alight pi . f i)
|
||||||
|
, (0, return . alight (0.5 * pi) . f i)
|
||||||
|
, (0, return . alight (1.5 * pi) . f i)
|
||||||
|
]
|
||||||
rToOnward "lasSensorTurretTest" $
|
rToOnward "lasSensorTurretTest" $
|
||||||
treePost
|
treePost
|
||||||
[door, cenroom, triggerDoorRoom n, cleatOnward door]
|
[door, cenroom, triggerDoorRoom n, cleatOnward door]
|
||||||
|
where
|
||||||
|
f i gw = fromJust $ find (isused . _rpType) (getRoomFromID i gw ^. rmPos)
|
||||||
|
isused UsedOutLink{_rplsChildNum = 0} = True
|
||||||
|
isused _ = False
|
||||||
|
|
||||||
lasCenSensEdge :: (RandomGen g) => Int -> State g (MetaTree Room String)
|
-- note the double usage of the int, shouldn't cause a problem
|
||||||
|
lasCenSensEdge :: Int -> State LayoutVars (MetaTree Room String)
|
||||||
lasCenSensEdge n = do
|
lasCenSensEdge n = do
|
||||||
cenroom <- shuffleLinks . lightSensByDoor n =<< cenLasTur
|
(i, cenroom') <- storeRoomID =<< shuffleLinks =<< lightSensByDoor n =<< cenLasTur
|
||||||
|
lshape <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
|
let alight a rp = mntLSCond (fmap (fmap $ colorSH black) lshape) (PS (rotateV a $ _rpPos rp) (a + _rpDir rp))
|
||||||
|
blight a = (0, return . alight a . f i)
|
||||||
|
let cenroom = cenroom' & rmInPmnt <>~ map blight [pi, (0.5 * pi), (1.5 * pi)]
|
||||||
let doorroom = triggerDoorRoom n
|
let doorroom = triggerDoorRoom n
|
||||||
rToOnward "lasCenSensEdge" $
|
rToOnward "lasCenSensEdge" $
|
||||||
treeFromTrunk [door] $
|
treeFromTrunk [door] $
|
||||||
Node
|
Node
|
||||||
cenroom
|
cenroom
|
||||||
[ treePost [doorroom, cleatOnward door]
|
[ treePost [doorroom, cleatOnward door]
|
||||||
, treePost [door, cleatLabel 0 corridor]
|
, treePost [door, cleatLabel n corridor]
|
||||||
]
|
]
|
||||||
|
where
|
||||||
|
f i gw = fromJust $ find (isused . _rpType) (getRoomFromID i gw ^. rmPos)
|
||||||
|
isused UsedOutLink{_rplsChildNum = 0} = True
|
||||||
|
isused _ = False
|
||||||
|
|
||||||
|
|
||||||
lasRunYinYang :: (RandomGen g) => State g (MetaTree Room String)
|
lasRunYinYang :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasRunYinYang = do
|
lasRunYinYang = do
|
||||||
npoly <- takeOne [6,8,10,12]
|
npoly <- takeOne [6, 8, 10, 12]
|
||||||
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
||||||
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
||||||
thelight2 <- mntLightLnkCond $ rprBool $ const . (\rp -> PolyEdge ((npoly + 1) `div` 4) `S.member`
|
thelight2 <-
|
||||||
(fold $ rp ^? rpType . rplsType))
|
mntLightLnkCond $
|
||||||
thelight3 <- mntLightLnkCond $ rprBool $ const . (\rp -> PolyEdge (3*(npoly + 1) `div` 4) `S.member`
|
rprBool $
|
||||||
(fold $ rp ^? rpType . rplsType))
|
const
|
||||||
r <- shuffleLinks =<<
|
. ( \rp ->
|
||||||
(roomNgon npoly 250
|
PolyEdge ((npoly + 1) `div` 4)
|
||||||
<&> rmPmnts
|
`S.member` (fold $ rp ^? rpType . rplsType)
|
||||||
.~
|
)
|
||||||
[angwall a | a <- [0,pi/8..pi-pi/9]] <>
|
thelight3 <-
|
||||||
[bngwall a | a <- [0,pi/8..pi-pi/9]] <>
|
mntLightLnkCond $
|
||||||
[ awall 0 (rectWH 15 5)
|
rprBool $
|
||||||
, putLasTurret 0.02 & plSpot . psPos .~ negate offxy
|
const
|
||||||
, putLasTurret 0.02 & plSpot . psPos .~ offxy
|
. ( \rp ->
|
||||||
-- , awall (V2 0 50) (square 10)
|
PolyEdge (3 * (npoly + 1) `div` 4)
|
||||||
, thelight
|
`S.member` (fold $ rp ^? rpType . rplsType)
|
||||||
, thelight1
|
)
|
||||||
, thelight2
|
r <-
|
||||||
, thelight3
|
shuffleLinks
|
||||||
]
|
=<< ( roomNgon npoly 250
|
||||||
<&> rmPath %~ (addNodesCrossingCirc 0 30
|
<&> rmPmnts
|
||||||
. flip (foldr ($)) [apath a | a <- [0,pi/8..pi-2*pi/9]]
|
.~ [angwall a | a <- [0, pi / 8 .. pi - pi / 9]]
|
||||||
. flip (foldr ($)) [bpath a | a <- [0,pi/8..pi-2*pi/9]]
|
<> [bngwall a | a <- [0, pi / 8 .. pi - pi / 9]]
|
||||||
)
|
<> [ awall 0 (rectWH 15 5)
|
||||||
<&> rmLinks %~ setInLinksByType (PolyEdge 0)
|
, putLasTurret 0.02 & plSpot . psPos .~ negate offxy
|
||||||
<&> rmLinks %~ setOutLinksByType (PolyEdge (npoly `div` 2))
|
, putLasTurret 0.02 & plSpot . psPos .~ offxy
|
||||||
)
|
, -- , awall (V2 0 50) (square 10)
|
||||||
|
thelight
|
||||||
|
, thelight1
|
||||||
|
, thelight2
|
||||||
|
, thelight3
|
||||||
|
]
|
||||||
|
<&> rmPath
|
||||||
|
%~ ( addNodesCrossingCirc 0 30
|
||||||
|
. flip (foldr ($)) [apath a | a <- [0, pi / 8 .. pi - 2 * pi / 9]]
|
||||||
|
. flip (foldr ($)) [bpath a | a <- [0, pi / 8 .. pi - 2 * pi / 9]]
|
||||||
|
)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setInLinksByType (PolyEdge 0)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setOutLinksByType (PolyEdge (npoly `div` 2))
|
||||||
|
)
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
awall x v = heightWallPS (PS x 0) 30 v
|
awall x v = heightWallPS (PS x 0) 30 v
|
||||||
--angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a/2)) $ rectWH 5 (25 - a*10/pi ))
|
-- angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a/2)) $ rectWH 5 (25 - a*10/pi ))
|
||||||
rf = 0.8
|
rf = 0.8
|
||||||
offxy = V2 0 (-100)
|
offxy = V2 0 (-100)
|
||||||
angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a*rf)) $ rectWH 5 (23 - a*13/pi ))
|
angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi / 4 + a * rf)) $ rectWH 5 (23 - a * 13 / pi))
|
||||||
apath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100),x - f (V2 0 100))) (V2 0 100 + rotateV a (V2 0 100))
|
apath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100), x - f (V2 0 100))) (V2 0 100 + rotateV a (V2 0 100))
|
||||||
where
|
where
|
||||||
a = a' + pi/16
|
a = a' + pi / 16
|
||||||
f = rotateV (pi/4 + a *0.8)
|
f = rotateV (pi / 4 + a * 0.8)
|
||||||
bngwall a = awall (V2 0 (-100) + rotateV a (V2 0 (-100))) (fmap (rotateV (pi/4 + a*rf)) $ rectWH 5 (23 - a*13/pi ))
|
bngwall a = awall (V2 0 (-100) + rotateV a (V2 0 (-100))) (fmap (rotateV (pi / 4 + a * rf)) $ rectWH 5 (23 - a * 13 / pi))
|
||||||
bpath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100),x - f (V2 0 100))) (V2 0 (-100) + rotateV a (V2 0 (-100)))
|
bpath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100), x - f (V2 0 100))) (V2 0 (-100) + rotateV a (V2 0 (-100)))
|
||||||
where
|
where
|
||||||
a = a' + pi/16
|
a = a' + pi / 16
|
||||||
f = rotateV (pi/4 + a *0.8)
|
f = rotateV (pi / 4 + a * 0.8)
|
||||||
|
|
||||||
lasRunYinYangCenter :: (RandomGen g) => State g (MetaTree Room String)
|
lasRunYinYangCenter :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasRunYinYangCenter = do
|
lasRunYinYangCenter = do
|
||||||
npoly <- takeOne [6,8,10,12]
|
npoly <- takeOne [6, 8, 10, 12]
|
||||||
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
||||||
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
||||||
thelight2 <- mntLightLnkCond $ rprBool $ const . (\rp -> PolyEdge ((npoly + 1) `div` 4) `S.member`
|
thelight2 <-
|
||||||
(fold $ rp ^? rpType . rplsType))
|
mntLightLnkCond $
|
||||||
thelight3 <- mntLightLnkCond $ rprBool $ const . (\rp -> PolyEdge (3*(npoly + 1) `div` 4) `S.member`
|
rprBool $
|
||||||
(fold $ rp ^? rpType . rplsType))
|
const
|
||||||
-- thelight3 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
. ( \rp ->
|
||||||
r <- shuffleLinks =<<
|
PolyEdge ((npoly + 1) `div` 4)
|
||||||
(roomNgon npoly 250
|
`S.member` (fold $ rp ^? rpType . rplsType)
|
||||||
<&> rmPmnts
|
)
|
||||||
.~
|
thelight3 <-
|
||||||
[angwall a | a <- [0,pi/8..pi-pi/9]] <>
|
mntLightLnkCond $
|
||||||
[bngwall a | a <- [0,pi/8..pi-pi/9]] <>
|
rprBool $
|
||||||
[ putLasTurret 0.02
|
const
|
||||||
-- , awall (V2 0 50) (square 10)
|
. ( \rp ->
|
||||||
, thelight
|
PolyEdge (3 * (npoly + 1) `div` 4)
|
||||||
, thelight1
|
`S.member` (fold $ rp ^? rpType . rplsType)
|
||||||
, thelight2
|
)
|
||||||
, thelight3
|
-- thelight3 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
||||||
]
|
r <-
|
||||||
<&> rmPath %~ (addNodesCrossingCirc 0 30
|
shuffleLinks
|
||||||
. flip (foldr ($)) [apath a | a <- [0,pi/8..pi-2*pi/9]]
|
=<< ( roomNgon npoly 250
|
||||||
. flip (foldr ($)) [bpath a | a <- [0,pi/8..pi-2*pi/9]]
|
<&> rmPmnts
|
||||||
)
|
.~ [angwall a | a <- [0, pi / 8 .. pi - pi / 9]]
|
||||||
<&> rmLinks %~ setInLinksByType (PolyEdge 0)
|
<> [bngwall a | a <- [0, pi / 8 .. pi - pi / 9]]
|
||||||
<&> rmLinks %~ setOutLinksByType (PolyEdge (npoly `div` 2))
|
<> [ putLasTurret 0.02
|
||||||
)
|
, -- , awall (V2 0 50) (square 10)
|
||||||
|
thelight
|
||||||
|
, thelight1
|
||||||
|
, thelight2
|
||||||
|
, thelight3
|
||||||
|
]
|
||||||
|
<&> rmPath
|
||||||
|
%~ ( addNodesCrossingCirc 0 30
|
||||||
|
. flip (foldr ($)) [apath a | a <- [0, pi / 8 .. pi - 2 * pi / 9]]
|
||||||
|
. flip (foldr ($)) [bpath a | a <- [0, pi / 8 .. pi - 2 * pi / 9]]
|
||||||
|
)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setInLinksByType (PolyEdge 0)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setOutLinksByType (PolyEdge (npoly `div` 2))
|
||||||
|
)
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
awall x v = heightWallPS (PS x 0) 30 v
|
awall x v = heightWallPS (PS x 0) 30 v
|
||||||
--angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a/2)) $ rectWH 5 (25 - a*10/pi ))
|
-- angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a/2)) $ rectWH 5 (25 - a*10/pi ))
|
||||||
angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi/4 + a*0.8)) $ rectWH 5 (23 - a*13/pi ))
|
angwall a = awall (V2 0 100 + rotateV a (V2 0 100)) (fmap (rotateV (pi / 4 + a * 0.8)) $ rectWH 5 (23 - a * 13 / pi))
|
||||||
apath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100),x - f (V2 0 100))) (V2 0 100 + rotateV a (V2 0 100))
|
apath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100), x - f (V2 0 100))) (V2 0 100 + rotateV a (V2 0 100))
|
||||||
where
|
where
|
||||||
a = a' + pi/16
|
a = a' + pi / 16
|
||||||
f = rotateV (pi/4 + a *0.8)
|
f = rotateV (pi / 4 + a * 0.8)
|
||||||
bngwall a = awall (V2 0 (-100) + rotateV a (V2 0 (-100))) (fmap (rotateV (pi/4 + a*0.8)) $ rectWH 5 (23 - a*13/pi ))
|
bngwall a = awall (V2 0 (-100) + rotateV a (V2 0 (-100))) (fmap (rotateV (pi / 4 + a * 0.8)) $ rectWH 5 (23 - a * 13 / pi))
|
||||||
bpath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100),x - f (V2 0 100))) (V2 0 (-100) + rotateV a (V2 0 (-100)))
|
bpath a' = addNodesCrossing $ (\x -> (x + f (V2 0 100), x - f (V2 0 100))) (V2 0 (-100) + rotateV a (V2 0 (-100)))
|
||||||
where
|
where
|
||||||
a = a' + pi/16
|
a = a' + pi / 16
|
||||||
f = rotateV (pi/4 + a *0.8)
|
f = rotateV (pi / 4 + a * 0.8)
|
||||||
|
|
||||||
lasCenRunClose' :: (RandomGen g) => State g (MetaTree Room String)
|
lasCenRunClose' :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasCenRunClose' = do
|
lasCenRunClose' = do
|
||||||
npoly <- takeOne [5..12]
|
npoly <- takeOne [5 .. 12]
|
||||||
inwall <- takeOne obwalls
|
inwall <- takeOne obwalls
|
||||||
outwall <- takeOne obwalls
|
outwall <- takeOne obwalls
|
||||||
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
thelight <- mntLightLnkCond $ rprBool $ const . isInLnk
|
||||||
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
thelight1 <- mntLightLnkCond $ rprBool $ const . isOutLnk
|
||||||
r <- shuffleLinks =<<
|
r <-
|
||||||
(roomNgon npoly 250
|
shuffleLinks
|
||||||
<&> rmPmnts
|
=<< ( roomNgon npoly 250
|
||||||
.~ (
|
<&> rmPmnts
|
||||||
fmap (uncurry inlinkwall) inwall <>
|
.~ ( fmap (uncurry inlinkwall) inwall
|
||||||
fmap (uncurry outlinkwall) outwall <>
|
<> fmap (uncurry outlinkwall) outwall
|
||||||
[ putLasTurret 0.02
|
<> [ putLasTurret 0.02
|
||||||
, thelight
|
, thelight
|
||||||
, thelight1
|
, thelight1
|
||||||
]
|
]
|
||||||
|
)
|
||||||
|
<&> rmPath
|
||||||
|
%~ addNodesCrossingCirc 0 30
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setInLinksByType (PolyEdge 0)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setOutLinks (\rl -> or [PolyEdge i `S.member` _rlType rl | i <- [2 .. npoly - 2]])
|
||||||
)
|
)
|
||||||
<&> rmPath %~ addNodesCrossingCirc 0 30
|
|
||||||
<&> rmLinks %~ setInLinksByType (PolyEdge 0)
|
|
||||||
<&> rmLinks %~ setOutLinks (\rl -> or [PolyEdge i `S.member` _rlType rl | i <- [2..npoly-2]])
|
|
||||||
)
|
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
swall = [ (70, (rectNSWE 10 (-10) (-10) 30))
|
swall =
|
||||||
, (125, (rectNSWE 55 (-55) (-10) 10))
|
[ (70, (rectNSWE 10 (-10) (-10) 30))
|
||||||
, (180, (rectNSWE 10 (-10) (-30) 10))
|
, (125, (rectNSWE 55 (-55) (-10) 10))
|
||||||
]
|
, (180, (rectNSWE 10 (-10) (-30) 10))
|
||||||
zwall = [ (70, (rectNSWE 10 (-10) (-30) 10))
|
]
|
||||||
, (125, (rectNSWE 55 (-55) (-10) 10))
|
zwall =
|
||||||
, (180, (rectNSWE 10 (-10) (-10) 30))
|
[ (70, (rectNSWE 10 (-10) (-30) 10))
|
||||||
]
|
, (125, (rectNSWE 55 (-55) (-10) 10))
|
||||||
iwall = [ (70, (rectNSWE 10 (-10) (-15) 20))
|
, (180, (rectNSWE 10 (-10) (-10) 30))
|
||||||
, (180, (rectNSWE 10 (-10) (-30) (-5)))
|
]
|
||||||
]
|
iwall =
|
||||||
jwall = [ (70, (rectNSWE 10 (-10) (-20) 15))
|
[ (70, (rectNSWE 10 (-10) (-15) 20))
|
||||||
, (180, (rectNSWE 10 (-10) 5 30))
|
, (180, (rectNSWE 10 (-10) (-30) (-5)))
|
||||||
]
|
]
|
||||||
uwall = [ (180, (rectNSWE 10 (-10) (-20) 20)) ]
|
jwall =
|
||||||
obwalls = [swall,zwall,iwall,jwall,uwall]
|
[ (70, (rectNSWE 10 (-10) (-20) 15))
|
||||||
linkwall f x = heightWallPS
|
, (180, (rectNSWE 10 (-10) 5 30))
|
||||||
(resetPLUse $ rprBoolShift (const . f) (shiftInBy x <&> (,S.singleton UsedPosLow)))
|
]
|
||||||
30
|
uwall = [(180, (rectNSWE 10 (-10) (-20) 20))]
|
||||||
|
obwalls = [swall, zwall, iwall, jwall, uwall]
|
||||||
|
linkwall f x =
|
||||||
|
heightWallPS
|
||||||
|
(resetPLUse $ rprBoolShift (const . f) (shiftInBy x <&> (,S.singleton UsedPosLow)))
|
||||||
|
30
|
||||||
inlinkwall = linkwall isInLnk
|
inlinkwall = linkwall isInLnk
|
||||||
outlinkwall = linkwall isOutLnk
|
outlinkwall = linkwall isOutLnk
|
||||||
|
|
||||||
lasCenRunCloseLongCor :: (RandomGen g) => State g (MetaTree Room String)
|
lasCenRunCloseLongCor :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasCenRunCloseLongCor = do
|
lasCenRunCloseLongCor = do
|
||||||
(alinks,blinks) <- shufflePair (rlinks,llinks)
|
(alinks, blinks) <- shufflePair (rlinks, llinks)
|
||||||
rdir <- takeOne [negate,id]
|
rdir <- takeOne [negate, id]
|
||||||
a <- takeOne [5*pi/16]
|
a <- takeOne [5 * pi / 16]
|
||||||
let h = 800
|
let h = 800
|
||||||
laspos <- takeOne [V2 (h/2) 80]
|
laspos <- takeOne [V2 (h / 2) 80]
|
||||||
ls <- mntLightLnkCond (PS (V2 (h/2) 0) pi)
|
ls <- mntLightLnkCond (PS (V2 (h / 2) 0) pi)
|
||||||
r <- shuffleLinks =<<
|
r <-
|
||||||
(roomRectAutoLights h 160
|
shuffleLinks
|
||||||
<&> rmPmnts
|
=<< ( roomRectAutoLights h 160
|
||||||
<>~ [ putLasTurret 0.02 & plSpot .~ PS laspos a
|
<&> rmPmnts
|
||||||
, awall (V2 (h /4) 80) (rotateV (rdir pi/16) <$> rectWH 180 10)
|
<>~ [ putLasTurret 0.02 & plSpot .~ PS laspos a
|
||||||
, awall (V2 (3*h/4) 80) (rotateV (rdir pi/16) <$> rectWH 180 10)
|
, awall (V2 (h / 4) 80) (rotateV (rdir pi / 16) <$> rectWH 180 10)
|
||||||
, ls
|
, awall (V2 (3 * h / 4) 80) (rotateV (rdir pi / 16) <$> rectWH 180 10)
|
||||||
]
|
, ls
|
||||||
<&> rmLinks %~ setInLinks alinks
|
]
|
||||||
<&> rmLinks %~ setOutLinks blinks
|
<&> rmLinks
|
||||||
<&> rmPath %~
|
%~ setInLinks alinks
|
||||||
(addNodesCrossing (V2 (h/2-10) 30,V2 (h/2+50) 90)
|
<&> rmLinks
|
||||||
.addNodesCrossing (V2 (h/2+10) 130,V2 (h/2-50) 70) )
|
%~ setOutLinks blinks
|
||||||
)
|
<&> rmPath
|
||||||
|
%~ ( addNodesCrossing (V2 (h / 2 - 10) 30, V2 (h / 2 + 50) 90)
|
||||||
|
. addNodesCrossing (V2 (h / 2 + 10) 130, V2 (h / 2 - 50) 70)
|
||||||
|
)
|
||||||
|
)
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
llinks = memtest (FromEdge South 1) (OnEdge West)
|
llinks = memtest (FromEdge South 1) (OnEdge West)
|
||||||
rlinks = memtest (FromEdge South 1) (OnEdge East)
|
rlinks = memtest (FromEdge South 1) (OnEdge East)
|
||||||
awall x v = heightWallPS (PS x 0) 30 v
|
awall x v = heightWallPS (PS x 0) 30 v
|
||||||
etest f g x = f x || g x
|
memtest a b x =
|
||||||
memtest a b x = let y = _rlType x
|
let y = _rlType x
|
||||||
in a `S.member` y && b `S.member` y
|
in a `S.member` y && b `S.member` y
|
||||||
|
|
||||||
lasCenRunClose1 :: (RandomGen g) => State g (MetaTree Room String)
|
lasCenRunClose1 :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasCenRunClose1 = do
|
lasCenRunClose1 = do
|
||||||
--(alinks,blinks) <- shufflePair (bllinks,brlinks)
|
-- (alinks,blinks) <- shufflePair (bllinks,brlinks)
|
||||||
--(alinks,blinks) <- shufflePair (bllinks,tmllink)
|
-- (alinks,blinks) <- shufflePair (bllinks,tmllink)
|
||||||
lnks <- shuffle [bllinks,brlinks,tmllink,tmrlink]
|
lnks <- shuffle [bllinks, brlinks, tmllink, tmrlink]
|
||||||
let alinks = lnks !! 0
|
let alinks = lnks !! 0
|
||||||
blinks = lnks !! 1
|
blinks = lnks !! 1
|
||||||
outwall <- takeOne [awall (V2 185 25) (rectWH 10 50)
|
outwall <-
|
||||||
, awall (V2 200 50) (rectWH 50 10) ]
|
takeOne
|
||||||
|
[ awall (V2 185 25) (rectWH 10 50)
|
||||||
|
, awall (V2 200 50) (rectWH 50 10)
|
||||||
|
]
|
||||||
let z = 35
|
let z = 35
|
||||||
r <- roomRectAutoLights 250 200
|
r <-
|
||||||
<&> rmPolys .~ [[V2 0 0, V2 250 0
|
roomRectAutoLights 250 200
|
||||||
, V2 250 (200-z)
|
<&> rmPolys
|
||||||
, V2 (250 - z) 200
|
.~ [
|
||||||
, V2 z 200
|
[ V2 0 0
|
||||||
, V2 0 (200-z)
|
, V2 250 0
|
||||||
]]
|
, V2 250 (200 - z)
|
||||||
|
, V2 (250 - z) 200
|
||||||
|
, V2 z 200
|
||||||
|
, V2 0 (200 - z)
|
||||||
|
]
|
||||||
|
]
|
||||||
<&> rmPmnts
|
<&> rmPmnts
|
||||||
<>~ [ putLasTurret 0.02 & plSpot .~ PS (V2 125 100) 0
|
<>~ [ putLasTurret 0.02 & plSpot .~ PS (V2 125 100) 0
|
||||||
, awall (V2 65 25) (rectWH 10 50)
|
, awall (V2 65 25) (rectWH 10 50)
|
||||||
, outwall
|
, outwall
|
||||||
, awall (V2 95 150) (rectWH 10 20)
|
, awall (V2 95 150) (rectWH 10 20)
|
||||||
, awall (V2 155 150) (rectWH 10 20)
|
, awall (V2 155 150) (rectWH 10 20)
|
||||||
, sps0 $ putConvexChasm $ rectNSWE 200 110 105 145
|
, sps0 $ putConvexChasm $ rectNSWE 200 110 105 145
|
||||||
-- , awall (V2 150 215) (rectWH 60 10)
|
-- , awall (V2 150 215) (rectWH 60 10)
|
||||||
]
|
]
|
||||||
<&> rmLinks %~ setInLinks alinks
|
<&> rmLinks
|
||||||
-- <&> rmLinks %~ setOutLinks (memtest (OnEdge South) (FromEdge West 3))
|
%~ setInLinks alinks
|
||||||
<&> rmLinks %~ setOutLinks blinks
|
-- <&> rmLinks %~ setOutLinks (memtest (OnEdge South) (FromEdge West 3))
|
||||||
<&> rmLinks . each %~ mvlinks
|
<&> rmLinks
|
||||||
<&> rmPath %~ S.map (both %~ mvpath)
|
%~ setOutLinks blinks
|
||||||
|
<&> rmLinks
|
||||||
|
. each
|
||||||
|
%~ mvlinks
|
||||||
|
<&> rmPath
|
||||||
|
%~ S.map (both %~ mvpath)
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
mvlinks lnk | tmllink lnk = lnk & rlPos -~ V2 20 0
|
mvlinks lnk
|
||||||
|
| tmllink lnk = lnk & rlPos -~ V2 20 0
|
||||||
| tmrlink lnk = lnk & rlPos +~ V2 20 0
|
| tmrlink lnk = lnk & rlPos +~ V2 20 0
|
||||||
| otherwise = lnk
|
| otherwise = lnk
|
||||||
mvpath (V2 x y) | y > 190 , x > 50 , x < 125 = V2 (x- 20) y
|
mvpath (V2 x y)
|
||||||
| y > 190 , x > 125 , x < 200 = V2 (x+ 20) y
|
| y > 190, x > 50, x < 125 = V2 (x - 20) y
|
||||||
|
| y > 190, x > 125, x < 200 = V2 (x + 20) y
|
||||||
| otherwise = V2 x y
|
| otherwise = V2 x y
|
||||||
tmllink = memtest (FromEdge West 1) (OnEdge North)
|
tmllink = memtest (FromEdge West 1) (OnEdge North)
|
||||||
tmrlink = memtest (FromEdge West 2) (OnEdge North)
|
tmrlink = memtest (FromEdge West 2) (OnEdge North)
|
||||||
bllinks = etest
|
bllinks =
|
||||||
(memtest (FromEdge West 0) (OnEdge South))
|
etest
|
||||||
(memtest (FromEdge South 0) (OnEdge West))
|
(memtest (FromEdge West 0) (OnEdge South))
|
||||||
brlinks = etest
|
(memtest (FromEdge South 0) (OnEdge West))
|
||||||
(memtest (FromEdge East 0) (OnEdge South))
|
brlinks =
|
||||||
(memtest (FromEdge South 0) (OnEdge East))
|
etest
|
||||||
|
(memtest (FromEdge East 0) (OnEdge South))
|
||||||
|
(memtest (FromEdge South 0) (OnEdge East))
|
||||||
awall x v = heightWallPS (PS x 0) 30 v
|
awall x v = heightWallPS (PS x 0) 30 v
|
||||||
etest f g x = f x || g x
|
etest f g x = f x || g x
|
||||||
memtest a b x = let y = _rlType x
|
memtest a b x =
|
||||||
in a `S.member` y && b `S.member` y
|
let y = _rlType x
|
||||||
|
in a `S.member` y && b `S.member` y
|
||||||
|
|
||||||
|
lasRunRand :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
|
lasRunRand = join $ takeOne [lasCenRunClose2, lasCenRunClose1]
|
||||||
|
|
||||||
lasCenRunClose2 :: (RandomGen g) => State g (MetaTree Room String)
|
lasCenRunClose2 :: (RandomGen g) => State g (MetaTree Room String)
|
||||||
lasCenRunClose2 = do
|
lasCenRunClose2 = do
|
||||||
(alinks,blinks) <- shufflePair (bllinks,trlinks)
|
(alinks, blinks) <- shufflePair (bllinks, trlinks)
|
||||||
a <- takeOne [3*pi/2,3*pi/4]
|
a <- takeOne [3 * pi / 2, 3 * pi / 4]
|
||||||
laspos <- takeOne [V2 60 190, V2 65 185]
|
laspos <- takeOne [V2 60 190, V2 65 185]
|
||||||
r <- shuffleLinks =<<
|
r <-
|
||||||
(roomRectAutoLights 250 250
|
shuffleLinks
|
||||||
<&> rmPmnts
|
=<< ( roomRectAutoLights 250 250
|
||||||
<>~ [ putLasTurret 0.02 & plSpot .~ PS laspos a
|
<&> rmPmnts
|
||||||
, awall (V2 35 100) (rectWH 10 60)
|
<>~ [ putLasTurret 0.02 & plSpot .~ PS laspos a
|
||||||
, awall (V2 150 215) (rectWH 60 10)
|
, awall (V2 35 100) (rectWH 10 60)
|
||||||
]
|
, awall (V2 150 215) (rectWH 60 10)
|
||||||
<&> rmLinks %~ setInLinks alinks
|
]
|
||||||
<&> rmLinks %~ setOutLinks blinks
|
<&> rmLinks
|
||||||
<&> rmPath %~ (addNodesCrossing (V2 110 170,V2 30 250)
|
%~ setInLinks alinks
|
||||||
.addNodesCrossing (V2 70 150,V2 10 210) )
|
<&> rmLinks
|
||||||
)
|
%~ setOutLinks blinks
|
||||||
|
<&> rmPath
|
||||||
|
%~ ( addNodesCrossing (V2 110 170, V2 30 250)
|
||||||
|
. addNodesCrossing (V2 70 150, V2 10 210)
|
||||||
|
)
|
||||||
|
)
|
||||||
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
rToOnward "lasCenRunClose" $ return $ cleatOnward r
|
||||||
where
|
where
|
||||||
bllinks = etest
|
bllinks =
|
||||||
(memtest (FromEdge West 0) (OnEdge South))
|
etest
|
||||||
(memtest (FromEdge South 0) (OnEdge West))
|
(memtest (FromEdge West 0) (OnEdge South))
|
||||||
trlinks = etest
|
(memtest (FromEdge South 0) (OnEdge West))
|
||||||
(memtest (FromEdge East 0) (OnEdge North))
|
trlinks =
|
||||||
(memtest (FromEdge North 0) (OnEdge East))
|
etest
|
||||||
|
(memtest (FromEdge East 0) (OnEdge North))
|
||||||
|
(memtest (FromEdge North 0) (OnEdge East))
|
||||||
awall x v = heightWallPS (PS x 0) 30 v
|
awall x v = heightWallPS (PS x 0) 30 v
|
||||||
etest f g x = f x || g x
|
etest f g x = f x || g x
|
||||||
memtest a b x = let y = _rlType x
|
memtest a b x =
|
||||||
in a `S.member` y && b `S.member` y
|
let y = _rlType x
|
||||||
|
in a `S.member` y && b `S.member` y
|
||||||
|
|
||||||
lasTunnel :: (RandomGen g) => Float -> State g Room
|
lasTunnel :: (RandomGen g) => Float -> State g Room
|
||||||
lasTunnel y = do
|
lasTunnel y = do
|
||||||
|
|||||||
@@ -1,4 +1,76 @@
|
|||||||
module Dodge.Room.Modify
|
module Dodge.Room.Modify (
|
||||||
( module Dodge.Room.Modify.Girder
|
module Dodge.Room.Modify.Girder,
|
||||||
) where
|
storeRoomID,
|
||||||
|
getRoomFromID,
|
||||||
|
addLightsNGon,
|
||||||
|
removeLights,
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Color
|
||||||
|
import Shape
|
||||||
|
import Dodge.Placement.Instance.LightSource
|
||||||
|
import Dodge.LevelGen.PlacementHelper
|
||||||
|
import LensHelp
|
||||||
|
import Dodge.Data.MetaTree
|
||||||
|
import RandomHelp
|
||||||
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Room.Modify.Girder
|
import Dodge.Room.Modify.Girder
|
||||||
|
import qualified Data.Set as S
|
||||||
|
import Data.Maybe
|
||||||
|
import Geometry
|
||||||
|
import Data.Foldable
|
||||||
|
|
||||||
|
storeRoomID :: Room -> State LayoutVars (Int, Room)
|
||||||
|
storeRoomID x = do
|
||||||
|
i <- nextLayoutInt
|
||||||
|
return (i, x & rmPmnts .:~ sps0 (PutWorldUpdate (f i)))
|
||||||
|
where
|
||||||
|
f i rid _ gw = gw & genInts . at i ?~ (gw ^?! genRooms . ix rid . rmMID . _Just)
|
||||||
|
|
||||||
|
-- unsafe! assumes that storeRoomID has been called
|
||||||
|
getRoomFromID :: Int -> GenWorld -> Room
|
||||||
|
getRoomFromID i gw = gw ^?! genRooms . ix (gw ^?! genInts . ix i)
|
||||||
|
|
||||||
|
removeLights :: Room -> Room
|
||||||
|
removeLights = rmPmnts %~ mapMaybe f
|
||||||
|
where
|
||||||
|
f x = case x ^. plType of
|
||||||
|
PutLabel "light" -> Nothing
|
||||||
|
_ -> Just x
|
||||||
|
|
||||||
|
addLightsNGon :: Room -> State LayoutVars Room
|
||||||
|
addLightsNGon rm = do
|
||||||
|
(i, rm') <- storeRoomID $ removeLights rm
|
||||||
|
return $
|
||||||
|
rm'
|
||||||
|
& rmInPmnt
|
||||||
|
.:~ (0, f i)
|
||||||
|
where
|
||||||
|
a = 2 * pi - (2 * pi / fromIntegral (rm ^?! rmType . rmngonSides))
|
||||||
|
y = rm ^?! rmType . rmngonSize
|
||||||
|
x = y * tan (0.5 * a)
|
||||||
|
f i gw = do
|
||||||
|
lshape <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
|
let ps = fromMaybe (PS (V2 y 0) 0) $ rpToPS <$> find iscolorlight (grm ^. rmPos)
|
||||||
|
alight a' = mntLSCond (fmap (fmap $ colorSH black) lshape) (rotateps a' ps)
|
||||||
|
takeOne
|
||||||
|
[ spanLightY (V2 0 0) (V2 y x) (V2 (x) y) (V2 (x) (-y))
|
||||||
|
, spanLightY (V2 20 20) (V2 y 20) (V2 (-y) 20) (V2 20 (-y))
|
||||||
|
, spanLightI (V2 22 y) (V2 22 (-y))
|
||||||
|
, spanLightI (V2 x y) (V2 (-x) (-y))
|
||||||
|
, alight (0.5 * pi) <> alight (1.5 * pi)
|
||||||
|
]
|
||||||
|
where
|
||||||
|
grm = getRoomFromID i gw
|
||||||
|
rotateps a' (PS v d) = PS (rotateV a' v) (a' + d)
|
||||||
|
rotateps _ _ = error "in addLightsNGon"
|
||||||
|
rpToPS rp = (PS (_rpPos rp) (_rpDir rp))
|
||||||
|
iscolorlight rp =
|
||||||
|
(ColoredLightRP `S.member` (rp ^. rpFlags))
|
||||||
|
&& islinkroompos rp
|
||||||
|
islinkroompos rp = case rp ^. rpType of
|
||||||
|
UsedOutLink{} -> True
|
||||||
|
UsedInLink{} -> True
|
||||||
|
UnusedLink{} -> True
|
||||||
|
NotLink{} -> False
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ roomNgon n x = do
|
|||||||
, _rmPmnts = [thelight]
|
, _rmPmnts = [thelight]
|
||||||
, _rmBound = [poly]
|
, _rmBound = [poly]
|
||||||
, _rmFloor = Tiled [makeTileFromPoly poly 2]
|
, _rmFloor = Tiled [makeTileFromPoly poly 2]
|
||||||
|
, _rmType = RoomNgon n x
|
||||||
--, _rmFloor = InheritFloor
|
--, _rmFloor = InheritFloor
|
||||||
, _rmName = show n ++ "gon"
|
, _rmName = show n ++ "gon"
|
||||||
, _rmPos = poss
|
, _rmPos = poss
|
||||||
|
|||||||
@@ -118,8 +118,9 @@ gridRoomPos xs ys = map makeonpos (grid xs ys) <> map makeoffpos (grid (mids xs)
|
|||||||
-- to do so)
|
-- to do so)
|
||||||
roomRectAutoLights :: RandomGen g => Float -> Float -> State g Room
|
roomRectAutoLights :: RandomGen g => Float -> Float -> State g Room
|
||||||
roomRectAutoLights x y = do
|
roomRectAutoLights x y = do
|
||||||
l1 <- mntLightLnkCond $ resetPLUse $ rprBool $ \rp _ -> isInLnk rp
|
shp <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
l2 <- mntLightLnkCond $ resetPLUse $ rprBool $ \rp _ -> isOutLnk rp
|
let l1 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> isInLnk rp
|
||||||
|
l2 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> isOutLnk rp
|
||||||
return $ roomRect x y (f x) (f y)
|
return $ roomRect x y (f x) (f y)
|
||||||
& rmName .~ "autoRect"
|
& rmName .~ "autoRect"
|
||||||
& rmPmnts .~ [ l1 , l2 ]
|
& rmPmnts .~ [ l1 , l2 ]
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ module Dodge.Room.Room (
|
|||||||
critDeadEnd,
|
critDeadEnd,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
import Data.Maybe
|
||||||
import Linear
|
import Linear
|
||||||
import Color
|
import Color
|
||||||
import Dodge.Placement.Instance.Pipe
|
import Dodge.Placement.Instance.Pipe
|
||||||
@@ -154,7 +155,7 @@ roomCenterPillar = do
|
|||||||
roomRect 240 240 2 2
|
roomRect 240 240 2 2
|
||||||
)
|
)
|
||||||
|
|
||||||
weaponEmptyRoom :: State StdGen (Tree Room)
|
weaponEmptyRoom :: RandomGen g => State g (Tree Room)
|
||||||
weaponEmptyRoom = do
|
weaponEmptyRoom = do
|
||||||
w <- state $ randomR (220, 300)
|
w <- state $ randomR (220, 300)
|
||||||
h <- state $ randomR (220, 300)
|
h <- state $ randomR (220, 300)
|
||||||
@@ -209,7 +210,7 @@ weaponBehindPillar = do
|
|||||||
, cleatOnward $ set rmPmnts [sPS (V2 20 60) (negate $ pi / 2) randC1] corridorN
|
, cleatOnward $ set rmPmnts [sPS (V2 20 60) (negate $ pi / 2) randC1] corridorN
|
||||||
]
|
]
|
||||||
|
|
||||||
weaponBetweenPillars :: State StdGen (MetaTree Room String)
|
weaponBetweenPillars :: State LayoutVars (MetaTree Room String)
|
||||||
weaponBetweenPillars = do
|
weaponBetweenPillars = do
|
||||||
(w, wn) <- takeOne [(240, 2), (340, 3)]
|
(w, wn) <- takeOne [(240, 2), (340, 3)]
|
||||||
(h, hn) <- takeOne [(240, 2), (340, 3)]
|
(h, hn) <- takeOne [(240, 2), (340, 3)]
|
||||||
@@ -271,7 +272,7 @@ deadEndRoom =
|
|||||||
lnks = [(V2 0 30, 0)]
|
lnks = [(V2 0 30, 0)]
|
||||||
|
|
||||||
{- A random Either tree with a weapon and melee monster challenge. -}
|
{- A random Either tree with a weapon and melee monster challenge. -}
|
||||||
weaponRoom :: State StdGen (MetaTree Room String)
|
weaponRoom :: State LayoutVars (MetaTree Room String)
|
||||||
weaponRoom =
|
weaponRoom =
|
||||||
join $
|
join $
|
||||||
takeOne
|
takeOne
|
||||||
@@ -428,8 +429,8 @@ distributerRoom :: AmmoType -> Int -> State LayoutVars Room
|
|||||||
distributerRoom atype aamount = do
|
distributerRoom atype aamount = do
|
||||||
i <- nextLayoutInt
|
i <- nextLayoutInt
|
||||||
i1 <- nextLayoutInt
|
i1 <- nextLayoutInt
|
||||||
w <- state $ randomR (100, 400)
|
w <- state $ randomR (100, 200)
|
||||||
h <- state $ randomR (200, 400)
|
h <- state $ randomR (200, 200)
|
||||||
r <- roomRectAutoLights w h
|
r <- roomRectAutoLights w h
|
||||||
let mcstore = defaultMachine
|
let mcstore = defaultMachine
|
||||||
& mcMaterial .~ Metal
|
& mcMaterial .~ Metal
|
||||||
@@ -446,8 +447,8 @@ distributerRoom atype aamount = do
|
|||||||
& plSpot .~ unusedOffPathAwayFromLink 50
|
& plSpot .~ unusedOffPathAwayFromLink 50
|
||||||
& plExternalID ?~ i1
|
& plExternalID ?~ i1
|
||||||
thepipe gw =
|
thepipe gw =
|
||||||
let p1 = gw ^?! genPmnt . ix i . plSpot . psPos
|
let p1 = fromMaybe (error "distributerRoom pipe") $ gw ^? genPmnt . ix i . plSpot . psPos
|
||||||
p2 = gw ^?! genPmnt . ix i1 . plSpot . psPos
|
p2 = fromMaybe (error "distributerRoom pipe") $ gw ^? genPmnt . ix i1 . plSpot . psPos
|
||||||
in sps (PS p1 0)
|
in sps (PS p1 0)
|
||||||
(PutForeground
|
(PutForeground
|
||||||
(ForegroundShape 0 0
|
(ForegroundShape 0 0
|
||||||
@@ -458,7 +459,7 @@ distributerRoom atype aamount = do
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return $ r & rmPmnts .:~ store
|
return $ r & rmPmnts .:~ store
|
||||||
& rmInPmnt <>~ [(0,dst),(1,thepipe)]
|
& rmInPmnt <>~ [(0,return . dst),(1,return . thepipe)]
|
||||||
& rmLinks %~ setInLinksByType (OnEdge South)
|
& rmLinks %~ setInLinksByType (OnEdge South)
|
||||||
& rmLinks %~ setOutLinks (not . S.member (OnEdge South) . _rlType)
|
& rmLinks %~ setOutLinks (not . S.member (OnEdge South) . _rlType)
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,42 @@
|
|||||||
{-# LANGUAGE TupleSections #-}
|
{-# LANGUAGE TupleSections #-}
|
||||||
module Dodge.Room.SensorDoor (sensAboveDoor,sensorRoomRunPast) where
|
|
||||||
|
|
||||||
import Dodge.Data.MTRS
|
module Dodge.Room.SensorDoor (sensAboveDoor, sensorRoomRunPast) where
|
||||||
|
|
||||||
|
import Control.Monad
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
|
import Dodge.Data.MTRS
|
||||||
import Dodge.LevelGen.PlacementHelper
|
import Dodge.LevelGen.PlacementHelper
|
||||||
import Dodge.Placement.Instance
|
import Dodge.Placement.Instance
|
||||||
import Dodge.PlacementSpot
|
import Dodge.PlacementSpot
|
||||||
import Dodge.Room.Corridor
|
import Dodge.Room.Corridor
|
||||||
import Dodge.Room.Door
|
import Dodge.Room.Door
|
||||||
import Dodge.Room.Link
|
import Dodge.Room.Link
|
||||||
|
import Dodge.Room.Modify
|
||||||
import Dodge.Room.Ngon
|
import Dodge.Room.Ngon
|
||||||
import Dodge.Room.Procedural
|
import Dodge.Room.Procedural
|
||||||
|
import Dodge.RoomLink
|
||||||
import Dodge.Terminal
|
import Dodge.Terminal
|
||||||
import Dodge.Tree
|
import Dodge.Tree
|
||||||
import Dodge.Wire
|
import Dodge.Wire
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
import RandomHelp
|
import RandomHelp
|
||||||
import Control.Monad
|
|
||||||
|
|
||||||
-- TODO fix case where the sensor created by sensInsideDoor blocks another door
|
-- TODO fix case where the sensor created by sensInsideDoor blocks another door
|
||||||
-- for roomRectAutoLinks-- make the locked door a center door?
|
-- for roomRectAutoLinks-- make the locked door a center door?
|
||||||
sensorRoom :: RandomGen g => SensorType -> Int -> State g (Tree Room)
|
sensorRoom :: SensorType -> Int -> State LayoutVars (Tree Room)
|
||||||
sensorRoom senseType n = do
|
sensorRoom senseType n = do
|
||||||
rm <- join $ takeOne [roomNgon 8 200, roomRectAutoLights 200 200]
|
rm <-
|
||||||
|
join $
|
||||||
|
takeOne
|
||||||
|
[ addLightsNGon =<< roomNgon 8 200
|
||||||
|
, roomRectAutoLights 200 200 <&> rmLinks %~ setOutLinks nonCornerLinks
|
||||||
|
]
|
||||||
cenroom <- shuffleLinks $ sensInsideDoor senseType n rm
|
cenroom <- shuffleLinks $ sensInsideDoor senseType n rm
|
||||||
return $ treePost
|
return $
|
||||||
|
treePost
|
||||||
[ door
|
[ door
|
||||||
, cenroom & rmLinkEff .~ f
|
, cenroom & rmLinkEff .~ f
|
||||||
, triggerDoorRoom n
|
, triggerDoorRoom n
|
||||||
@@ -43,29 +52,51 @@ sensorRoom senseType n = do
|
|||||||
p' = p +.+ rotateV d (V2 0 (negate 100))
|
p' = p +.+ rotateV d (V2 0 (negate 100))
|
||||||
isclose = dist (_rlPos rl) p' < 30
|
isclose = dist (_rlPos rl) p' < 30
|
||||||
|
|
||||||
sensorRoomRunPast :: RandomGen g => SensorType -> Int -> State g MTRS
|
nonCornerLinks :: RoomLink -> Bool
|
||||||
|
nonCornerLinks = not . any f . (^. rlType)
|
||||||
|
where
|
||||||
|
f (FromEdge _ 0) = True
|
||||||
|
f _ = False
|
||||||
|
|
||||||
|
sensorRoomRunPast :: SensorType -> Int -> State LayoutVars MTRS
|
||||||
sensorRoomRunPast dt n = do
|
sensorRoomRunPast dt n = do
|
||||||
t <- sensorRoom dt n
|
t <- sensorRoom dt n
|
||||||
rToOnward "sensorRoomRunPast" $ t
|
rToOnward "sensorRoomRunPast" $
|
||||||
& applyToSubforest [0]
|
t
|
||||||
( ++ [ treePost [ door & rmConnectsTo .~ (\s -> S.member InLink s && not (S.member BlockedLink s)) , cleatLabel n corridor ] ])
|
& applyToSubforest
|
||||||
|
[0]
|
||||||
|
(++ [treePost [door & rmConnectsTo .~ (\s -> S.member InLink s && not (S.member BlockedLink s)), cleatLabel n corridor]])
|
||||||
|
|
||||||
sensAboveDoor :: SensorType -> Float -> PlacementSpot -> Placement
|
sensAboveDoor :: SensorType -> Float -> PlacementSpot -> Placement
|
||||||
sensAboveDoor sensetype wth ps =
|
sensAboveDoor sensetype wth ps =
|
||||||
extTrigLitPos
|
extTrigLitPos
|
||||||
(atFstLnkOutShiftBy (\(p, a) -> ((p +.+ rotateV a (V2 18.5 (-2.5)), a), S.singleton UsedPosHigh)))
|
( psposAddLabel
|
||||||
|
ColoredLightRP
|
||||||
|
(atFstLnkOutShiftBy (\(p, a) -> ((p +.+ rotateV a (V2 18.5 (-2.5)), a), S.singleton UsedPosHigh)))
|
||||||
|
)
|
||||||
(\tp -> Just $ damageSensor sensetype wth (_plMID tp) ps)
|
(\tp -> Just $ damageSensor sensetype wth (_plMID tp) ps)
|
||||||
|
|
||||||
sensInsideDoor :: SensorType -> Int -> Room -> Room
|
sensInsideDoor :: SensorType -> Int -> Room -> Room
|
||||||
sensInsideDoor senseType i rm = rm
|
sensInsideDoor senseType i rm =
|
||||||
& rmName .++~ take 4 (show senseType)
|
rm
|
||||||
& rmPmnts
|
& rmName
|
||||||
|
.++~ take 4 (show senseType)
|
||||||
|
& rmPmnts
|
||||||
.++~ [ psPt atFstLnkOut . PutForeground $ floorWire (V2 20 0) (V2 20 (-100))
|
.++~ [ psPt atFstLnkOut . PutForeground $ floorWire (V2 20 0) (V2 20 (-100))
|
||||||
, psPt atFstLnkOut . PutForeground $ floorWire (V2 0 (-100)) (V2 20 (-100))
|
, psPt atFstLnkOut . PutForeground $ floorWire (V2 0 (-100)) (V2 20 (-100))
|
||||||
, psPt atFstLnkOut . PutForeground $ verticalWire (V2 20 0) 0 80
|
, psPt atFstLnkOut . PutForeground $ verticalWire (V2 20 0) 0 80
|
||||||
, putMessageTerminal
|
, putMessageTerminal
|
||||||
(textTerminal & tmCommands .:~ TCDamageCommand)
|
(textTerminal & tmCommands .:~ TCDamageCommand)
|
||||||
& plSpot .~ rprBoolShift isUnusedLnk (shiftInBy 10 <&> (, S.singleton UsedPosHigh))
|
& plSpot
|
||||||
, sensAboveDoor senseType 10 (atFstLnkOutShiftInward 100) & plExternalID ?~ i
|
.~ rprBoolShift termpos (shiftInBy 10 <&> (,S.singleton UsedPosHigh))
|
||||||
|
, sensAboveDoor senseType 10 (atFstLnkOutShiftInward 100) & plExternalID ?~ i
|
||||||
]
|
]
|
||||||
-- & rmOutPmnt . at i ?~ sensAboveDoor senseType 10 (atFstLnkOutShiftInward 100)
|
where
|
||||||
|
termpos rp rm' =
|
||||||
|
isUnusedLnk rp rm'
|
||||||
|
&& all ((> 30) . dist (_rpPos rp) . _rpPos) (filter usedlnks $ rm' ^. rmPos)
|
||||||
|
usedlnks rp = case _rpType rp of
|
||||||
|
UsedOutLink{} -> True
|
||||||
|
UsedInLink{} -> True
|
||||||
|
UnusedLink{} -> False
|
||||||
|
NotLink{} -> False
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ powerFakeout = do
|
|||||||
]
|
]
|
||||||
|
|
||||||
-- the i is used either for a PickOnePlacement or a room id, this is not great
|
-- the i is used either for a PickOnePlacement or a room id, this is not great
|
||||||
startRoom :: Int -> State StdGen (MetaTree Room String)
|
startRoom :: State LayoutVars (MetaTree Room String)
|
||||||
startRoom i =
|
startRoom = do
|
||||||
|
i <- nextLayoutInt
|
||||||
join $
|
join $
|
||||||
takeOne
|
takeOne
|
||||||
[ attachOnward "startThenWeaponRoom" <$> preCritStart <*> weaponRoom
|
[ attachOnward "startThenWeaponRoom" <$> preCritStart <*> weaponRoom
|
||||||
|
|||||||
+199
-184
@@ -1,42 +1,43 @@
|
|||||||
{-# OPTIONS_GHC -Wno-unused-imports #-}
|
{-# OPTIONS_GHC -Wno-unused-imports #-}
|
||||||
|
|
||||||
module Dodge.Room.Tutorial where
|
module Dodge.Room.Tutorial where
|
||||||
|
|
||||||
import Data.Maybe
|
|
||||||
import Dodge.LockAndKey
|
|
||||||
import Dodge.Room.SensorDoor
|
|
||||||
import Dodge.Room.Room
|
|
||||||
import Dodge.Data.AmmoType
|
|
||||||
import Dodge.Room.Path
|
|
||||||
import Dodge.Room.Pillar
|
|
||||||
import Dodge.Room.Boss
|
|
||||||
import Dodge.Room.Tanks
|
|
||||||
import Dodge.Room.LongDoor
|
|
||||||
import Dodge.Layout
|
|
||||||
import Dodge.Item.Held.Utility
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import qualified Data.IntMap.Strict as IM
|
import qualified Data.IntMap.Strict as IM
|
||||||
import qualified Data.IntSet as IS
|
import qualified Data.IntSet as IS
|
||||||
|
import Data.Maybe
|
||||||
import Data.Maybe (mapMaybe)
|
import Data.Maybe (mapMaybe)
|
||||||
import qualified Data.Set as S
|
import qualified Data.Set as S
|
||||||
import Dodge.Cleat
|
import Dodge.Cleat
|
||||||
|
import Dodge.Data.AmmoType
|
||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Data.MTRS
|
import Dodge.Data.MTRS
|
||||||
import Dodge.Default.Terminal
|
import Dodge.Default.Terminal
|
||||||
import Dodge.Item.Ammo
|
import Dodge.Item.Ammo
|
||||||
import Dodge.Item.Held.Cane
|
import Dodge.Item.Held.Cane
|
||||||
|
import Dodge.Item.Held.Utility
|
||||||
|
import Dodge.Layout
|
||||||
import Dodge.LevelGen.PlacementHelper
|
import Dodge.LevelGen.PlacementHelper
|
||||||
|
import Dodge.LockAndKey
|
||||||
import Dodge.Placement.Instance
|
import Dodge.Placement.Instance
|
||||||
import Dodge.PlacementSpot
|
import Dodge.PlacementSpot
|
||||||
import Dodge.Room.Airlock
|
import Dodge.Room.Airlock
|
||||||
|
import Dodge.Room.Boss
|
||||||
import Dodge.Room.Corridor
|
import Dodge.Room.Corridor
|
||||||
import Dodge.Room.Door
|
import Dodge.Room.Door
|
||||||
import Dodge.Room.LasTurret
|
import Dodge.Room.LasTurret
|
||||||
import Dodge.Room.Link
|
import Dodge.Room.Link
|
||||||
|
import Dodge.Room.LongDoor
|
||||||
|
import Dodge.Room.Modify
|
||||||
import Dodge.Room.Ngon
|
import Dodge.Room.Ngon
|
||||||
|
import Dodge.Room.Path
|
||||||
|
import Dodge.Room.Pillar
|
||||||
import Dodge.Room.Procedural
|
import Dodge.Room.Procedural
|
||||||
import Dodge.Room.RezBox
|
import Dodge.Room.RezBox
|
||||||
import Dodge.Room.RoadBlock
|
import Dodge.Room.RoadBlock
|
||||||
import Dodge.Room.Room
|
import Dodge.Room.Room
|
||||||
|
import Dodge.Room.SensorDoor
|
||||||
|
import Dodge.Room.Tanks
|
||||||
import Dodge.Room.Warning
|
import Dodge.Room.Warning
|
||||||
import Dodge.RoomLink
|
import Dodge.RoomLink
|
||||||
import Dodge.Terminal
|
import Dodge.Terminal
|
||||||
@@ -52,45 +53,32 @@ tutAnoTree :: State LayoutVars MTRS
|
|||||||
tutAnoTree = do
|
tutAnoTree = do
|
||||||
foldMTRS
|
foldMTRS
|
||||||
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
[ tToBTree "TutStartRez" . return . cleatOnward <$> tutRezBox
|
||||||
-- , return . tToBTree "door" $ treePost [corridor, cleatOnward door]
|
|
||||||
, corDoor
|
, corDoor
|
||||||
-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
, chasmSpitTerminal
|
||||||
, lasRunYinYang
|
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- , passthroughLockKeyLists lockRoomKeyItems itemRooms
|
, corDoor
|
||||||
, tToBTree "door" . return <$> return (cleatOnward door)
|
, tToBTree "sdr" . return . cleatOnward
|
||||||
, tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
<$> (shuffleLinks =<< distributerRoom BulletAmmo 100000)
|
||||||
-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
, -- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
-- --, tToBTree "sdr" . return . cleatOnward <$> slowDoorRoom
|
||||||
-- , passthroughLockKeyLists
|
---- , tToBTree "sr" . return . cleatOnward <$> tanksRoom [] []
|
||||||
-- [(sensorRoomRunPast ElectricSensor, takeOne
|
-- , return $ tToBTree "door" $ return $ cleatOnward door
|
||||||
-- [-- CRAFT (ENERGYBALLCRAFT TeslaBall) ,
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- HELD SPARKGUN])]
|
-- , tToBTree "sdr" . return . cleatOnward <$>
|
||||||
-- itemRooms
|
-- (shuffleLinks =<< tanksPipesRoom)
|
||||||
-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
-- , tToBTree "cor" . return <$> shuffleLinks (cleatOnward corridor)
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
, tToBTree "sdr" . return . cleatOnward <$>
|
-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
(shuffleLinks =<< distributerRoom BulletAmmo 100000)
|
return $ tToBTree "door" $ return $ cleatOnward door
|
||||||
--aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
--aaa-- --, tToBTree "sdr" . return . cleatOnward <$> slowDoorRoom
|
, tutHub
|
||||||
--aaa---- , tToBTree "sr" . return . cleatOnward <$> tanksRoom [] []
|
, chasmSpitTerminal
|
||||||
--aaa-- , return $ tToBTree "door" $ return $ cleatOnward door
|
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
--aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
, tutLight
|
||||||
--aaa-- , tToBTree "sdr" . return . cleatOnward <$>
|
, tutDrop
|
||||||
--aaa-- (shuffleLinks =<< tanksPipesRoom)
|
, return $ tToBTree "cor" $ return $ cleatOnward corridor
|
||||||
--aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
---- , AnTree $ pickupTut
|
||||||
--aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
---- , AnTree $ weaponTut
|
||||||
--aaa-- , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
|
||||||
--aaa , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
|
||||||
--aaa , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
|
||||||
--aaa , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
|
||||||
--aaa , return $ tToBTree "door" $ return $ cleatOnward door
|
|
||||||
--aaa , tutHub
|
|
||||||
--aaa , chasmSpitTerminal
|
|
||||||
--aaa , tutLight
|
|
||||||
--aaa , tutDrop
|
|
||||||
--aaa , return $ tToBTree "cor" $ return $ cleatOnward corridor
|
|
||||||
--aaa ---- , AnTree $ pickupTut
|
|
||||||
--aaa ---- , AnTree $ weaponTut
|
|
||||||
]
|
]
|
||||||
|
|
||||||
foldMTRS ::
|
foldMTRS ::
|
||||||
@@ -100,41 +88,33 @@ foldMTRS xs = do
|
|||||||
ys <- sequence xs
|
ys <- sequence xs
|
||||||
return $ foldr1 attachOnward' ys
|
return $ foldr1 attachOnward' ys
|
||||||
|
|
||||||
setRoomInt :: Room -> State LayoutVars (Int, Room)
|
|
||||||
setRoomInt x = do
|
|
||||||
i <- nextLayoutInt
|
|
||||||
return (i, x & rmPmnts .:~ sps0 (PutWorldUpdate (f i)))
|
|
||||||
where
|
|
||||||
f i rid _ gw = gw & genInts . at i ?~ (gw ^?! genRooms . ix rid . rmMID . _Just)
|
|
||||||
|
|
||||||
setTreeInts :: Tree Room -> State LayoutVars ([Int], Tree Room)
|
setTreeInts :: Tree Room -> State LayoutVars ([Int], Tree Room)
|
||||||
setTreeInts x = do
|
setTreeInts x = do
|
||||||
y <- traverse setRoomInt x
|
y <- traverse storeRoomID x
|
||||||
return (foldMap ((: []) . fst) y, fmap snd y)
|
return (foldMap ((: []) . fst) y, fmap snd y)
|
||||||
|
|
||||||
tutDrop :: State LayoutVars (MetaTree Room String)
|
tutDrop :: State LayoutVars (MetaTree Room String)
|
||||||
tutDrop = do
|
tutDrop = do
|
||||||
x <- shuffleLinks =<< roomNgon 6 100
|
x <- shuffleLinks =<< roomNgon 6 100
|
||||||
i <- nextLayoutInt
|
i <- nextLayoutInt
|
||||||
--let y = decontamRoom i
|
-- let y = decontamRoom i
|
||||||
(j, y) <- setRoomInt (decontamRoom i)
|
(j, y) <- storeRoomID (decontamRoom i)
|
||||||
rm <- roomRectAutoLights 40 100
|
rm <- roomRectAutoLights 40 100
|
||||||
return $
|
return $
|
||||||
tToBTree "TutDrop" $
|
tToBTree "TutDrop" $
|
||||||
treePost
|
treePost
|
||||||
[x & rmInPmnt .:~ (0, t j), y, cleatOnward rm]
|
[x & rmInPmnt .:~ (0, return . t j), y, cleatOnward rm]
|
||||||
where
|
where
|
||||||
t j gw =
|
t j gw =
|
||||||
let x = gw ^? genInts . ix j
|
let x = gw ^? genInts . ix j
|
||||||
in putMessageTerminal
|
in putMessageTerminal
|
||||||
(defaultTerminal & tmBootLines .~ ss <> tlSetStatus (TerminalPressTo $ show x <> "QUIT") <> tlDoEffect TmWdWdPowerDownTerminal)
|
(defaultTerminal & tmBootLines .~ ss <> tlSetStatus (TerminalPressTo $ show x <> "QUIT") <> tlDoEffect TmWdWdPowerDownTerminal)
|
||||||
& plSpot
|
& plSpot
|
||||||
.~ rprBoolShift
|
.~ rprBoolShift
|
||||||
isUnusedLnk
|
isUnusedLnk
|
||||||
(\(p, a) -> ((p + 10 *.* unitVectorAtAngle (a - pi / 2), a), S.singleton UsedPosLow))
|
(\(p, a) -> ((p + 10 *.* unitVectorAtAngle (a - pi / 2), a), S.singleton UsedPosLow))
|
||||||
ss =
|
ss =
|
||||||
[ makeTermLine "--------------------------------------------"
|
[ makeTermLine "YOU CAN ONLY CARRY A LIMITED AMOUNT OF ITEMS"
|
||||||
, makeTermLine "YOU CAN ONLY CARRY A LIMITED AMOUNT OF ITEMS"
|
|
||||||
, makeTermLine "--------------------------------------------"
|
, makeTermLine "--------------------------------------------"
|
||||||
]
|
]
|
||||||
<> tlSetStatus (TerminalPressTo "CONTINUE")
|
<> tlSetStatus (TerminalPressTo "CONTINUE")
|
||||||
@@ -152,18 +132,24 @@ cChasm = do
|
|||||||
x <- state $ randomR (150, 300)
|
x <- state $ randomR (150, 300)
|
||||||
y <- state $ randomR (150, 300)
|
y <- state $ randomR (150, 300)
|
||||||
roomRectAutoLights x y
|
roomRectAutoLights x y
|
||||||
<&> rmLinks %~ setOutLinks (isCornerLink NorthWest)
|
<&> rmLinks
|
||||||
<&> rmLinks %~ setInLinks (isCornerLink SouthWest)
|
%~ setOutLinks (isCornerLink NorthWest)
|
||||||
<&> rmPmnts <>~ [sps0 $ putConvexChasm (rectNSWE (y -50) 50 0 (x -50))]
|
<&> rmLinks
|
||||||
|
%~ setInLinks (isCornerLink SouthWest)
|
||||||
|
<&> rmPmnts
|
||||||
|
<>~ [sps0 $ putConvexChasm (rectNSWE (y - 50) 50 0 (x - 50))]
|
||||||
|
|
||||||
lChasm :: State LayoutVars Room
|
lChasm :: State LayoutVars Room
|
||||||
lChasm = do
|
lChasm = do
|
||||||
x <- state $ randomR (150, 300)
|
x <- state $ randomR (150, 300)
|
||||||
y <- state $ randomR (150, 300)
|
y <- state $ randomR (150, 300)
|
||||||
roomRectAutoLights x y
|
roomRectAutoLights x y
|
||||||
<&> rmLinks %~ setOutLinks (isCornerLink NorthWest)
|
<&> rmLinks
|
||||||
<&> rmLinks %~ setInLinks (isCornerLink SouthEast)
|
%~ setOutLinks (isCornerLink NorthWest)
|
||||||
<&> rmPmnts <>~ [sps0 $ putConvexChasm (rectNSWE (y -50) 0 0 (x -50))]
|
<&> rmLinks
|
||||||
|
%~ setInLinks (isCornerLink SouthEast)
|
||||||
|
<&> rmPmnts
|
||||||
|
<>~ [sps0 $ putConvexChasm (rectNSWE (y - 50) 0 0 (x - 50))]
|
||||||
|
|
||||||
-- the Float is the width of the bridge
|
-- the Float is the width of the bridge
|
||||||
zChasm :: Float -> State LayoutVars Room
|
zChasm :: Float -> State LayoutVars Room
|
||||||
@@ -171,13 +157,16 @@ zChasm z = do
|
|||||||
x <- state $ randomR (150, 300)
|
x <- state $ randomR (150, 300)
|
||||||
y <- state $ randomR (150, 300)
|
y <- state $ randomR (150, 300)
|
||||||
roomRectAutoLights x y
|
roomRectAutoLights x y
|
||||||
<&> rmLinks %~ setOutLinks (isCornerLink NorthWest)
|
<&> rmLinks
|
||||||
<&> rmLinks %~ setInLinks (isCornerLink SouthEast)
|
%~ setOutLinks (isCornerLink NorthWest)
|
||||||
<&> rmPath %~ addNodesCrossing (V2 0 (y/2),V2 x (y/2))
|
<&> rmLinks
|
||||||
|
%~ setInLinks (isCornerLink SouthEast)
|
||||||
|
<&> rmPath
|
||||||
|
%~ addNodesCrossing (V2 0 (y / 2), V2 x (y / 2))
|
||||||
<&> rmPmnts
|
<&> rmPmnts
|
||||||
<>~ [ sps0 $ putConvexChasm (rectNSWE (y / 2 - z) 0 0 (x -50))
|
<>~ [ sps0 $ putConvexChasm (rectNSWE (y / 2 - z) 0 0 (x - 50))
|
||||||
, sps0 $ putConvexChasm (rectNSWE y (y / 2 + z) 50 x)
|
, sps0 $ putConvexChasm (rectNSWE y (y / 2 + z) 50 x)
|
||||||
]
|
]
|
||||||
|
|
||||||
midChasm :: State LayoutVars Room
|
midChasm :: State LayoutVars Room
|
||||||
midChasm = do
|
midChasm = do
|
||||||
@@ -187,9 +176,12 @@ midChasm = do
|
|||||||
cs <- join $ takeOne [cenoct x y, censquare x y]
|
cs <- join $ takeOne [cenoct x y, censquare x y]
|
||||||
shuffleLinks $
|
shuffleLinks $
|
||||||
r
|
r
|
||||||
& rmLinks %~ setOutLinks (isMidEdgeLink r North)
|
& rmLinks
|
||||||
& rmLinks %~ setInLinks (isMidEdgeLink r South)
|
%~ setOutLinks (isMidEdgeLink r North)
|
||||||
& rmPmnts <>~ cs
|
& rmLinks
|
||||||
|
%~ setInLinks (isMidEdgeLink r South)
|
||||||
|
& rmPmnts
|
||||||
|
<>~ cs
|
||||||
where
|
where
|
||||||
censquare x y = do
|
censquare x y = do
|
||||||
z <- state $ randomR (40, 60)
|
z <- state $ randomR (40, 60)
|
||||||
@@ -206,26 +198,31 @@ midChasmPlatform = do
|
|||||||
cs <- join $ takeOne [censquare x y]
|
cs <- join $ takeOne [censquare x y]
|
||||||
shuffleLinks $
|
shuffleLinks $
|
||||||
r
|
r
|
||||||
& rmLinks %~ setOutLinks (isMidEdgeLink r North)
|
& rmLinks
|
||||||
& rmLinks %~ setInLinks (isMidEdgeLink r South)
|
%~ setOutLinks (isMidEdgeLink r North)
|
||||||
& rmPmnts <>~ cs
|
& rmLinks
|
||||||
|
%~ setInLinks (isMidEdgeLink r South)
|
||||||
|
& rmPmnts
|
||||||
|
<>~ cs
|
||||||
where
|
where
|
||||||
censquare x y = do
|
censquare x y = do
|
||||||
z <- state $ randomR (40, 60)
|
z <- state $ randomR (40, 60)
|
||||||
let (chsms,clfs) = sqPlatformChasm 20 (min x y/2 - z)
|
let (chsms, clfs) = sqPlatformChasm 20 (min x y / 2 - z)
|
||||||
--return [sps0 $ putConvexChasm (rectNSWE (y - z) z z (x - z))]
|
-- return [sps0 $ putConvexChasm (rectNSWE (y - z) z z (x - z))]
|
||||||
return [sps0 $ PutChasm
|
return
|
||||||
(fmap (fmap (+ V2 (x/2) (y/2))) chsms)
|
[ sps0 $
|
||||||
(fmap (fmap (+ V2 (x/2) (y/2))) clfs)
|
PutChasm
|
||||||
]-- (rectNSWE (y - z) z z (x - z))]
|
(fmap (fmap (+ V2 (x / 2) (y / 2))) chsms)
|
||||||
-- cenoct x y =
|
(fmap (fmap (+ V2 (x / 2) (y / 2))) clfs)
|
||||||
-- return
|
] -- (rectNSWE (y - z) z z (x - z))]
|
||||||
-- [sps0 $ putConvexChasm $ (V2 (x / 2) (y / 2) +) <$> polyOrthDist 8 (min x y / 2 - 25)]
|
-- cenoct x y =
|
||||||
|
-- return
|
||||||
|
-- [sps0 $ putConvexChasm $ (V2 (x / 2) (y / 2) +) <$> polyOrthDist 8 (min x y / 2 - 25)]
|
||||||
|
|
||||||
sqPlatformChasm :: Float -> Float -> ([[Point2]],[[Point2]])
|
sqPlatformChasm :: Float -> Float -> ([[Point2]], [[Point2]])
|
||||||
sqPlatformChasm b a =
|
sqPlatformChasm b a =
|
||||||
( [[ibr,obr,otr,itr],[itr,otr,otl,itl],[itl,otl,obl,ibl],[ibl,obl,obr,ibr]]
|
( [[ibr, obr, otr, itr], [itr, otr, otl, itl], [itl, otl, obl, ibl], [ibl, obl, obr, ibr]]
|
||||||
, [[obr,otr,otl,obl], [ibr,ibl, itl, itr]]
|
, [[obr, otr, otl, obl], [ibr, ibl, itl, itr]]
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
obr = V2 a (-a)
|
obr = V2 a (-a)
|
||||||
@@ -237,10 +234,10 @@ sqPlatformChasm b a =
|
|||||||
itl = V2 (-b) b
|
itl = V2 (-b) b
|
||||||
itr = V2 b b
|
itr = V2 b b
|
||||||
|
|
||||||
sqSpitChasm :: Float -> Float -> ([[Point2]],[[Point2]])
|
sqSpitChasm :: Float -> Float -> ([[Point2]], [[Point2]])
|
||||||
sqSpitChasm b a =
|
sqSpitChasm b a =
|
||||||
( [[ibr,obr,otr,itr],[itr,otr,otl,itl],[itl,otl,obl,ibl]]
|
( [[ibr, obr, otr, itr], [itr, otr, otl, itl], [itl, otl, obl, ibl]]
|
||||||
, [[ibr,obr,otr,otl,obl,ibl,itl,itr]]
|
, [[ibr, obr, otr, otl, obl, ibl, itl, itr]]
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
obr = V2 a (-a)
|
obr = V2 a (-a)
|
||||||
@@ -258,55 +255,75 @@ midChasmSpit = do
|
|||||||
y = 300
|
y = 300
|
||||||
r <- roomRectAutoLights x y
|
r <- roomRectAutoLights x y
|
||||||
cs <- join $ takeOne [censquare x y]
|
cs <- join $ takeOne [censquare x y]
|
||||||
|
foutlnks <-
|
||||||
|
takeOne
|
||||||
|
[ \rl ->
|
||||||
|
isMidEdgeLink r North rl
|
||||||
|
|| isMidEdgeLink r East rl
|
||||||
|
|| isMidEdgeLink r West rl
|
||||||
|
, \rl -> OnEdge North `S.member` (rl ^. rlType)
|
||||||
|
&& not (FromEdge East 0 `S.member` (rl ^. rlType))
|
||||||
|
&& not (FromEdge West 0 `S.member` (rl ^. rlType))
|
||||||
|
]
|
||||||
shuffleLinks $
|
shuffleLinks $
|
||||||
r
|
r
|
||||||
& rmLinks %~ setOutLinks
|
& rmLinks %~ setOutLinks foutlnks
|
||||||
(\rl -> isMidEdgeLink r North rl
|
|
||||||
|| isMidEdgeLink r East rl
|
|
||||||
|| isMidEdgeLink r West rl
|
|
||||||
)
|
|
||||||
& rmLinks %~ setInLinks (isMidEdgeLink r South)
|
& rmLinks %~ setInLinks (isMidEdgeLink r South)
|
||||||
& rmPmnts .~ cs
|
& rmPmnts .~ cs
|
||||||
where
|
where
|
||||||
censquare x y = do
|
censquare x y = do
|
||||||
z <- state $ randomR (40, 60)
|
z <- state $ randomR (40, 60)
|
||||||
let (chsms,clfs) = sqSpitChasm 20 (min x y/2 - z)
|
let (chsms, clfs) = sqSpitChasm 20 (min x y / 2 - z)
|
||||||
return [sps0 $ PutChasm
|
return
|
||||||
(fmap (fmap (+ V2 (x/2) (y/2))) chsms)
|
[ sps0 $
|
||||||
(fmap (fmap (+ V2 (x/2) (y/2))) clfs)
|
PutChasm
|
||||||
]-- (rectNSWE (y - z) z z (x - z))]
|
(fmap (fmap (+ V2 (x / 2) (y / 2))) chsms)
|
||||||
-- cenoct x y =
|
(fmap (fmap (+ V2 (x / 2) (y / 2))) clfs)
|
||||||
-- return
|
] -- (rectNSWE (y - z) z z (x - z))]
|
||||||
-- [sps0 $ putConvexChasm $ (V2 (x / 2) (y / 2) +) <$> polyOrthDist 8 (min x y / 2 - 25)]
|
-- cenoct x y =
|
||||||
|
-- return
|
||||||
|
-- [sps0 $ putConvexChasm $ (V2 (x / 2) (y / 2) +) <$> polyOrthDist 8 (min x y / 2 - 25)]
|
||||||
|
|
||||||
chasmSpitTerminal :: State LayoutVars MTRS
|
chasmSpitTerminal :: State LayoutVars MTRS
|
||||||
chasmSpitTerminal = do
|
chasmSpitTerminal = do
|
||||||
i1 <- nextLayoutInt
|
i1 <- nextLayoutInt
|
||||||
y <- midChasmSpit
|
y <- midChasmSpit
|
||||||
l3 <- mntLightLnkCond $ resetPLUse $ rprBool $ \rp _ -> isOutLnkNum 0 rp
|
shp <- takeOne [vShape, lShape, jShape, liShape]
|
||||||
l4 <- mntLightLnkCond $ resetPLUse $ rprBool $ \rp _ -> isOutLnkNum 1 rp
|
let l3 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> isOutLnkNum 0 rp
|
||||||
let y' = y & rmPmnts <>~ [l3,l4]
|
l4 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> isOutLnkNum 1 rp
|
||||||
return $ tToBTree "chasmTerm" $ Node (addDoorToggleTerminal' i1 (PS 150 0) y')
|
l5 = mntLightLnkShape shp $ resetPLUse $ rprBool $ \rp _ -> isOutLnkNum 2 rp
|
||||||
[treePost [triggerDoorRoom i1, critDeadEnd]
|
-- let y' = y & rmPmnts <>~ [l3, l4, l5]
|
||||||
,treePost [triggerDoorRoom i1, critDeadEnd]
|
let y' = y & rmPmnts <>~ [l3, l4]
|
||||||
,return $ cleatOnward $ triggerDoorRoom i1
|
return $
|
||||||
]
|
tToBTree "chasmTerm" $
|
||||||
|
Node
|
||||||
|
(addDoorToggleTerminal' i1 (PS 150 0) y')
|
||||||
|
[ treePost [triggerDoorRoom i1, critDeadEnd]
|
||||||
|
, treePost [triggerDoorRoom i1, critDeadEnd]
|
||||||
|
, return $ cleatOnward $ triggerDoorRoom i1
|
||||||
|
]
|
||||||
|
|
||||||
polyChasm :: Int -> Float -> State LayoutVars Room
|
polyChasm :: Int -> Float -> State LayoutVars Room
|
||||||
polyChasm n x =
|
polyChasm n x =
|
||||||
shuffleLinks
|
shuffleLinks
|
||||||
=<< ( roomNgon n x
|
=<< ( roomNgon n x
|
||||||
<&> rmPmnts <>~ [sps0 $ putConvexChasm $ polyOrthDist n (x -30)]
|
<&> rmPmnts
|
||||||
<&> rmLinks %~ setOutLinks (\rl -> rl ^. rlPos . _y > 0)
|
<>~ [sps0 $ putConvexChasm $ polyOrthDist n (x - 30)]
|
||||||
<&> rmLinks %~ setInLinks (\rl -> rl ^. rlPos . _y < (5 - x))
|
<&> rmLinks
|
||||||
|
%~ setOutLinks (\rl -> rl ^. rlPos . _y > 0)
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setInLinks (\rl -> rl ^. rlPos . _y < (5 - x))
|
||||||
)
|
)
|
||||||
|
|
||||||
polyChasmC :: Int -> Float -> State LayoutVars Room
|
polyChasmC :: Int -> Float -> State LayoutVars Room
|
||||||
polyChasmC n x =
|
polyChasmC n x =
|
||||||
roomNgon n x
|
roomNgon n x
|
||||||
<&> rmPmnts <>~ [sps0 $ putConvexChasm $ rectNSWE x (60 - x) (-40) 40]
|
<&> rmPmnts
|
||||||
<&> rmLinks %~ setInLinks (\rl -> PolyEdge 1 `S.member` (rl ^. rlType))
|
<>~ [sps0 $ putConvexChasm $ rectNSWE x (60 - x) (-40) 40]
|
||||||
<&> rmLinks %~ setOutLinks (\rl -> PolyEdge (n -1) `S.member` (rl ^. rlType))
|
<&> rmLinks
|
||||||
|
%~ setInLinks (\rl -> PolyEdge 1 `S.member` (rl ^. rlType))
|
||||||
|
<&> rmLinks
|
||||||
|
%~ setOutLinks (\rl -> PolyEdge (n - 1) `S.member` (rl ^. rlType))
|
||||||
|
|
||||||
chasmSimpleMaze :: State LayoutVars Room
|
chasmSimpleMaze :: State LayoutVars Room
|
||||||
chasmSimpleMaze =
|
chasmSimpleMaze =
|
||||||
@@ -338,10 +355,11 @@ tutLight = do
|
|||||||
return $
|
return $
|
||||||
tToBTree "TutLight" $
|
tToBTree "TutLight" $
|
||||||
treePost
|
treePost
|
||||||
[ x & rmPmnts <>~
|
[ x
|
||||||
[sps g (PutFlIt led)
|
& rmPmnts
|
||||||
,sps g (PutFlIt battery)
|
<>~ [ sps g (PutFlIt led)
|
||||||
]
|
, sps g (PutFlIt battery)
|
||||||
|
]
|
||||||
, corridor & rmPmnts .~ mempty
|
, corridor & rmPmnts .~ mempty
|
||||||
, removeLights y
|
, removeLights y
|
||||||
, corridor & rmPmnts .~ mempty
|
, corridor & rmPmnts .~ mempty
|
||||||
@@ -353,18 +371,14 @@ tutLight = do
|
|||||||
g = PSPos (\x _ -> f x) (const id) Nothing
|
g = PSPos (\x _ -> f x) (const id) Nothing
|
||||||
where
|
where
|
||||||
f x = case _rpType x of
|
f x = case _rpType x of
|
||||||
NotLink{} | null (x ^. rpPlacementUse . at UsedPosFloor)
|
NotLink{}
|
||||||
-> Just (PS (_rpPos x) (_rpDir x)
|
| null (x ^. rpPlacementUse . at UsedPosFloor) ->
|
||||||
, x & rpPlacementUse . at UsedPosFloor ?~ ())
|
Just
|
||||||
|
( PS (_rpPos x) (_rpDir x)
|
||||||
|
, x & rpPlacementUse . at UsedPosFloor ?~ ()
|
||||||
|
)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
removeLights :: Room -> Room
|
|
||||||
removeLights = rmPmnts %~ mapMaybe f
|
|
||||||
where
|
|
||||||
f x = case x ^. plType of
|
|
||||||
PutLabel "light" -> Nothing
|
|
||||||
_ -> Just x
|
|
||||||
|
|
||||||
tutHub :: State LayoutVars (MetaTree Room String)
|
tutHub :: State LayoutVars (MetaTree Room String)
|
||||||
tutHub = do
|
tutHub = do
|
||||||
(is, wbp) <- setTreeInts =<< critsRoom 1
|
(is, wbp) <- setTreeInts =<< critsRoom 1
|
||||||
@@ -374,21 +388,21 @@ tutHub = do
|
|||||||
k <- nextLayoutInt
|
k <- nextLayoutInt
|
||||||
let a gw =
|
let a gw =
|
||||||
analyserByNthLink
|
analyserByNthLink
|
||||||
3
|
3
|
||||||
(RequireDeadCreatures $ getCrsFromRooms is gw)
|
(RequireDeadCreatures $ getCrsFromRooms is gw)
|
||||||
k
|
k
|
||||||
x <-
|
x <-
|
||||||
shuffleLinks
|
shuffleLinks
|
||||||
. analyserByDoor (RequireEquipment (AMMOMAG DRUMMAG)) i
|
. analyserByDoor (RequireEquipment (AMMOMAG DRUMMAG)) i
|
||||||
. (rmInPmnt .:~ (0, a))
|
. (rmInPmnt .:~ (0, return . a))
|
||||||
. addDoorAtNthLinkToggleTerminal 1 ss j
|
. addDoorAtNthLinkToggleTerminal 1 ss j
|
||||||
-- . addDoorAtNthLinkToggleInterrupt 2 ds j
|
-- . addDoorAtNthLinkToggleInterrupt 2 ds j
|
||||||
. addDoorAtNthLinkToggleInterrupt 2 ds j1
|
. addDoorAtNthLinkToggleInterrupt 2 ds j1
|
||||||
=<< roomNgon 6 100
|
=<< roomNgon 6 100
|
||||||
-- bcor <- treeAttachDeep (return door) <$> blockedCorridor
|
-- bcor <- treeAttachDeep (return door) <$> blockedCorridor
|
||||||
r1 <- r burstRifle <&> rmPmnts .:~ itemshiftterminal
|
r1 <- r burstRifle <&> rmPmnts .:~ itemshiftterminal
|
||||||
r2 <- ammoroom (drumMag & itConsumables ?~ 90) -- <&> rmPmnts .:~ tutorialterminal
|
r2 <- ammoroom (drumMag & itConsumables ?~ 90) -- <&> rmPmnts .:~ tutorialterminal
|
||||||
--r2 <- r (tinMag & itConsumables ?~ 500)
|
-- r2 <- r (tinMag & itConsumables ?~ 500)
|
||||||
return $
|
return $
|
||||||
tToBTree "DoorTest" $
|
tToBTree "DoorTest" $
|
||||||
Node
|
Node
|
||||||
@@ -396,16 +410,14 @@ tutHub = do
|
|||||||
[ treeFromPost [triggerDoorRoom i] r1
|
[ treeFromPost [triggerDoorRoom i] r1
|
||||||
, treeFromPost [triggerDoorRoom j] r2
|
, treeFromPost [triggerDoorRoom j] r2
|
||||||
, treeFromTrunk [triggerDoorRoom j1] wbp
|
, treeFromTrunk [triggerDoorRoom j1] wbp
|
||||||
-- , (rmClusterStatus . csLinks . at OnwardCluster .~ Nothing)
|
, -- , (rmClusterStatus . csLinks . at OnwardCluster .~ Nothing)
|
||||||
-- <$> treeAttachDeep wbp (return corridor)
|
-- <$> treeAttachDeep wbp (return corridor)
|
||||||
, treeFromPost [] (cleatOnward $ triggerDoorRoom k & rmInPmnt . ix 0 . _1 .~ 1)
|
treeFromPost [] (cleatOnward $ triggerDoorRoom k & rmInPmnt . ix 0 . _1 .~ 1)
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
ds = ["DESTROY THIS TO OPEN THE DOOR"]
|
ds = ["DESTROY THIS TO OPEN THE DOOR"]
|
||||||
ss =
|
ss =
|
||||||
[ makeTermLine "---------------------------------------------"
|
[ makeTermLine "SOME TERMINALS HAVE A PROMPT"
|
||||||
, makeTermLine "YOU CAN INTERACT WITH SOME TERMINALS DIRECTLY"
|
|
||||||
, makeTermLine " THESE WILL DISPLAY A PROMPT SYMBOL"
|
|
||||||
, makeTermLine " *****"
|
, makeTermLine " *****"
|
||||||
, makeTermLine " * * TYPE OR SCROLL TO ENTER COMMANDS"
|
, makeTermLine " * * TYPE OR SCROLL TO ENTER COMMANDS"
|
||||||
, makeTermLine " * > *"
|
, makeTermLine " * > *"
|
||||||
@@ -420,9 +432,9 @@ tutHub = do
|
|||||||
putMessageTerminal
|
putMessageTerminal
|
||||||
(defaultTerminal & tmBootLines .~ ss' <> tlSetStatus (TerminalPressTo "QUIT") <> tlDoEffect TmWdWdPowerDownTerminal)
|
(defaultTerminal & tmBootLines .~ ss' <> tlSetStatus (TerminalPressTo "QUIT") <> tlDoEffect TmWdWdPowerDownTerminal)
|
||||||
& plSpot
|
& plSpot
|
||||||
.~ rprBoolShift
|
.~ rprBoolShift
|
||||||
isUnusedLnk
|
isUnusedLnk
|
||||||
(\(p, a) -> ((p + 10 *.* unitVectorAtAngle (a - pi / 2), a), S.singleton UsedPosLow))
|
(\(p, a) -> ((p + 10 *.* unitVectorAtAngle (a - pi / 2), a), S.singleton UsedPosLow))
|
||||||
ss' =
|
ss' =
|
||||||
[ makeTermLine "---------------------------------------------"
|
[ makeTermLine "---------------------------------------------"
|
||||||
, makeTermLine "HOLD [CAPS] AND SCROLL"
|
, makeTermLine "HOLD [CAPS] AND SCROLL"
|
||||||
@@ -455,8 +467,8 @@ getCrsFromRooms' is gw = fmap h $ show $ foldMap f (IM.restrictKeys (gw ^. genRo
|
|||||||
js = getRoomsFromInts is gw
|
js = getRoomsFromInts is gw
|
||||||
f rm = shortShow <$> rm ^.. rmPmnts . each . plType
|
f rm = shortShow <$> rm ^.. rmPmnts . each . plType
|
||||||
|
|
||||||
--f rm = foldMap g $ rm ^. rmPmnts
|
-- f rm = foldMap g $ rm ^. rmPmnts
|
||||||
--g x = case x ^. plType of
|
-- g x = case x ^. plType of
|
||||||
-- PutCrit _ -> [x ^?! plMID . _Just]
|
-- PutCrit _ -> [x ^?! plMID . _Just]
|
||||||
-- _ -> []
|
-- _ -> []
|
||||||
|
|
||||||
@@ -480,26 +492,28 @@ sensorTut =
|
|||||||
|
|
||||||
-- <> tlSetStatus (TerminalPressTo "CONTINUE")
|
-- <> tlSetStatus (TerminalPressTo "CONTINUE")
|
||||||
|
|
||||||
tutRezBox :: RandomGen g => State g Room
|
tutRezBox :: (RandomGen g) => State g Room
|
||||||
tutRezBox = do
|
tutRezBox = do
|
||||||
ls <- rezColor
|
ls <- rezColor
|
||||||
return $
|
return $
|
||||||
roomRect 40 60 1 1
|
roomRect 40 60 1 1
|
||||||
& rmPmnts
|
& rmPmnts
|
||||||
.~ [ sPS (V2 20 1) 0 $ PutLS ls
|
.~ [ sPS (V2 20 1) 0 $ PutLS ls
|
||||||
, Placement (PS 0 0) PutNothing Nothing Nothing $ \w _ ->
|
, Placement (PS 0 0) PutNothing Nothing Nothing $ \w _ ->
|
||||||
Just $
|
Just $
|
||||||
putImmediateMessageTerminal
|
putImmediateMessageTerminal
|
||||||
( defaultTerminal & tmBootLines .~ s w
|
( defaultTerminal & tmBootLines .~ s w
|
||||||
<> tlSetStatus (TerminalPressTo "QUIT")
|
<> tlSetStatus (TerminalPressTo "QUIT")
|
||||||
<> tlDoEffect TmWdWdPowerDownTerminal
|
<> tlDoEffect TmWdWdPowerDownTerminal
|
||||||
-- <> tlDoEffect (TmWdWdLeaveTerminal "QUIT")
|
-- <> tlDoEffect (TmWdWdLeaveTerminal "QUIT")
|
||||||
)
|
)
|
||||||
& plSpot .~ PS (V2 20 0) 0
|
& plSpot
|
||||||
]
|
.~ PS (V2 20 0) 0
|
||||||
|
]
|
||||||
& restrictInLinks (\(V2 _ h, _) -> h < 1)
|
& restrictInLinks (\(V2 _ h, _) -> h < 1)
|
||||||
& restrictOutLinks (\(V2 _ h, _) -> h > 59)
|
& restrictOutLinks (\(V2 _ h, _) -> h > 59)
|
||||||
& rmName .~ "tutRezBox"
|
& rmName
|
||||||
|
.~ "tutRezBox"
|
||||||
where
|
where
|
||||||
s w = tutorialMessage1 (w ^. gwWorld . cWorld . cwGen . cwgSeed)
|
s w = tutorialMessage1 (w ^. gwWorld . cWorld . cwGen . cwgSeed)
|
||||||
|
|
||||||
@@ -517,23 +531,24 @@ tutorialMessage1 i =
|
|||||||
, makeTermLine " [D] TO MOVE"
|
, makeTermLine " [D] TO MOVE"
|
||||||
, makeTermLine "--------------------------------------------"
|
, makeTermLine "--------------------------------------------"
|
||||||
]
|
]
|
||||||
|
|
||||||
-- <> tlSetStatus (TerminalPressTo "CONTINUE")
|
-- <> tlSetStatus (TerminalPressTo "CONTINUE")
|
||||||
-- <> [ makeTermLine "AFTER EXITING THIS TERMINAL YOUR INVENTORY"
|
-- <> [ makeTermLine "AFTER EXITING THIS TERMINAL YOUR INVENTORY"
|
||||||
-- , makeTermLine " AND NEARBY OBJECTS WILL BE DISPLAYED"
|
-- , makeTermLine " AND NEARBY OBJECTS WILL BE DISPLAYED"
|
||||||
-- , makeTermLine "--------------------------------------------"
|
-- , makeTermLine "--------------------------------------------"
|
||||||
-- ]
|
-- ]
|
||||||
passthroughLockKeyLists ::
|
passthroughLockKeyLists ::
|
||||||
[(Int -> State LayoutVars (MetaTree Room String), State LayoutVars ItemType)]
|
[(Int -> State LayoutVars (MetaTree Room String), State LayoutVars ItemType)] ->
|
||||||
-> [(ItemType, State LayoutVars (MetaTree Room String))]
|
[(ItemType, State LayoutVars (MetaTree Room String))] ->
|
||||||
-> State LayoutVars (MetaTree Room String)
|
State LayoutVars (MetaTree Room String)
|
||||||
passthroughLockKeyLists ls ks = do
|
passthroughLockKeyLists ls ks = do
|
||||||
i <- nextLayoutInt
|
i <- nextLayoutInt
|
||||||
(functionlockroom, randomitemidentity) <- takeOne ls
|
(functionlockroom, randomitemidentity) <- takeOne ls
|
||||||
lr <- functionlockroom i
|
lr <- functionlockroom i
|
||||||
ii <- randomitemidentity
|
ii <- randomitemidentity
|
||||||
keyroom <- fromJust $ lookup ii ks
|
keyroom <- fromJust $ lookup ii ks
|
||||||
return $
|
return $
|
||||||
MTree
|
MTree
|
||||||
("PassthroughLockKeyLists-" ++ show ii)
|
("PassthroughLockKeyLists-" ++ show ii)
|
||||||
(NodeMTree $ MTree "RassThroughLockKeyLists" (NodeMTree lr) [MBranch (toLabel i) keyroom])
|
(NodeMTree $ MTree "RassThroughLockKeyLists" (NodeMTree lr) [MBranch (toLabel i) keyroom])
|
||||||
[]
|
[]
|
||||||
|
|||||||
+4
-15
@@ -30,9 +30,12 @@ import qualified Data.Map.Strict as M
|
|||||||
import NewInt
|
import NewInt
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import Data.Monoid
|
import Data.Monoid
|
||||||
|
import RandomHelp
|
||||||
|
|
||||||
testStringInit :: Universe -> [String]
|
testStringInit :: Universe -> [String]
|
||||||
testStringInit u = fmap show $ u ^.. uvWorld . cWorld . lWorld . machines . each . mcHP
|
testStringInit u = [evalState (takeOne ["a","b"]) (_randGen $ _uvWorld u)]
|
||||||
|
-- (fmap show $ u ^.. uvWorld . cWorld . lWorld . machines . each . mcType . _McDamSensor . sensAmount)
|
||||||
|
-- <> (fmap show $ u ^.. uvWorld . cWorld . lWorld . machines . each . mcMaterial)
|
||||||
--testStringInit u = map show (u ^.. uvWorld . cWorld . lWorld . machines . traverse . mcDir)
|
--testStringInit u = map show (u ^.. uvWorld . cWorld . lWorld . machines . traverse . mcDir)
|
||||||
--testStringInit u = map show
|
--testStringInit u = map show
|
||||||
-- (u ^.. uvWorld . cWorld . lWorld . machines . traverse .mcType . _McDistributer)
|
-- (u ^.. uvWorld . cWorld . lWorld . machines . traverse .mcType . _McDistributer)
|
||||||
@@ -61,20 +64,6 @@ showManObj (SelCloseItem x) = "CloseItem " ++ show x
|
|||||||
showManObj SortCloseButton = "SortCloseButton"
|
showManObj SortCloseButton = "SortCloseButton"
|
||||||
showManObj (SelCloseButton x) = "CloseButton " ++ show x
|
showManObj (SelCloseButton x) = "CloseButton " ++ show x
|
||||||
|
|
||||||
|
|
||||||
--testStringInit u = fromMaybe mempty $ do
|
|
||||||
-- inv <- fmap invLDT $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv
|
|
||||||
-- invitm <- inv ^? ix 1
|
|
||||||
-- return $ concatMap (prettyLDT (\(x,_,_,_) -> take 5 (show $ x ^. itType . iyBase))) [invitm]
|
|
||||||
|
|
||||||
--testStringInit u = maybe [] invTree (u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv)
|
|
||||||
-- [fromMaybe "" $ do
|
|
||||||
-- cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
|
|
||||||
-- i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
|
||||||
-- fmap (show . canAttachTargeting) (cr ^? crInv . ix i)
|
|
||||||
-- ]
|
|
||||||
|
|
||||||
|
|
||||||
showTimeFlow :: TimeFlowStatus -> String
|
showTimeFlow :: TimeFlowStatus -> String
|
||||||
showTimeFlow tfs = case tfs of
|
showTimeFlow tfs = case tfs of
|
||||||
RespawnDelay i -> "Respawndelay"++show i
|
RespawnDelay i -> "Respawndelay"++show i
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
-- | Combining and composing trees of trees.
|
-- | Combining and composing trees of trees.
|
||||||
module Dodge.Tree.Compose (
|
module Dodge.Tree.Compose (
|
||||||
tToBTree,
|
tToBTree,
|
||||||
overwriteLabel,
|
|
||||||
composeTree,
|
composeTree,
|
||||||
decomposeTree,
|
decomposeTree,
|
||||||
numMetaTree,
|
numMetaTree,
|
||||||
@@ -16,6 +15,7 @@ module Dodge.Tree.Compose (
|
|||||||
attachOnward,
|
attachOnward,
|
||||||
attachOnward',
|
attachOnward',
|
||||||
showIntsString,
|
showIntsString,
|
||||||
|
overwriteLabel,
|
||||||
module Dodge.Data.MetaTree
|
module Dodge.Data.MetaTree
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -6,7 +6,6 @@ module Dodge.Update (updateUniverse) where
|
|||||||
import Data.Function (on)
|
import Data.Function (on)
|
||||||
import Dodge.Zoning.Wall
|
import Dodge.Zoning.Wall
|
||||||
import Bound
|
import Bound
|
||||||
import Dodge.Data.DoubleTree
|
|
||||||
import Dodge.HeldUse
|
import Dodge.HeldUse
|
||||||
import Dodge.DoubleTree
|
import Dodge.DoubleTree
|
||||||
import Dodge.Item.Grammar
|
import Dodge.Item.Grammar
|
||||||
@@ -337,7 +336,7 @@ muzzleWallCheck w cr = fromMaybe cr $ do
|
|||||||
else let v = minimumBy (compare `on` norm) vs
|
else let v = minimumBy (compare `on` norm) vs
|
||||||
in cr & crPos . _xy +~ normalize v
|
in cr & crPos . _xy +~ normalize v
|
||||||
where
|
where
|
||||||
f loc = map (muzzlePos loc cr) (itemMuzzles $ loc ^. locDT . dtValue . _1)
|
f loc = map (muzzlePos loc cr) (itemMuzzles $ loc)
|
||||||
g cp wls p = case collidePoint cp p wls of
|
g cp wls p = case collidePoint cp p wls of
|
||||||
(ep,Just _) -> Just (ep - p)
|
(ep,Just _) -> Just (ep - p)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|||||||
@@ -183,8 +183,7 @@ heldAimZoom = \case
|
|||||||
FLAMETORRENT -> 1
|
FLAMETORRENT -> 1
|
||||||
FLAMEWALL -> 1
|
FLAMEWALL -> 1
|
||||||
BLOWTORCH -> 1
|
BLOWTORCH -> 1
|
||||||
SPARKGUN -> 1
|
TESLACOIL -> 1.5
|
||||||
TESLAGUN -> 1.5
|
|
||||||
TRACTORGUN -> 1.5
|
TRACTORGUN -> 1.5
|
||||||
RLAUNCHER -> 1.5
|
RLAUNCHER -> 1.5
|
||||||
RLAUNCHERX{} -> 1.5
|
RLAUNCHERX{} -> 1.5
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ damageWall wlid dt w = fromMaybe (mempty,w) $ do
|
|||||||
& maybeDestroyDoor drid
|
& maybeDestroyDoor drid
|
||||||
_ -> (mempty, w')
|
_ -> (mempty, w')
|
||||||
|
|
||||||
|
-- the way that sensor damage is registered is not yet ideal
|
||||||
damageMachine :: Damage -> Int -> Int -> World -> (S.Set Int2, World)
|
damageMachine :: Damage -> Int -> Int -> World -> (S.Set Int2, World)
|
||||||
damageMachine dam x mcid w = case w ^? cWorld . lWorld . machines . ix mcid of
|
damageMachine dam x mcid w = case w ^? cWorld . lWorld . machines . ix mcid of
|
||||||
Just mc | Just se <- mc ^? mcType . _McDamSensor
|
Just mc | Just se <- mc ^? mcType . _McDamSensor
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ doWdWd = \case
|
|||||||
UseInvItem invid pt -> \w -> fromMaybe w (useItem invid pt w)
|
UseInvItem invid pt -> \w -> fromMaybe w (useItem invid pt w)
|
||||||
WdWdBurstFireRepetition cid invid -> \w -> fromMaybe w $ do
|
WdWdBurstFireRepetition cid invid -> \w -> fromMaybe w $ do
|
||||||
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
cr <- w ^? cWorld . lWorld . creatures . ix cid
|
||||||
--itree <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
|
|
||||||
loc <- invIndents (fmap (\k -> w ^?! cWorld . lWorld . items . ix k) $ cr ^. crInv) ^? ix (_unNInt invid) . _2
|
loc <- invIndents (fmap (\k -> w ^?! cWorld . lWorld . items . ix k) $ cr ^. crInv) ^? ix (_unNInt invid) . _2
|
||||||
return $ heldEffectMuzzles loc cr w
|
return $ heldEffectMuzzles loc cr w
|
||||||
|
|
||||||
|
|||||||
+55
-37
@@ -2,13 +2,13 @@
|
|||||||
{- Helpers for random generation. -}
|
{- Helpers for random generation. -}
|
||||||
module RandomHelp (
|
module RandomHelp (
|
||||||
module System.Random,
|
module System.Random,
|
||||||
-- module Control.Monad.State,
|
-- module Control.Monad.State,
|
||||||
module RandomHelp,
|
module RandomHelp,
|
||||||
module Control.Monad.Trans.State.Lazy,
|
module Control.Monad.Trans.State.Lazy,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
--import Control.Monad.State
|
-- import Control.Monad.State
|
||||||
import Control.Monad.Trans.State.Lazy
|
import Control.Monad.Trans.State.Lazy
|
||||||
import Data.List
|
import Data.List
|
||||||
import Geometry
|
import Geometry
|
||||||
@@ -21,8 +21,25 @@ randomRanges = join . takeOne . f
|
|||||||
f (x : y : ys) = state (randomR (x, y)) : f ys
|
f (x : y : ys) = state (randomR (x, y)) : f ys
|
||||||
f _ = []
|
f _ = []
|
||||||
|
|
||||||
takeOne :: RandomGen g => [a] -> State g a
|
takeOne :: (RandomGen g) => [a] -> State g a
|
||||||
takeOne xs = state (randomR (0, length xs - 1)) >>= (\i -> return (xs !! i))
|
takeOne xs = state (randomR (0, length xs - 1)) >>= \i -> return (xs !! i)
|
||||||
|
|
||||||
|
takeOneRem :: (RandomGen g) => [a] -> State g (Maybe (a, [a]))
|
||||||
|
takeOneRem [] = return Nothing
|
||||||
|
takeOneRem xs =
|
||||||
|
state (randomR (0, length xs - 1)) >>= \i -> do
|
||||||
|
let (ys, (z : zs)) = splitAt i xs
|
||||||
|
return $ Just (z, ys <> zs)
|
||||||
|
|
||||||
|
takeOneFiltered :: (RandomGen g) => (a -> Bool) -> [a] -> State g (Maybe a)
|
||||||
|
takeOneFiltered t xs = do
|
||||||
|
m <- takeOneRem xs
|
||||||
|
f m
|
||||||
|
where
|
||||||
|
f Nothing = return Nothing
|
||||||
|
f (Just (y, ys))
|
||||||
|
| t y = return $ Just y
|
||||||
|
| otherwise = takeOneFiltered t ys
|
||||||
|
|
||||||
takeOneWeighted :: (RandomGen g, Random b, Ord b, Num b) => [b] -> [a] -> State g a
|
takeOneWeighted :: (RandomGen g, Random b, Ord b, Num b) => [b] -> [a] -> State g a
|
||||||
takeOneWeighted ws xs = state (randomR (0, sum ws)) >>= (\w -> return (xs !! i w ws))
|
takeOneWeighted ws xs = state (randomR (0, sum ws)) >>= (\w -> return (xs !! i w ws))
|
||||||
@@ -32,25 +49,25 @@ takeOneWeighted ws xs = state (randomR (0, sum ws)) >>= (\w -> return (xs !! i w
|
|||||||
| otherwise = 1 + i (y - z) zs
|
| otherwise = 1 + i (y - z) zs
|
||||||
i _ _ = 0
|
i _ _ = 0
|
||||||
|
|
||||||
--{-# OPTIONS -Wno-incomplete-uni-patterns #-}
|
-- {-# OPTIONS -Wno-incomplete-uni-patterns #-}
|
||||||
takeOneMore :: RandomGen g => ([a], [a]) -> State g ([a], [a])
|
takeOneMore :: (RandomGen g) => ([a], [a]) -> State g ([a], [a])
|
||||||
takeOneMore (_, []) = error "trying to takeOneMore from empty list"
|
takeOneMore (_, []) = error "trying to takeOneMore from empty list"
|
||||||
takeOneMore (xs, ys) = do
|
takeOneMore (xs, ys) = do
|
||||||
i <- state $ randomR (0, length ys - 1)
|
i <- state $ randomR (0, length ys - 1)
|
||||||
let (zs, w : ws) = splitAt i ys
|
let (zs, w : ws) = splitAt i ys
|
||||||
return (w : xs, zs ++ ws)
|
return (w : xs, zs ++ ws)
|
||||||
|
|
||||||
takeNMore :: RandomGen g => Int -> ([a], [a]) -> State g ([a], [a])
|
takeNMore :: (RandomGen g) => Int -> ([a], [a]) -> State g ([a], [a])
|
||||||
takeNMore n p = foldl' (flip $ const (>>= takeOneMore)) (return p) [1 .. n]
|
takeNMore n p = foldl' (flip $ const (>>= takeOneMore)) (return p) [1 .. n]
|
||||||
|
|
||||||
takeN :: RandomGen g => Int -> [a] -> State g [a]
|
takeN :: (RandomGen g) => Int -> [a] -> State g [a]
|
||||||
takeN 0 _ = return []
|
takeN 0 _ = return []
|
||||||
takeN i xs = fst <$> takeNMore i ([], xs)
|
takeN i xs = fst <$> takeNMore i ([], xs)
|
||||||
|
|
||||||
-- | Randomly shuffle a list.
|
-- | Randomly shuffle a list.
|
||||||
shuffle :: RandomGen g => [a] -> State g [a]
|
shuffle :: (RandomGen g) => [a] -> State g [a]
|
||||||
shuffle xs = do
|
shuffle xs = do
|
||||||
rands <- forM [0 .. length xs -1] $ \i -> state $ randomR (0, i)
|
rands <- forM [0 .. length xs - 1] $ \i -> state $ randomR (0, i)
|
||||||
let f ys rand =
|
let f ys rand =
|
||||||
let (as, b : bs) = splitAt rand ys
|
let (as, b : bs) = splitAt rand ys
|
||||||
in (as ++ bs, b)
|
in (as ++ bs, b)
|
||||||
@@ -58,94 +75,95 @@ shuffle xs = do
|
|||||||
return $ forceElements zs `seq` zs
|
return $ forceElements zs `seq` zs
|
||||||
|
|
||||||
-- | Randomly shuffle the tail of a list, not safe.
|
-- | Randomly shuffle the tail of a list, not safe.
|
||||||
shuffleTail :: RandomGen g => [a] -> State g [a]
|
shuffleTail :: (RandomGen g) => [a] -> State g [a]
|
||||||
shuffleTail (x : xs) = (x :) <$> shuffle xs
|
shuffleTail (x : xs) = (x :) <$> shuffle xs
|
||||||
shuffleTail _ = undefined
|
shuffleTail _ = undefined
|
||||||
|
|
||||||
-- select elements from a list randomly
|
-- select elements from a list randomly
|
||||||
-- each element has the same independent chance of being selected
|
-- each element has the same independent chance of being selected
|
||||||
randomSelectionFromList :: RandomGen g => Float -> [a] -> State g [a]
|
randomSelectionFromList :: (RandomGen g) => Float -> [a] -> State g [a]
|
||||||
randomSelectionFromList = filterM . const . randProb
|
randomSelectionFromList = filterM . const . randProb
|
||||||
|
|
||||||
randProb :: RandomGen g => Float -> State g Bool
|
randProb :: (RandomGen g) => Float -> State g Bool
|
||||||
randProb p = do
|
randProb p = do
|
||||||
p1 <- state $ randomR (0, 1)
|
p1 <- state $ randomR (0, 1)
|
||||||
return (p1 < p)
|
return (p1 < p)
|
||||||
|
|
||||||
randInCirc :: RandomGen g => Float -> State g Point2
|
randInCirc :: (RandomGen g) => Float -> State g Point2
|
||||||
randInCirc = flip randInArc (2 * pi)
|
randInCirc = flip randInArc (2 * pi)
|
||||||
|
|
||||||
randOnCirc :: RandomGen g => Float -> State g Point2
|
randOnCirc :: (RandomGen g) => Float -> State g Point2
|
||||||
randOnCirc r = do
|
randOnCirc r = do
|
||||||
a <- state $ randomR (0, 2*pi)
|
a <- state $ randomR (0, 2 * pi)
|
||||||
return $ r *.* unitVectorAtAngle a
|
return $ r *.* unitVectorAtAngle a
|
||||||
|
|
||||||
randInArc :: RandomGen g => Float -> Float -> State g Point2
|
randInArc :: (RandomGen g) => Float -> Float -> State g Point2
|
||||||
randInArc = randInArcStrip 0
|
randInArc = randInArcStrip 0
|
||||||
|
|
||||||
randInArcStrip :: RandomGen g => Float -> Float -> Float -> State g Point2
|
randInArcStrip :: (RandomGen g) => Float -> Float -> Float -> State g Point2
|
||||||
randInArcStrip minrad maxRad maxangle = do
|
randInArcStrip minrad maxRad maxangle = do
|
||||||
rad <- state $ randomR (minrad, maxRad)
|
rad <- state $ randomR (minrad, maxRad)
|
||||||
ang <- state $ randomR (0, maxangle)
|
ang <- state $ randomR (0, maxangle)
|
||||||
return $ rad *.* unitVectorAtAngle ang
|
return $ rad *.* unitVectorAtAngle ang
|
||||||
|
|
||||||
randOnUnitSphere :: RandomGen g => State g Point3
|
randOnUnitSphere :: (RandomGen g) => State g Point3
|
||||||
randOnUnitSphere = do
|
randOnUnitSphere = do
|
||||||
z <- state $ randomR (negate 1, 1)
|
z <- state $ randomR (negate 1, 1)
|
||||||
longitude <- state $ randomR (0, 2 * pi)
|
longitude <- state $ randomR (0, 2 * pi)
|
||||||
let (V2 x y) = sqrt (1 - z ^ (2 :: Int)) *.* unitVectorAtAngle longitude
|
let (V2 x y) = sqrt (1 - z ^ (2 :: Int)) *.* unitVectorAtAngle longitude
|
||||||
return (V3 x y z)
|
return (V3 x y z)
|
||||||
|
|
||||||
randOnHemisphere :: RandomGen g => State g Point3
|
randOnHemisphere :: (RandomGen g) => State g Point3
|
||||||
randOnHemisphere = do
|
randOnHemisphere = do
|
||||||
z <- state $ randomR (0, 1)
|
z <- state $ randomR (0, 1)
|
||||||
longitude <- state $ randomR (0, 2 * pi)
|
longitude <- state $ randomR (0, 2 * pi)
|
||||||
let (V2 x y) = sqrt (1 - z ^ (2 :: Int)) *.* unitVectorAtAngle longitude
|
let (V2 x y) = sqrt (1 - z ^ (2 :: Int)) *.* unitVectorAtAngle longitude
|
||||||
return (V3 x y z)
|
return (V3 x y z)
|
||||||
|
|
||||||
randInHemisphere :: RandomGen g => State g Point3
|
randInHemisphere :: (RandomGen g) => State g Point3
|
||||||
randInHemisphere = do
|
randInHemisphere = do
|
||||||
p <- randOnHemisphere
|
p <- randOnHemisphere
|
||||||
r <- state $ randomR (0, 1)
|
r <- state $ randomR (0, 1)
|
||||||
return $ r *.*.* p
|
return $ r *.*.* p
|
||||||
|
|
||||||
randInRect :: RandomGen g => Float -> Float -> State g Point2
|
randInRect :: (RandomGen g) => Float -> Float -> State g Point2
|
||||||
randInRect w h = do
|
randInRect w h = do
|
||||||
x <- state $ randomR (0, w)
|
x <- state $ randomR (0, w)
|
||||||
y <- state $ randomR (0, h)
|
y <- state $ randomR (0, h)
|
||||||
return (V2 x y)
|
return (V2 x y)
|
||||||
|
|
||||||
maybeTakeOne :: RandomGen g => [a] -> State g (Maybe a)
|
maybeTakeOne :: (RandomGen g) => [a] -> State g (Maybe a)
|
||||||
maybeTakeOne [] = return Nothing
|
maybeTakeOne [] = return Nothing
|
||||||
maybeTakeOne xs = state (randomR (0, length xs - 1)) >>= (\i -> return (Just (xs !! i)))
|
maybeTakeOne xs = state (randomR (0, length xs - 1)) >>= (\i -> return (Just (xs !! i)))
|
||||||
|
|
||||||
randsSpread :: RandomGen g => (Float, Float) -> Int -> State g [Float]
|
randsSpread :: (RandomGen g) => (Float, Float) -> Int -> State g [Float]
|
||||||
randsSpread (a, b) i
|
randsSpread (a, b) i
|
||||||
| i <= 0 = error "tried to take <= 0 randsSpread"
|
| i <= 0 = error "tried to take <= 0 randsSpread"
|
||||||
| otherwise = zipWith (+) [a + x, a + 2 * x ..] <$> replicateM i (state $ randomR (0, x))
|
| otherwise = zipWith (+) [a + x, a + 2 * x ..] <$> replicateM i (state $ randomR (0, x))
|
||||||
where
|
where
|
||||||
x = (b - a) / fromIntegral i
|
x = (b - a) / fromIntegral i
|
||||||
|
|
||||||
randsOnCirc :: RandomGen g => Int -> State g [Float]
|
randsOnCirc :: (RandomGen g) => Int -> State g [Float]
|
||||||
randsOnCirc = randsSpread (0, 2 * pi)
|
randsOnCirc = randsSpread (0, 2 * pi)
|
||||||
|
|
||||||
randPeakedParam :: RandomGen g => Int -> Float -> Float -> Float -> State g Float
|
randPeakedParam :: (RandomGen g) => Int -> Float -> Float -> Float -> State g Float
|
||||||
randPeakedParam i a b c = do
|
randPeakedParam i a b c = do
|
||||||
x <- state $ randomR (-1, 1)
|
x <- state $ randomR (-1, 1)
|
||||||
let y = x ^ i
|
let y = x ^ i
|
||||||
return $ if y < 0
|
return $
|
||||||
then a + y * (a-b)
|
if y < 0
|
||||||
else b + y * (c-b)
|
then a + y * (a - b)
|
||||||
|
else b + y * (c - b)
|
||||||
|
|
||||||
randPeaked :: RandomGen g => Float -> Float -> Float -> State g Float
|
randPeaked :: (RandomGen g) => Float -> Float -> Float -> State g Float
|
||||||
randPeaked = randPeakedParam 3
|
randPeaked = randPeakedParam 3
|
||||||
|
|
||||||
randFromPair :: RandomGen g => Float -> (a,a) -> State g a
|
randFromPair :: (RandomGen g) => Float -> (a, a) -> State g a
|
||||||
randFromPair x (l,r) = do
|
randFromPair x (l, r) = do
|
||||||
y <- state $ randomR (0,1)
|
y <- state $ randomR (0, 1)
|
||||||
if x < y then return l else return r
|
if x < y then return l else return r
|
||||||
|
|
||||||
shufflePair :: RandomGen g => (a,a) -> State g (a,a)
|
shufflePair :: (RandomGen g) => (a, a) -> State g (a, a)
|
||||||
shufflePair (x,y) = do
|
shufflePair (x, y) = do
|
||||||
v <- state $ randomR (0::Float,1)
|
v <- state $ randomR (0 :: Float, 1)
|
||||||
if v > 0.5 then return (x,y) else return (y,x)
|
if v > 0.5 then return (x, y) else return (y, x)
|
||||||
|
|||||||
Reference in New Issue
Block a user