Compare commits

...

65 Commits

Author SHA1 Message Date
justin db24b0ffa6 Use circles instead of points for zome wall zones 2026-02-03 13:48:15 +00:00
justin be6acfa58b Update tutorial rooms 2026-02-02 22:45:29 +00:00
justin 68609c9d54 Tweak bullet hit sound 2026-02-02 22:28:06 +00:00
justin 3b7e33cab8 Tweak ledge room, rename roomRectAutoLinks 2026-02-02 10:44:27 +00:00
justin f3aaf8ba57 Room with doors and central ledge terminal 2026-02-01 22:23:06 +00:00
justin a6976eae8d Non-convex chasms 2026-01-26 10:59:51 +00:00
justin 962df63e62 Remove mtl dependency 2026-01-23 09:59:18 +00:00
justin a464d4dc38 Improve wrist forcefield positioning
Not perfect for left wrist when aiming two handed twist weapons
2026-01-22 21:19:40 +00:00
justin f1c63abdc3 Simplify some attachment use types 2026-01-02 21:45:12 +00:00
justin 3cc439b877 Cleanup defaults 2026-01-02 21:33:00 +00:00
justin 02da762f2f Orient alteRifle ammo 2026-01-02 21:14:19 +00:00
justin c02a1fd212 Orient volleygun ammo attachments 2026-01-02 20:25:56 +00:00
justin 736d0494c4 Improve minigun spinning shape 2026-01-02 20:03:25 +00:00
justin 030a021aa1 Tweak inventory display 2026-01-02 19:33:28 +00:00
justin d68cb97f6b Tweak rmb cursor display 2026-01-02 18:55:40 +00:00
justin 376ce4462c Improve drawRBOptions positioning 2026-01-02 18:36:35 +00:00
justin 71f56c0638 Allow for creature death sounds 2026-01-02 15:06:02 +00:00
justin b414da7dab Fix flatshield wall creation and remove muzzle 2026-01-02 12:34:17 +00:00
justin f6f63c9a14 Remove graphviz dependency 2026-01-02 11:40:14 +00:00
justin 3b4e24b74f Disable face culling on fixed layer, for aim sweep reverse winding 2026-01-02 11:34:45 +00:00
justin 804e4eb1e2 Cleanup 2026-01-02 11:07:47 +00:00
justin 119234af89 Fix picture vertex buffering bug 2026-01-02 10:58:28 +00:00
justin 2c978b4de1 Move towards resolving picture rendering bug
The bug concerns a mutable vector storing the amount of data that has
been poked.
2026-01-01 23:44:18 +00:00
justin 0a8725f68d Implement (broken) push away from walls according to muzzle pos 2026-01-01 11:10:00 +00:00
justin 5b5a12be6e Simplify and improve distributer 2025-12-31 13:31:08 +00:00
justin fa07f989c2 Add sound for distributer 2025-12-31 13:06:46 +00:00
justin 6db7efece1 Cleanup 2025-12-30 20:52:04 +00:00
justin 579b82b4ed Cleanup 2025-12-30 19:55:39 +00:00
justin 91aac70edf Cleanup 2025-12-30 19:39:30 +00:00
justin 26b4b77ff6 Fix terminal scrolling 2025-12-30 19:28:05 +00:00
justin 4390a82d64 Work on terminal tab completion/scrolling 2025-12-28 18:16:24 +00:00
justin bb376b0a56 Work on tab completion 2025-12-26 21:49:39 +00:00
justin 2fd4a3d2e3 Add sounds 2025-12-26 20:45:24 +00:00
justin 60a69d0092 Improve handle position for one handed at ease carry 2025-12-26 16:58:25 +00:00
justin b446ff2366 Add sound, cleanup 2025-12-26 16:53:10 +00:00
justin 50e9a65404 Cleanup 2025-12-26 16:04:45 +00:00
justin 157d63a714 Add sound, cleanup 2025-12-26 16:01:07 +00:00
justin 3f7eeb871c Cleanup 2025-12-26 15:43:21 +00:00
justin 3c07069adc Introduce destructible switches 2025-12-26 15:10:37 +00:00
justin 29394e86a3 Unify background machine sounds 2025-12-26 12:49:49 +00:00
justin 337e786f33 Add some background sounds to machines 2025-12-26 12:30:05 +00:00
justin 2575ccc0f4 Limit terminal display to 13 lines, terminal displays with padding 2025-12-26 11:53:36 +00:00
justin 589cfd6d79 Remove heading from terminal display 2025-12-26 11:48:41 +00:00
justin 98c411c581 Cleanup 2025-12-26 11:43:13 +00:00
justin de5a5854bf Make distribution terminal handle its own sound 2025-12-26 11:42:18 +00:00
justin ada80fb925 Add sounds when distributing ammo 2025-12-26 11:35:14 +00:00
justin 2f935a0d41 Tweak inventory display 2025-12-26 11:05:34 +00:00
justin 2cb9fb153a Add hacky block shadow to inventory items 2025-12-26 10:41:21 +00:00
justin b9a6bd5f67 Make Nearby Items subheading disappear if none nearby/not filtering 2025-12-24 22:14:13 +00:00
justin 27cb05b8f7 Only update stride amount when actually moving 2025-12-24 22:02:43 +00:00
justin 8e484e37a9 Fix distributer not to take ammo from overfilled magazines 2025-12-24 21:01:49 +00:00
justin 225ee310ad Tweak drawRBOptions, still not completely correct 2025-12-24 20:54:36 +00:00
justin faa40bdd9f Clicking on button in inventory list activates button 2025-12-24 20:25:06 +00:00
justin de6bbe7697 Fix terminal mouse over positioning 2025-12-24 20:10:03 +00:00
justin 3cdab08184 Limit terminal input to 42 characters 2025-12-24 17:00:36 +00:00
justin c96c18b9aa Cleanup 2025-12-24 16:49:51 +00:00
justin a1c20c56ce Cleanup 2025-12-24 16:43:36 +00:00
justin 8cd2625548 Cleanup, hide item selection cursor when in terminal 2025-12-24 13:45:38 +00:00
justin 6becda01d5 Add connector between terminal button and temrinal display 2025-12-23 22:54:56 +00:00
justin 34c86c6a1b Draw cursor over close button of displayed terminal 2025-12-23 22:33:19 +00:00
justin 9e8b847940 Work on terminal text display 2025-12-23 22:02:38 +00:00
justin 238d6b8799 Add border to terminal display 2025-12-23 15:43:56 +00:00
justin 183bb16fca Add custom hlint rules 2025-12-21 22:05:26 +00:00
justin 51c52ace7d More hlinting 2025-12-21 19:27:49 +00:00
justin 2fbaa47c0b First commit on new machine, some hlinting 2025-12-21 18:43:52 +00:00
169 changed files with 4102 additions and 3708 deletions
+70
View File
@@ -0,0 +1,70 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint
##########################
# This file contains a template configuration file, which is typically
# placed as .hlint.yaml in the root of your project
# Specify additional command line arguments
#
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
# Control which extensions/flags/modules/functions can be used
#
# - extensions:
# - default: false # all extension are banned by default
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
#
# - flags:
# - {name: -w, within: []} # -w is allowed nowhere
#
# - modules:
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
#
# - functions:
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
# Add custom hints for this project
#
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
# The hints are named by the string they display in warning messages.
# For example, if you see a warning starting like
#
# Main.hs:116:51: Warning: Redundant ==
#
# You can refer to that hint with `{name: Redundant ==}` (see below).
# Turn on hints that are off by default
#
# Ban "module X(module X) where", to require a real export list
#- warn: {name: Use explicit module export list} # TODO uncomment
#
# Replace a $ b $ c with a . b $ c
#- group: {name: dollar, enabled: true} # TODO uncomment
#
# Generalise map to fmap, ++ to <>
#- group: {name: generalise, enabled: true} # TODO uncomment
#
# Warn on use of partial functions
# - group: {name: partial, enabled: true} # possibly uncomment
- group: {name: use-lens, enabled: true}
# Ignore some builtin hints
# - ignore: {name: Use let}
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
# Define some custom infix operators
# - fixity: infixr 3 ~^#^~
# To generate a suitable file for HLint do:
# $ hlint --default > .hlint.yaml
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+5 -5
View File
@@ -25,16 +25,16 @@ dependencies:
- aeson-pretty - aeson-pretty
- containers - containers
- deepseq - deepseq
- dlist #- dlist
- directory - directory
- extra - extra
- foldl - foldl
- graphviz #- graphviz
- OpenGLRaw - OpenGLRaw
- text - text
- bytestring - bytestring
- lens - lens
- mtl #- mtl
- fgl - fgl
- JuicyPixels - JuicyPixels
- random - random
@@ -81,7 +81,7 @@ executables:
- -fno-state-hack - -fno-state-hack
- -funfolding-use-threshold1000 - -funfolding-use-threshold1000
#- -funfolding-keeness-factor1000 #- -funfolding-keeness-factor1000
- -fllvm # - -fllvm
- -optlo-O3 - -optlo-O3
- -Wall - -Wall
#- -Wcompat #- -Wcompat
@@ -121,7 +121,7 @@ benchmarks:
- -fno-state-hack - -fno-state-hack
- -funfolding-use-threshold1000 - -funfolding-use-threshold1000
# - -funfolding-keeness-factor1000 # - -funfolding-keeness-factor1000
- -fllvm # - -fllvm
#- -optlo-O3 #- -optlo-O3
main: Bench.hs main: Bench.hs
source-dirs: bench source-dirs: bench
+7 -3
View File
@@ -1,6 +1,5 @@
module Bound ( module Bound (boundPoints
boundPoints, ,boundPointsRect) where
) where
import qualified Control.Foldl as L import qualified Control.Foldl as L
import Control.Lens import Control.Lens
@@ -20,3 +19,8 @@ boundPoints =
) )
where where
f (mn, ms, me, mw) = (,,,) <$> mn <*> ms <*> me <*> mw f (mn, ms, me, mw) = (,,,) <$> mn <*> ms <*> me <*> mw
boundPointsRect :: [Point2] -> Maybe (Point2,Point2)
boundPointsRect ps = do
(n,s,e,w) <- boundPoints ps
return (V2 w s, V2 e n)
+31 -21
View File
@@ -1,11 +1,38 @@
module Color ( module Color (
module Color, withAlpha,
red,
green,
blue,
yellow,
cyan,
magenta,
rose,
violet,
azure,
aquamarine,
chartreuse,
orange,
white,
black,
greyN,
mixColors,
brightX,
mixColorsLinear,
mixColorsFrac,
dim,
bright,
light,
dark,
paletteToColor,
lightx4,
toColor8,
normalizeColor,
module Color.Data, module Color.Data,
) where ) where
import Color.Data import Color.Data
import Geometry
import Control.Lens import Control.Lens
import Geometry
withAlpha :: Float -> RGBA -> RGBA withAlpha :: Float -> RGBA -> RGBA
{-# INLINE withAlpha #-} {-# INLINE withAlpha #-}
@@ -81,7 +108,7 @@ normalizeColor (V4 r g b a) = V4 (f r) (f g) (f b) (f a)
mixColorsFrac :: Color -> Color -> Float -> Color mixColorsFrac :: Color -> Color -> Float -> Color
{-# INLINE mixColorsFrac #-} {-# INLINE mixColorsFrac #-}
mixColorsFrac c1 c2 x = mixColors x (1-x) c1 c2 mixColorsFrac c1 c2 x = mixColors x (1 - x) c1 c2
mixColors :: Float -> Float -> Color -> Color -> Color mixColors :: Float -> Float -> Color -> Color -> Color
{-# INLINE mixColors #-} {-# INLINE mixColors #-}
@@ -107,7 +134,7 @@ light (V4 r g b a) = V4 (r + 0.2) (g + 0.2) (b + 0.2) a
dark :: Color -> Color dark :: Color -> Color
{-# INLINE dark #-} {-# INLINE dark #-}
dark (V4 r g b a) = V4 (r -0.2) (g -0.2) (b -0.2) a dark (V4 r g b a) = V4 (r - 0.2) (g - 0.2) (b - 0.2) a
dim :: Color -> Color dim :: Color -> Color
{-# INLINE dim #-} {-# INLINE dim #-}
@@ -125,23 +152,6 @@ greyN :: Float -> Color
{-# INLINE greyN #-} {-# INLINE greyN #-}
greyN x = toV4 (x, x, x, 1) greyN x = toV4 (x, x, x, 1)
numColor :: Int -> Color
{-# INLINE numColor #-}
numColor 0 = toV4 (1, 0, 0, 1)
numColor 1 = toV4 (0, 1, 0, 1)
numColor 2 = toV4 (0, 0, 1, 1)
numColor 3 = toV4 (1, 1, 0, 1)
numColor 4 = toV4 (0, 1, 1, 1)
numColor 5 = toV4 (1, 0, 1, 1)
numColor 6 = toV4 (1, 0, 0.5, 1)
numColor 7 = toV4 (0.5, 0, 1, 1)
numColor 8 = toV4 (0, 0.5, 1, 1)
numColor 9 = toV4 (0, 1, 0.5, 1)
numColor 10 = toV4 (0.5, 1, 0, 1)
numColor 11 = toV4 (1, 0.5, 0, 1)
numColor 12 = toV4 (1, 1, 1, 1)
numColor _ = toV4 (1, 1, 1, 1)
lightx4 :: Color -> Color lightx4 :: Color -> Color
lightx4 = light . light . light . light lightx4 = light . light . light . light
+2 -2
View File
@@ -14,8 +14,8 @@ cardVec cp = case cp of
East -> V2 1 0 East -> V2 1 0
West -> V2 (-1) 0 West -> V2 (-1) 0
cardEightVec :: CardinalEightPoint -> Point2 card8Vec :: Cardinal8 -> Point2
cardEightVec cp = case cp of card8Vec cp = case cp of
North8 -> V2 0 1 North8 -> V2 0 1
NorthEast8 -> V2 1 1 NorthEast8 -> V2 1 1
East8 -> V2 1 0 East8 -> V2 1 0
+1 -1
View File
@@ -287,7 +287,7 @@ circOnSomeWall :: Point2 -> Float -> World -> Bool
{-# INLINE circOnSomeWall #-} {-# INLINE circOnSomeWall #-}
circOnSomeWall p rad = circOnSomeWall p rad =
any (uncurry (circOnSeg p rad) . _wlLine) any (uncurry (circOnSeg p rad) . _wlLine)
. wlsNearPoint p . wlsNearCirc p rad
circOnAnyCr :: Point2 -> Float -> World -> Bool circOnAnyCr :: Point2 -> Float -> World -> Bool
{-# INLINE circOnAnyCr #-} {-# INLINE circOnAnyCr #-}
+1 -1
View File
@@ -31,7 +31,7 @@ worldPosToResOffset cfig cam p =
(worldPosToScreen cam p & each %~ f) (worldPosToScreen cam p & each %~ f)
+ 0.5 *^ ((getWindowSize _gr_world_res cfig :: V2 Int) & each %~ fromIntegral) + 0.5 *^ ((getWindowSize _gr_world_res cfig :: V2 Int) & each %~ fromIntegral)
where where
f x = applyResFactorF (cfig ^. gr_world_res) x f = applyResFactorF (cfig ^. gr_world_res)
-- | The mouse position in world coordinates. -- | The mouse position in world coordinates.
mouseWorldPos :: Input -> Camera -> Point2 mouseWorldPos :: Input -> Camera -> Point2
-150
View File
@@ -1,150 +0,0 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Combine.Graph ( combinationsDotGraph) where
import Dodge.Data.CombAmount
import Data.Bifunctor
import qualified Data.Graph.Inductive as FGL
import Data.GraphViz.Attributes.Complete
import Data.Text (Text)
import Data.Text.Lazy (pack, toStrict)
import Dodge.Combine.Combinations
import Dodge.Data.Item
import GraphHelp
import GraphVizHelp
import LensHelp
data CombClust
= CraftClust
| ItemClust
| JoinClust
deriving (Eq, Ord, Show, Enum, Bounded)
newtype CombNode = CombNode {_unCombNode :: Either ItemType [(CombAmount, ItemType)]}
deriving (Eq, Ord, Show)
instance Labellable CombNode where
toLabelValue (CombNode Right{}) = StrLabel (pack "")
toLabelValue (CombNode (Left ibt)) = StrLabel (pack $ show ibt)
newtype CombEdge = CombEdge {_unCombEdge :: Int}
deriving (Eq, Ord, Show)
instance Labellable CombEdge where
toLabelValue (CombEdge 0) = StrLabel (pack "")
toLabelValue (CombEdge x) = StrLabel (pack $ show x)
--bulletCombinations :: [([(ItAmount, ItemType)], Item)]
--bulletCombinations =
-- filter
-- ( (`elem` map totype bulletWeapons)
-- . totype
-- . snd
-- )
-- itemCombinations
-- where
-- totype = _itType
maxShowX :: ItemType -> Maybe Int
maxShowX = \case
HELD (BANGSTICK _) -> Just 2
HELD (VOLLEYGUN _) -> Just 3
HELD (MINIGUNX _) -> Just 3
HELD (GRAPECANNON _) -> Just 1
HELD (RLAUNCHERX _) -> Just 2
-- HELD (LASWIDE _) -> Just 2
-- LASGUNFOCUS _ -> Just 2
_ -> Nothing
itemCombinationsEdges :: [(CombNode, CombNode, Int)]
itemCombinationsEdges = concatMap (f . over _2 _itType) itemCombinations
where
--itemCombinationsEdges = concatMap (f . over _2 (_iyBase . _itType)) bulletCombinations
f (abts, bt)
| bt `elem` bts = []
| (not . all belowNumX) bts = []
| otherwise = (CombNode $ Right abts, CombNode $ Left bt, 0) : map g abts
where
bts = map snd abts
g (am, bt') = (CombNode $ Left bt', CombNode $ Right abts, _getCombAmount am)
combinationsGraph :: FGL.Gr CombNode CombEdge
combinationsGraph =
FGL.labnfilter (f . _unCombNode . snd)
. second CombEdge
$ mkGraphFromEdges itemCombinationsEdges
where
f Right{} = True
f (Left (CRAFT _)) = False
f (Left bt) = case maxShowX bt of
Nothing -> True
Just i -> _xNum (_ibtHeld bt) <= i
belowNumX :: ItemType -> Bool
belowNumX bt = case maxShowX bt of
Nothing -> True
Just i -> _xNum (_ibtHeld bt) <= i
--toCombNodeLabel :: CombNode -> String
--toCombNodeLabel (CombNode (Left ibt)) = show ibt
--toCombNodeLabel (CombNode Right{}) = ""
combinationsDotGraph :: Text
--combinationsDotGraph = toStrict . printDotGraph . graphToDot nonClusteredParams $ combinationsGraph
combinationsDotGraph =
toStrict . printDotGraph . graphToDot myParams $
combinationsGraph
-- $ first toCombNodeLabel combinationsGraph
myParams :: GraphvizParams Int CombNode CombEdge CombClust CombNode
myParams =
defaultParams -- {globalAttributes = [GraphAttrs [RankDir FromLeft]]}
& isDirectedL .~ True
-- & globalAttributesL .~ [GraphAttrs [RankDir FromLeft,Splines PolyLine]]
& globalAttributesL .~ [GraphAttrs [RankDir FromLeft]]
& clusterByL .~ clusterFunc
& isDotClusterL .~ const False
& clusterIDL .~ setClusterID
& fmtClusterL .~ clusterFormatting
& fmtEdgeL .~ edgeFormatting
& fmtNodeL .~ nodeFormatting
setClusterID :: CombClust -> GraphID
setClusterID = Num . Int . fromEnum
clusterFunc :: (Int, CombNode) -> NodeCluster CombClust (Int, CombNode)
clusterFunc n@(_, CombNode (Left bt)) = case bt of
CRAFT _ -> C CraftClust (N n)
_ -> C ItemClust (N n)
clusterFunc n = C JoinClust (N n)
clusterFormatting :: CombClust -> [GlobalAttributes]
clusterFormatting cl = case cl of
-- CraftClust -> [GraphAttrs [Rank SameRank]]
CraftClust -> []
_ -> []
edgeFormatting :: (Int, Int, CombEdge) -> Attributes
--edgeFormatting (_,_,CombEdge 0) = []
-- [ArrowHead (AType [(ArrMod OpenArrow BothSides ,NoArrow)])
-- ,SameTail (pack "b")
-- ]
edgeFormatting (_, _, ce) = case _unCombEdge ce of
0 ->
[ xLabel ce
, TailPort (CompassPoint East)
]
_ ->
[ xLabel ce
, ArrowHead (AType [(ArrMod OpenArrow BothSides, NoArrow)])
, HeadPort (CompassPoint West)
]
nodeFormatting :: (Int, CombNode) -> Attributes
nodeFormatting (_, CombNode Right{}) = [Shape PointShape]
nodeFormatting (_, CombNode cn@(Left bt)) = case bt of
--CRAFT _ -> [Shape DiamondShape,toLabel (CombNode cn)]
CRAFT _ -> [Color [WC (X11Color Green) Nothing], toLabel (CombNode cn)]
_ -> [Shape BoxShape, toLabel (CombNode cn)]
+15 -1
View File
@@ -129,6 +129,11 @@ inventoryX c = case c of
, tinMag , tinMag
, tinMag , tinMag
, tinMag , tinMag
, volleyGun 4
, tinMag
, tinMag
, drumMag
, drumMag
, burstRifle , burstRifle
, bangCone , bangCone
, tinMag , tinMag
@@ -155,7 +160,7 @@ inventoryX c = case c of
] ]
"E" -> [alteRifle "E" -> [alteRifle
, tinMag , tinMag
, tinMag , drumMag
] <> ] <>
fold fold
[ makeTypeCraftNum 1 SPRING [ makeTypeCraftNum 1 SPRING
@@ -285,6 +290,15 @@ inventoryX c = case c of
, FlashBall ]] , FlashBall ]]
<> [bulletModule (BulletModPayload BulGas)] <> [bulletModule (BulletModPayload BulGas)]
<> [bulletModule (BulletModEffect x) | x <- [minBound .. maxBound]] <> [bulletModule (BulletModEffect x) | x <- [minBound .. maxBound]]
"W" -> [miniGunX 2
, beltMag
, miniGunX 3
, beltMag
, miniGunX 4
, beltMag
, miniGunX 5
, beltMag
]
_ -> [] _ -> []
testInventory :: [Item] testInventory :: [Item]
+1
View File
@@ -10,6 +10,7 @@ module Dodge.Creature.HandPos (
backPQ, backPQ,
headPQ, headPQ,
translateToES, translateToES,
rightHandPQ,
) where ) where
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
+2 -1
View File
@@ -3,7 +3,8 @@
module Dodge.Creature.Impulse (followImpulse) where module Dodge.Creature.Impulse (followImpulse) where
import Control.Monad.State import Control.Monad.Trans.State.Lazy
--import Control.Monad.State -- moving from mtl to transformers
import Data.Maybe import Data.Maybe
import Dodge.Creature.Impulse.Movement import Dodge.Creature.Impulse.Movement
import Dodge.Creature.MoveType import Dodge.Creature.MoveType
+1 -9
View File
@@ -37,7 +37,7 @@ crMvByNoStride p lw cr = crMvAbsoluteNoStride lw (rotateV (_crDir cr) p) cr
crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature crMvAbsolute :: LWorld -> Point2 -> Creature -> Creature
crMvAbsolute lw p' cr = crMvAbsolute lw p' cr =
advanceStepCounter (magV p) cr cr
& crPos . _xy +~ p & crPos . _xy +~ p
& crMvDir .~ argV p & crMvDir .~ argV p
where where
@@ -57,14 +57,6 @@ strengthFactor i
crMvForward :: Float -> LWorld -> Creature -> Creature crMvForward :: Float -> LWorld -> Creature -> Creature
crMvForward speed = crMvBy (V2 speed 0) crMvForward speed = crMvBy (V2 speed 0)
advanceStepCounter :: Float -> Creature -> Creature
advanceStepCounter speed cr = cr & crStance . carriage %~ f
where
f car = case car of
Standing -> f (Walking 0 RightForward)
Walking i ff -> Walking (min (cr ^. crStance . strideLength) (i + speed)) ff
_ -> car
creatureTurnTo :: Point2 -> Creature -> Creature creatureTurnTo :: Point2 -> Creature -> Creature
creatureTurnTo p cr creatureTurnTo p cr
| vToTarg == V2 0 0 = cr -- this should deal with the angleVV error | vToTarg == V2 0 0 = cr -- this should deal with the angleVV error
+1 -1
View File
@@ -2,6 +2,7 @@
module Dodge.Creature.Impulse.UseItem (useItem) where module Dodge.Creature.Impulse.UseItem (useItem) where
import Dodge.Euse
import NewInt import NewInt
import Control.Lens import Control.Lens
import Data.Maybe import Data.Maybe
@@ -9,7 +10,6 @@ import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree import Dodge.Data.DoubleTree
import Dodge.Data.World import Dodge.Data.World
import Dodge.DoubleTree import Dodge.DoubleTree
import Dodge.Equipment
import Dodge.HeldUse import Dodge.HeldUse
import Dodge.Inventory import Dodge.Inventory
import Dodge.Item.Grammar import Dodge.Item.Grammar
+1 -1
View File
@@ -74,7 +74,7 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
ATTACH CAPACITOR -> tryDrawToCapacitor loc w ATTACH CAPACITOR -> tryDrawToCapacitor loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
COPIER _ -> copierItemUpdate itm cr w COPIER _ -> copierItemUpdate itm cr w
HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w HELD FLATSHIELD -> rootAndAttNotEff createShieldWall removeShieldWall itm cr w
HELD MINIGUNX{} -> coolMinigun itm w HELD MINIGUNX{} -> coolMinigun itm w
HELD MACHINEPISTOL{} -> coolMachinePistol cr itm w HELD MACHINEPISTOL{} -> coolMachinePistol cr itm w
LASER | loc ^. locDT . dtValue . _2 == WeaponTargetingSF LASER | loc ^. locDT . dtValue . _2 == WeaponTargetingSF
+16 -1
View File
@@ -1,5 +1,8 @@
module Dodge.Creature.Update (updateCreature) where module Dodge.Creature.Update (updateCreature) where
import Dodge.Creature.Vocalization
import RandomHelp
import Data.Maybe
import Linear import Linear
import NewInt import NewInt
import Color import Color
@@ -88,11 +91,22 @@ checkDeath' cr w = case cr ^. crHP of
corpseOrGib :: Creature -> World -> World corpseOrGib :: Creature -> World -> World
corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of corpseOrGib cr = case cr ^? crDamage . to maxDamageType . _Just . _1 of
Just CookingDamage -> sethp (CrIsCorpse $ scorchSPic thecorpse) Just CookingDamage -> sethp (CrIsCorpse $ scorchSPic thecorpse)
. dodeathsound CookDeath
Just PoisonDamage -> sethp (CrIsCorpse $ poisonSPic thecorpse) Just PoisonDamage -> sethp (CrIsCorpse $ poisonSPic thecorpse)
. dodeathsound PoisonDeath
Just PhysicalDamage | _crPain cr > 200 Just PhysicalDamage | _crPain cr > 200
-> addCrGibs cr . sethp CrIsGibs -> addCrGibs cr . sethp CrIsGibs
. dodeathsound GibsDeath
_ -> sethp (CrIsCorpse thecorpse) _ -> sethp (CrIsCorpse thecorpse)
. dodeathsound PlainDeath
where where
dodeathsound dt = f dt . stopSoundFrom (CrMouth cid)
f dt w = fromMaybe w $ do
let (msid, g) = runState (maybeTakeOne (crDeathSounds cr dt)) (_randGen w)
sid <- msid
return $ w & soundStart (CrMouth cid) (cr ^. crPos . _xy) sid Nothing
& randGen .~ g
cid = cr ^. crID
sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x sethp x = cWorld . lWorld . creatures . ix (_crID cr) . crHP .~ x
thecorpse = makeCorpse cr thecorpse = makeCorpse cr
@@ -110,7 +124,8 @@ chasmTest :: Creature -> World -> World
chasmTest cr w chasmTest cr w
| _crZVel cr < 0 = w & tocr . crZVel -~ 0.5 | _crZVel cr < 0 = w & tocr . crZVel -~ 0.5
& tocr . crPos . _z +~ _crZVel cr & tocr . crPos . _z +~ _crZVel cr
| Just (x, y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms) = w -- | Just (x, y) <- List.find g (foldMap loopPairs $ w ^. cWorld . chasms') = w
| Just (x, y) <- List.find g (w ^. cWorld . cliffs) = w
& soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100) & soundContinue (CrChasm (_crID cr)) (cr ^. crPos . _xy) debrisS (Just 100)
& tocr . crPos . _xy -~ normalizeV (vNormal (x - y)) & tocr . crPos . _xy -~ normalizeV (vNormal (x - y))
| any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5 | any f (w ^. cWorld . chasms) = w & tocr . crZVel -~ 0.5
+19
View File
@@ -1,5 +1,7 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.Vocalization ( module Dodge.Creature.Vocalization (
crWarningSounds, crWarningSounds,
crDeathSounds,
vocalizationTest, vocalizationTest,
resetCrVocCoolDown, resetCrVocCoolDown,
) where ) where
@@ -39,6 +41,23 @@ crWarningSounds cr = case cr ^. crType of
BarrelCrit{} -> mempty BarrelCrit{} -> mempty
LampCrit{} -> mempty LampCrit{} -> mempty
crDeathSounds :: Creature -> DeathType -> [SoundID]
crDeathSounds cr dt = case cr ^. crType of
Avatar{} -> mempty
AvatarDead -> mempty
ChaseCrit{} -> defaultDeathSounds dt
SwarmCrit -> mempty
AutoCrit -> mempty
BarrelCrit{} -> mempty
LampCrit{} -> mempty
defaultDeathSounds :: DeathType -> [SoundID]
defaultDeathSounds = \case
CookDeath -> mempty
PoisonDeath -> mempty
PlainDeath -> mempty
GibsDeath -> mempty
vocalizationTest :: Creature -> Maybe SoundID vocalizationTest :: Creature -> Maybe SoundID
vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of vocalizationTest cr = case cr ^? crVocalization . vcCoolDown of
Just 0 -> crVocalizationSound cr Just 0 -> crVocalizationSound cr
+1
View File
@@ -31,6 +31,7 @@ data CWorld = CWorld
, _incEdges :: [(Int,Int)] , _incEdges :: [(Int,Int)]
, _numberFloorVerxs :: Int , _numberFloorVerxs :: Int
, _chasms :: [[Point2]] , _chasms :: [[Point2]]
, _cliffs :: [(Point2,Point2)]
, _numberChasmVerxs :: Int , _numberChasmVerxs :: Int
, _highlightItems :: IM.IntMap Int , _highlightItems :: IM.IntMap Int
} }
+1 -1
View File
@@ -24,7 +24,7 @@ data CardinalPointBetween
| NorthWest | NorthWest
deriving (Eq, Ord, Show, Bounded, Enum) deriving (Eq, Ord, Show, Bounded, Enum)
data CardinalEightPoint data Cardinal8
= North8 = North8
| NorthEast8 | NorthEast8
| East8 | East8
+4 -3
View File
@@ -52,7 +52,7 @@ data Config = Config
, _gr_upscale_filter :: Bool , _gr_upscale_filter :: Bool
, _gr_cloud_shadows :: Bool , _gr_cloud_shadows :: Bool
, _gr_distortions :: Bool , _gr_distortions :: Bool
, _gr_bloom :: Bool -- , _gr_bloom :: Bool
, _gr_shadow_rendering :: ShadowRendering , _gr_shadow_rendering :: ShadowRendering
, _gr_shadows_on_clouds :: ShadowRendering , _gr_shadows_on_clouds :: ShadowRendering
, _gr_shadow_size :: Importance , _gr_shadow_size :: Importance
@@ -98,7 +98,7 @@ data DebugBool
| Circ_collision_test | Circ_collision_test
| Show_far_wall_detect | Show_far_wall_detect
| Show_walls_near_point_cursor | Show_walls_near_point_cursor
| Show_walls_near_point_you | Show_walls_near_you
| Show_walls_near_segment | Show_walls_near_segment
| Show_zone_near_point_cursor | Show_zone_near_point_cursor
| Show_zone_circ | Show_zone_circ
@@ -106,6 +106,7 @@ data DebugBool
| Show_path_between | Show_path_between
| Show_writable_values | Show_writable_values
| Show_mouse_click_pos | Show_mouse_click_pos
| Muzzle_positions
deriving (Eq, Ord, Bounded, Enum, Show) deriving (Eq, Ord, Bounded, Enum, Show)
data ResFactor = DoubleRes | FullRes | HalfRes | QuarterRes | EighthRes | SixteenthRes data ResFactor = DoubleRes | FullRes | HalfRes | QuarterRes | EighthRes | SixteenthRes
@@ -155,7 +156,7 @@ defaultConfig =
, _volume_music = 0 , _volume_music = 0
, _gr_upscale_filter = True , _gr_upscale_filter = True
, _gr_cloud_shadows = True , _gr_cloud_shadows = True
, _gr_bloom = True -- , _gr_bloom = True
, _gr_shadow_rendering = GeoObjShads , _gr_shadow_rendering = GeoObjShads
, _gr_shadows_on_clouds = NoObjShads , _gr_shadows_on_clouds = NoObjShads
, _gr_shadow_size = Typical , _gr_shadow_size = Typical
+2
View File
@@ -65,6 +65,8 @@ data CrHP
| CrIsGibs | CrIsGibs
| CrIsPitted | CrIsPitted
data DeathType = CookDeath | PoisonDeath | PlainDeath | GibsDeath
data Intention = Intention data Intention = Intention
{ _targetCr :: Maybe Int { _targetCr :: Maybe Int
, _mvToPoint :: Maybe Point2 , _mvToPoint :: Maybe Point2
-1
View File
@@ -21,7 +21,6 @@ data Stance = Stance
data Carriage data Carriage
= Walking {_strideAmount :: Float, _currentFoot :: FootForward} = Walking {_strideAmount :: Float, _currentFoot :: FootForward}
| Standing
| Floating | Floating
| Flying | Flying
| Boosting Point2 | Boosting Point2
+10 -2
View File
@@ -10,7 +10,8 @@ module Dodge.Data.GenWorld (
import ShortShow import ShortShow
import Control.Lens import Control.Lens
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
import qualified Data.Set as S import qualified Data.Set as S
import Data.Tile import Data.Tile
import Dodge.Data.Room import Dodge.Data.Room
@@ -57,11 +58,18 @@ data PSType
| PutWorldUpdate (Int -> PlacementSpot -> GenWorld -> GenWorld) -- the Int is the roomid | PutWorldUpdate (Int -> PlacementSpot -> GenWorld -> GenWorld) -- the Int is the roomid
| PutNothing | PutNothing
| PutID {_putID :: Int} | PutID {_putID :: Int}
| PutChasm {_putChasmPoly :: [Point2]} | PutChasm {_putChasmChasms :: [[Point2]], _putChasmCliffs :: [[Point2]]}
-- the chasms should be a convex partition of the cliffs.
-- Chasm and cliff polygons are orientated anticlockwise, so platforms
-- within a chasm will appear as a clockwise oriented list of points
-- in _putChasmCliffs.
| PutLabel {_putLabel :: String} -- currently not actually put anywhere | PutLabel {_putLabel :: String} -- currently not actually put anywhere
-- just used for later inspection as top level -- just used for later inspection as top level
-- of a continuing placement in a room placement list -- of a continuing placement in a room placement list
putConvexChasm :: [Point2] -> PSType
putConvexChasm ps = PutChasm [ps] [ps]
instance ShortShow PSType where instance ShortShow PSType where
shortShow PutCrit {} = "PutCrit" shortShow PutCrit {} = "PutCrit"
shortShow PutMachine {} = "PutMachine" shortShow PutMachine {} = "PutMachine"
+1 -1
View File
@@ -31,7 +31,7 @@ data ItemLocation
, _ilInvID :: NewInt InvInt , _ilInvID :: NewInt InvInt
, _ilIsRoot :: Bool -- of any item , _ilIsRoot :: Bool -- of any item
, _ilIsSelected :: Bool , _ilIsSelected :: Bool
, _ilIsAttached :: Bool -- to selected item , _ilIsAttached :: Bool -- to selected item. question: downwards and upwards?
, _ilEquipSite :: Maybe EquipSite , _ilEquipSite :: Maybe EquipSite
} }
| OnTurret {_ilTuID :: Int} | OnTurret {_ilTuID :: Int}
+2
View File
@@ -47,6 +47,7 @@ data MachineType
| McTurret {_mctTurret :: Turret} | McTurret {_mctTurret :: Turret}
| McStorage {_mcsType :: AmmoType, _mcsAmount :: Int} | McStorage {_mcsType :: AmmoType, _mcsAmount :: Int}
| McDistributer {_mcdStorageMachine :: Maybe Int} | McDistributer {_mcdStorageMachine :: Maybe Int}
| McTrigger {_mcTriggerID :: Int}
-- | McSynthesiser -- | McSynthesiser
instance ShortShow MachineType where instance ShortShow MachineType where
@@ -58,6 +59,7 @@ instance ShortShow MachineType where
McTurret {} -> "McTur" McTurret {} -> "McTur"
McStorage {} -> "McStor" McStorage {} -> "McStor"
McDistributer {} -> "McDist" McDistributer {} -> "McDist"
McTrigger i -> "McTrigger " <> show i
data Turret = Turret data Turret = Turret
{ _tuWeapon :: Int { _tuWeapon :: Int
-1
View File
@@ -19,7 +19,6 @@ data SensorType
data DamageSensor = DamSensor data DamageSensor = DamSensor
{ _sensAmount :: Int { _sensAmount :: Int
, _sensType :: SensorType , _sensType :: SensorType
, _sensThreshold :: Int
} }
data ProximitySensor = ProxSensor data ProximitySensor = ProxSensor
+2 -1
View File
@@ -6,7 +6,8 @@ module Dodge.Data.MetaTree where
import Control.Lens import Control.Lens
import Data.Tree import Data.Tree
import System.Random import System.Random
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
data MetaTree a b = MTree data MetaTree a b = MTree
{_mtLabel :: b, _mtTree :: MetaNode a b, _mtBranches :: [MetaBranch a b]} {_mtLabel :: b, _mtTree :: MetaNode a b, _mtBranches :: [MetaBranch a b]}
+10 -4
View File
@@ -10,15 +10,16 @@ import Dodge.Data.CardinalPoint
import Dodge.Data.ScreenPos import Dodge.Data.ScreenPos
import Picture.Data import Picture.Data
data ListDisplayParams = ListDisplayParams data LDParams = LDP -- List display parameters
{ _ldpPos :: ScreenPos { _ldpPos :: ScreenPos
, _ldpScale :: Float , _ldpScale :: Float
, _ldpVerticalGap :: Float , _ldpVerticalGap :: Float
, _ldpBorder :: Maybe (Int,Int) -- the Ints give height and width for a border
} }
data CursorDisplay data CursorDisplay
= BoundaryCursor [CardinalPoint] = BoundCurs [CardinalPoint]
| BackdropCursor | BackdropCurs
data SectionCursor = SectionCursor data SectionCursor = SectionCursor
{ _scurPos :: Int { _scurPos :: Int
@@ -36,6 +37,8 @@ data SelSection a = SelSection
type IMSS a = IntMap (SelSection a) type IMSS a = IntMap (SelSection a)
type IMSI a = IntMap (SelectionItem a)
data SelectionWidth = FixedSelectionWidth Int | UseItemWidth data SelectionWidth = FixedSelectionWidth Int | UseItemWidth
data SelectionItem a = SelItem data SelectionItem a = SelItem
@@ -52,8 +55,11 @@ data SelectionItem a = SelItem
data SIDisplayMod data SIDisplayMod
= NoSIDisplayMod = NoSIDisplayMod
| HighlightSI | HighlightSI
| DropShadowSI
| InventoryHeadSI
| InventoryHeadFilterSI
makeLenses ''ListDisplayParams makeLenses ''LDParams
makeLenses ''SelectionItem makeLenses ''SelectionItem
makeLenses ''SelSection makeLenses ''SelSection
makeLenses ''SectionCursor makeLenses ''SectionCursor
+2 -1
View File
@@ -18,7 +18,8 @@ data SoundOrigin
| CrWeaponSound Int Int | CrWeaponSound Int Int
| ItemSound Int Int | ItemSound Int Int
| CrWeaponFailSound Int | CrWeaponFailSound Int
| MachineSound Int | MachinePrimarySound Int
| MachineBackgroundSound Int
| MachineAltSound Int | MachineAltSound Int
| TerminalSound | TerminalSound
| WallSound Int | WallSound Int
+1
View File
@@ -28,6 +28,7 @@ data Terminal = Terminal
, _tmStatus :: TerminalStatus , _tmStatus :: TerminalStatus
, _tmCommandHistory :: [String] , _tmCommandHistory :: [String]
, _tmToggles :: M.Map String TerminalToggle , _tmToggles :: M.Map String TerminalToggle
, _tmRebootOnAccess :: Bool
} }
data TerminalLineString = TerminalLineConst String Color data TerminalLineString = TerminalLineConst String Color
+25 -2
View File
@@ -2,6 +2,13 @@
module Dodge.Debug (debugEvents, drawDebug) where module Dodge.Debug (debugEvents, drawDebug) where
import Geometry.Data
import Dodge.Render.Label
import Dodge.Data.DoubleTree
import Dodge.HeldUse
import Dodge.DoubleTree
import Dodge.Item.Grammar
import NewInt
import AesonHelp import AesonHelp
import Control.Lens import Control.Lens
import Control.Monad import Control.Monad
@@ -55,7 +62,7 @@ debugItem = \case
Show_wall_search_rays -> mempty Show_wall_search_rays -> mempty
Show_dda_test -> mempty Show_dda_test -> mempty
Show_far_wall_detect -> mempty Show_far_wall_detect -> mempty
Show_walls_near_point_you -> mempty Show_walls_near_you -> mempty
Show_zone_near_point_cursor -> mempty Show_zone_near_point_cursor -> mempty
Show_zone_circ -> mempty Show_zone_circ -> mempty
Inspect_wall -> mempty Inspect_wall -> mempty
@@ -70,6 +77,7 @@ debugItem = \case
Show_mouse_click_pos -> debugMouseClickPos Show_mouse_click_pos -> debugMouseClickPos
Debug_get -> doDebugGet Debug_get -> doDebugGet
Debug_put -> debugPutItems Debug_put -> debugPutItems
Muzzle_positions -> mempty
debugGet :: Universe -> [String] debugGet :: Universe -> [String]
debugGet u = foldMap getPretty $ u ^. uvWorld . cWorld . lWorld . shockwaves debugGet u = foldMap getPretty $ u ^. uvWorld . cWorld . lWorld . shockwaves
@@ -224,7 +232,7 @@ drawDebug u = \case
Show_wall_search_rays -> drawWallSearchRays $ _uvWorld u Show_wall_search_rays -> drawWallSearchRays $ _uvWorld u
Show_dda_test -> drawDDATest $ _uvWorld u Show_dda_test -> drawDDATest $ _uvWorld u
Show_far_wall_detect -> drawFarWallDetect $ _uvWorld u Show_far_wall_detect -> drawFarWallDetect $ _uvWorld u
Show_walls_near_point_you -> drawWallsNearYou $ _uvWorld u Show_walls_near_you -> drawWallsNearYou $ _uvWorld u
Show_zone_near_point_cursor -> drawZoneNearPointCursor $ _uvWorld u Show_zone_near_point_cursor -> drawZoneNearPointCursor $ _uvWorld u
Show_zone_circ -> drawZoneCirc $ _uvWorld u Show_zone_circ -> drawZoneCirc $ _uvWorld u
Inspect_wall -> drawInspectWalls $ _uvWorld u Inspect_wall -> drawInspectWalls $ _uvWorld u
@@ -239,3 +247,18 @@ drawDebug u = \case
Show_path_between -> drawPathBetween u Show_path_between -> drawPathBetween u
Show_writable_values -> mempty Show_writable_values -> mempty
Show_mouse_click_pos -> mempty Show_mouse_click_pos -> mempty
Muzzle_positions -> showMuzzlePositions u
showMuzzlePositions :: Universe -> Picture
showMuzzlePositions u = fold $ do
cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
invid <- cr ^? crManipulation . manObject . imRootSelectedItem . unNInt
loc <- invIndents ((\k -> u ^?! uvWorld . cWorld . lWorld . items . ix k) <$> _crInv cr)
^? ix invid . _2
return . color red $ setLayer DebugLayer $ reduceLocDT (f cr) loc
where
f cr loc = foldMap (g . muzzlePos loc cr) (itemMuzzles $ loc ^. locDT . dtValue . _1)
where
g :: Point3Q -> Picture
g pq = translate3 (pq ^. _1) $ crossPic 5
+5 -4
View File
@@ -72,7 +72,7 @@ lineOnScreenCone cfig w p1 p2 =
drawWallFace :: Config -> World -> Wall -> Picture drawWallFace :: Config -> World -> Wall -> Picture
drawWallFace cfig w wall drawWallFace cfig w wall
| isRHS sightFrom x y || not (wlIsOpaque wall) = blank | isRHS sightFrom x y || not (wlIsOpaque wall) = mempty
| otherwise = setDepth (-1) . color (withAlpha 0 black) . polygon $ points | otherwise = setDepth (-1) . color (withAlpha 0 black) . polygon $ points
where where
(x, y) = _wlLine wall (x, y) = _wlLine wall
@@ -214,8 +214,8 @@ drawPathBetween u = concat $ do
color rose (foldMap (arrowPath . map nodepos) nodelist) color rose (foldMap (arrowPath . map nodepos) nodelist)
<> drawCrossCol green sp <> drawCrossCol green sp
<> drawCrossCol cyan ep <> drawCrossCol cyan ep
<> foldMap (color green . arrow sp) (nodepos <$> walkableNodeNear w sp) <> foldMap ((color green . arrow sp) . nodepos) (walkableNodeNear w sp)
<> foldMap (color cyan . flip arrow ep) (nodepos <$> walkableNodeNear w ep) <> foldMap ((color cyan . flip arrow ep) . nodepos) (walkableNodeNear w ep)
<> foldMap (color orange . arrow sp) (pointTowardsImpulse sp ep w) <> foldMap (color orange . arrow sp) (pointTowardsImpulse sp ep w)
where where
w = u ^. uvWorld w = u ^. uvWorld
@@ -223,9 +223,10 @@ drawPathBetween u = concat $ do
drawWallsNearYou :: World -> Picture drawWallsNearYou :: World -> Picture
drawWallsNearYou w = concat $ do drawWallsNearYou w = concat $ do
p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy p <- w ^? cWorld . lWorld . creatures . ix 0 . crPos . _xy
return $ setLayer DebugLayer $ foldMap f $ wlsNearPoint p w return $ setLayer DebugLayer $ foldMap f $ wlsNearCirc p 30 w
where where
f wl = color violet $ thickLine 3 [a, b] f wl = color violet $ thickLine 3 [a, b]
<> uncurryV translate (0.5 *^ (a + b)) (scale 0.05 0.05 . text $ show (_wlID wl))
where where
(a, b) = _wlLine wl (a, b) = _wlLine wl
+2 -2
View File
@@ -21,8 +21,8 @@ import Dodge.Default.Wall
import Geometry import Geometry
import Picture import Picture
defaultEquipment :: Item defEquipment :: Item
defaultEquipment = defaultHeldItem & itUse .~ UseNothing defEquipment = defHeldItem & itUse .~ UseNothing
defaultFlIt :: FloorItem defaultFlIt :: FloorItem
defaultFlIt = FlIt{_flItRot = 0, _flItPos = V2 0 0} defaultFlIt = FlIt{_flItRot = 0, _flItPos = V2 0 0}
+6 -6
View File
@@ -1,13 +1,13 @@
module Dodge.Default.Item ( module Dodge.Default.Item (
defaultHeldItem, defHeldItem,
defaultCraftItem, defCraftItem,
) where ) where
import Control.Lens import Control.Lens
import Dodge.Data.Item import Dodge.Data.Item
defaultHeldItem :: Item defHeldItem :: Item
defaultHeldItem = defHeldItem =
Item Item
{ _itType = HELD PISTOL { _itType = HELD PISTOL
, _itConsumables = Nothing , _itConsumables = Nothing
@@ -22,5 +22,5 @@ defaultHeldItem =
, _itTimeLastUsed = 0 , _itTimeLastUsed = 0
} }
defaultCraftItem :: Item defCraftItem :: Item
defaultCraftItem = defaultHeldItem & itUse .~ UseNothing defCraftItem = defHeldItem & itUse .~ UseNothing
+1
View File
@@ -19,6 +19,7 @@ defaultTerminal =
, _tmStatus = TerminalOff , _tmStatus = TerminalOff
, _tmCommandHistory = [] , _tmCommandHistory = []
, _tmToggles = mempty , _tmToggles = mempty
, _tmRebootOnAccess = False
-- , _tmExternalColor = dark magenta -- , _tmExternalColor = dark magenta
} }
+1
View File
@@ -94,6 +94,7 @@ defaultCWorld =
, _cwTiles = mempty , _cwTiles = mempty
, _numberFloorVerxs = 0 , _numberFloorVerxs = 0
, _chasms = mempty , _chasms = mempty
, _cliffs = mempty
, _numberChasmVerxs = 0 , _numberChasmVerxs = 0
, _incGraph = mempty , _incGraph = mempty
, _incNode = mempty , _incNode = mempty
+18 -17
View File
@@ -65,7 +65,7 @@ updateCombineSections w cfig =
sclose' sclose'
| null sclose = | null sclose =
IM.singleton 0 $ IM.singleton 0 $
SelItem ["NONE"] 1 25 False white 2 Nothing NoSIDisplayMod SelItem ["NONE"] 1 25 False white 2 Nothing DropShadowSI
| otherwise = sclose | otherwise = sclose
regexCombs :: IM.IntMap Item -> SelectionItem CombItem -> String -> Bool regexCombs :: IM.IntMap Item -> SelectionItem CombItem -> String -> Bool
@@ -124,8 +124,8 @@ updateDisplaySections w cfig =
[ sfinv [ sfinv
, sinv , sinv
, IM.singleton 0 $ , IM.singleton 0 $
SelItem [displayFreeSlots (crNumFreeSlots (w ^. cWorld . lWorld . items) cr)] 1 15 True invDimColor 2 Nothing NoSIDisplayMod SelItem [displayFreeSlots (crNumFreeSlots (w ^. cWorld . lWorld . items) cr)] 1 15 True invDimColor 2 Nothing DropShadowSI
, sfclose , sfclose1
, sclose , sclose
, interfaceshead , interfaceshead
, btitems , btitems
@@ -137,6 +137,9 @@ updateDisplaySections w cfig =
filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $ filterSectionsPair invfiltcurs plainRegex invitems "INVENTORY" $
w ^? hud . diInvFilter . _Just w ^? hud . diInvFilter . _Just
closefiltcurs = mselpos ^? _Just . slSec == Just 2 closefiltcurs = mselpos ^? _Just . slSec == Just 2
sfclose1
| null sclose && sfclose ^? ix 0 . siIsSelectable == Just False = mempty
| otherwise = sfclose
(sfclose, sclose) = (sfclose, sclose) =
filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $ filterSectionsPair closefiltcurs plainRegex closeitms "NEARBY ITEMS" $
w ^? hud . diCloseFilter . _Just w ^? hud . diCloseFilter . _Just
@@ -144,7 +147,7 @@ updateDisplaySections w cfig =
btitems = btitems =
IM.fromDistinctAscList . zip [0 ..] $ IM.fromDistinctAscList . zip [0 ..] $
mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons) mapMaybe (closeButtonToSelectionItem w) (w ^. hud . closeButtons)
makehead str = IM.singleton 0 $ SelItem [str] 1 15 False white 0 Nothing NoSIDisplayMod makehead str = IM.singleton 0 $ SelItem [str] 1 15 False white 0 Nothing InventoryHeadSI
cr = you w cr = you w
closeitms = closeitms =
IM.fromDistinctAscList . zip [0 ..] $ IM.fromDistinctAscList . zip [0 ..] $
@@ -165,7 +168,7 @@ filterSectionsPair infocus filtfn itms s mfilt = (x, itms')
where where
filtcurs = if infocus then cFilledRect else cWireRect filtcurs = if infocus then cFilledRect else cWireRect
x = IM.singleton 0 $ x = IM.singleton 0 $
fromMaybe (SelItem [s] 1 (length s) False white 0 Nothing NoSIDisplayMod) $ do fromMaybe (SelItem [s] 1 (length s) False white 0 Nothing InventoryHeadSI) $ do
str <- mfilt str <- mfilt
return $ return $
SelItem SelItem
@@ -176,7 +179,7 @@ filterSectionsPair infocus filtfn itms s mfilt = (x, itms')
white white
0 0
Nothing Nothing
NoSIDisplayMod InventoryHeadFilterSI
f y = y f y = y
-- | null y = -- | null y =
-- IM.singleton 0 $ SelItem ["(NONE)"] 1 (length s) True (greyN 0.5) 0 Nothing -- IM.singleton 0 $ SelItem ["(NONE)"] 1 (length s) True (greyN 0.5) 0 Nothing
@@ -256,13 +259,7 @@ updateSectionsPositioning h mselpos allavailablelines lsss sss =
lk = mselpos ^.. _Just . slSec lk = mselpos ^.. _Just . slSec
ssizes = sectionsSizes allavailablelines lk $ sectionsDesiredLines ls ssizes = sectionsSizes allavailablelines lk $ sectionsDesiredLines ls
updateSection :: updateSection :: Int -> Maybe Int -> IMSI a -> Int -> Int -> SelSection a
Int ->
Maybe Int ->
IM.IntMap (SelectionItem a) ->
Int ->
Int ->
SelSection a
updateSection indent mcsel sis availablelines oldoffset = updateSection indent mcsel sis availablelines oldoffset =
SelSection SelSection
{ _ssItems = sis { _ssItems = sis
@@ -302,10 +299,14 @@ updateSection indent mcsel sis availablelines oldoffset =
listSelectionColorPicture :: SelectionItem a -> ([Picture], Sum Int) listSelectionColorPicture :: SelectionItem a -> ([Picture], Sum Int)
listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si) listSelectionColorPicture si = (g <$> _siPictures si, Sum $ _siHeight si)
where where
textf = case si ^. siDisplayMod of g = translate lindent 0 . case si ^. siDisplayMod of
NoSIDisplayMod -> text NoSIDisplayMod -> docolor . text
HighlightSI -> hackBoldText HighlightSI -> docolor . hackBoldText
g = translate lindent 0 . color (_siColor si) . textf DropShadowSI -> hackDropShadow (si ^. siColor) black
InventoryHeadSI -> hackInvertText black white . dopad
InventoryHeadFilterSI -> docolor . text
dopad s = " "<>s<>" "
docolor = color (si ^. siColor)
lindent = 100 * fromIntegral (_siOffX si) lindent = 100 * fromIntegral (_siOffX si)
regexList :: String -> [String] -> Bool regexList :: String -> [String] -> Bool
-5
View File
@@ -44,7 +44,6 @@ drawFlamelet size pt =
time = _ebTimer pt time = _ebTimer pt
piu = piu =
translate3 sp translate3 sp
-- setDepth (z + 5)
-- . uncurryV translate sp -- . uncurryV translate sp
. color . color
( mixColors ( mixColors
@@ -61,8 +60,6 @@ drawFlamelet size pt =
$ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2) $ reverse (rectNSWE siz2 (- siz2) (- siz2) siz2)
pi2 = pi2 =
translate3 sp translate3 sp
--setDepth (z + 5)
-- . uncurryV translate sp
. color . color
( mixColors ( mixColors
(fromIntegral (max 0 (time -2))) (fromIntegral (max 0 (time -2)))
@@ -79,8 +76,6 @@ drawFlamelet size pt =
$ rectNSWE siz2 (- siz2) (- siz2) siz2 $ rectNSWE siz2 (- siz2) (- siz2) siz2
pic = pic =
translate3 sp translate3 sp
--setDepth (z + 2)
-- . uncurryV translate sp
. color . color
( mixColors ( mixColors
(fromIntegral (max 0 (time -2))) (fromIntegral (max 0 (time -2)))
-64
View File
@@ -1,64 +0,0 @@
module Dodge.Equipment (
effectOnRemove,
effectOnEquip,
) where
import Linear
import Control.Lens
import Data.Maybe
import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.Item.Location
import Dodge.Wall.Delete
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Geometry
import qualified IntMapHelp as IM
import NewInt
effectOnRemove :: Item -> Creature -> World -> World
effectOnRemove itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onRemoveWristShield itm
_ -> const id
onRemoveWristShield :: Item -> Creature -> World -> World
onRemoveWristShield itm _ =
(pointerToItem itm . itParams .~ NoParams) . mremovewall
where
mremovewall = fromMaybe id $ do
i <- itm ^? itParams . itParamID
return $ deleteWallID i
effectOnEquip :: Item -> Creature -> World -> World
effectOnEquip itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onEquipWristShield itm
_ -> const id
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w =
w
& pointerToItem itm . itParams .~ ItemParamID{_itParamID = i}
& cWorld . lWorld . walls . at i ?~ forceField{_wlID = i}
& setWristShieldPos
( itm & itParams .~ ItemParamID{_itParamID = i}
)
cr
where
i = IM.newKey (w ^. cWorld . lWorld . walls)
setWristShieldPos :: Item -> Creature -> World -> World
setWristShieldPos itm cr w = w & moveWallIDUnsafe i wlline
where
i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
handtrans = case w ^? cWorld . lWorld . items
. ix (itm ^. itID . unNInt)
. itLocation
. ilEquipSite
. _Just of
Just x -> translateToES cr x -- . g
_ -> undefined
-- g
-- | twists cr = (+.+.+ V3 (-5) 10 0)
-- | otherwise = id
f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans
+90 -24
View File
@@ -1,22 +1,25 @@
module Dodge.Euse (equipBackgroundEffect) where module Dodge.Euse (
equipBackgroundEffect,
effectOnRemove,
effectOnEquip,
) where
import Dodge.Creature.HandPos import Dodge.Creature.HandPos
import Dodge.Creature.Test
import Dodge.Data.ComposedItem import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree import Dodge.Data.DoubleTree
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
import Dodge.Data.World import Dodge.Data.World
import Dodge.Item.Location
import Dodge.Wall.Delete
import Dodge.Wall.ForceField
import Dodge.Wall.Move import Dodge.Wall.Move
import Geometry import Geometry
import qualified IntMapHelp as IM
import LensHelp import LensHelp
import Linear import Linear
import NewInt
equipBackgroundEffect :: equipBackgroundEffect :: LocationDT OItem -> Creature -> EquipSite -> World -> World
LocationDT OItem ->
Creature ->
EquipSite ->
World ->
World
equipBackgroundEffect loc cr = case eo of equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr EQUIP (MAGSHIELD mt) -> const $ useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr EQUIP WRISTARMOUR -> setWristShieldPos itm cr
@@ -29,28 +32,31 @@ equipBackgroundEffect loc cr = case eo of
-- this should probably drain energy -- this should probably drain energy
useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World useMagShield :: MagnetBuBu -> Item -> Creature -> World -> World
useMagShield mt _ cr w = useMagShield mt _ cr w =
w & cWorld . lWorld . magnets w
& cWorld
. lWorld
. magnets
.:~ Magnet .:~ Magnet
{ _mgPos = cr ^. crPos . _xy { _mgPos = cr ^. crPos . _xy
, _mgField = mt , _mgField = mt
} }
setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World --setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World
setWristShieldPos itm cr x = moveWallIDUnsafe i wlline --setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
where -- where
i = _itParamID $ _itParams itm -- i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) 7 0), f (V3 10 7 0)) -- wlline = (f (V3 (-10) 7 0), f (V3 10 7 0))
handtrans = case x of -- handtrans = case x of
OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g -- OnLeftWrist -> \cr' -> translatePointToLeftHand cr' . g
_ -> translatePointToRightHand -- _ -> translatePointToRightHand
g -- g
| twists cr = (+.+.+ V3 (-5) 10 0) -- | twists cr = (+.+.+ V3 (-5) 10 0)
| otherwise = id -- | otherwise = id
f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans cr -- f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans cr
-- TODO the reflection should be controled by the particle -- TODO the reflection should be controled by the particle
--shieldWallDamage :: Damage -> Wall -> Int -> World -> World -- shieldWallDamage :: Damage -> Wall -> Int -> World -> World
--shieldWallDamage dm _ crid w = case _dmType dm of -- shieldWallDamage dm _ crid w = case _dmType dm of
---- Lasering -> w ---- Lasering -> w
-- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm -- _ | isMovementDam dm -> w & creatures . ix crid . crState . crDamage .:~ dm
-- _ -> w -- _ -> w
@@ -58,7 +64,9 @@ setWristShieldPos itm cr x = moveWallIDUnsafe i wlline
createHeadLamp :: Item -> Creature -> World -> World createHeadLamp :: Item -> Creature -> World -> World
createHeadLamp _ cr w = createHeadLamp _ cr w =
w w
& cWorld . lWorld . lights & cWorld
. lWorld
. lights
.:~ LSParam .:~ LSParam
( _crPos cr ( _crPos cr
+.+.+ rotate3 +.+.+ rotate3
@@ -67,3 +75,61 @@ createHeadLamp _ cr w =
) )
200 200
0.7 0.7
effectOnRemove :: Item -> Creature -> World -> World
effectOnRemove itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onRemoveWristShield itm
_ -> const id
onRemoveWristShield :: Item -> Creature -> World -> World
onRemoveWristShield itm _ =
(pointerToItem itm . itParams .~ NoParams)
. maybe id deleteWallID (itm ^? itParams . itParamID)
effectOnEquip :: Item -> Creature -> World -> World
effectOnEquip itm = case itm ^. itType of
EQUIP WRISTARMOUR -> onEquipWristShield itm
_ -> const id
onEquipWristShield :: Item -> Creature -> World -> World
onEquipWristShield itm cr w =
w
& pointerToItem itm
. itParams
.~ ItemParamID i
& cWorld
. lWorld
. walls
. at i
?~ forceField{_wlID = i}
& setWristShieldPos
( itm & itParams .~ ItemParamID{_itParamID = i}
)
cr esite
where
i = IM.newKey (w ^. cWorld . lWorld . walls)
esite = w ^?! cWorld . lWorld . items . ix (itm ^. itID . unNInt) . itLocation . ilEquipSite . _Just
setWristShieldPos :: Item -> Creature -> EquipSite -> World -> World
setWristShieldPos itm cr esite w = w & moveWallIDUnsafe i wlline
where
i = _itParamID $ _itParams itm
wlline = (f (V3 (-10) y 0), f (V3 10 y 0))
y = case esite of
OnLeftWrist -> 7
OnRightWrist -> -7
_ -> error "setWristShieldPos esite is not a wrist"
handtrans = case w
^? cWorld
. lWorld
. items
. ix (itm ^. itID . unNInt)
. itLocation
. ilEquipSite
. _Just of
Just x -> translateToES cr x -- . g
_ -> undefined
-- g
-- | twists cr = (+.+.+ V3 (-5) 10 0)
-- | otherwise = id
f = (+.+ cr ^. crPos . _xy) . stripZ . rotate3 (_crDir cr) . handtrans
+1 -1
View File
@@ -55,7 +55,7 @@ initialRoomTree =
, intAnno $ warningRooms "INVISIBLE CREATURE AHEAD" , intAnno $ warningRooms "INVISIBLE CREATURE AHEAD"
, rToOnward "chaseCrit+armourChaseCrit rectRoom" . , rToOnward "chaseCrit+armourChaseCrit rectRoom" .
return . cleatOnward =<< return . cleatOnward =<<
(roomRectAutoLinks 400 400 <&> rmPmnts (roomRectAutoLights 400 400 <&> rmPmnts
.++~ [ psPtPl anyUnusedSpot (PutCrit invisibleChaseCrit) .++~ [ psPtPl anyUnusedSpot (PutCrit invisibleChaseCrit)
, psPtPl anyUnusedSpot (PutCrit armourChaseCrit) , psPtPl anyUnusedSpot (PutCrit armourChaseCrit)
]) ])
+12 -17
View File
@@ -6,6 +6,8 @@ module Dodge.HeldUse (
gadgetEffect, gadgetEffect,
mcUseHeld, mcUseHeld,
heldEffectMuzzles, heldEffectMuzzles,
muzzlePos,
itemMuzzles,
) where ) where
import Color import Color
@@ -206,14 +208,14 @@ heldItemMuzzles itm = \case
BURSTRIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0 & ix 0 . mzInaccuracy .~ 0.05 BURSTRIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0 & ix 0 . mzInaccuracy .~ 0.05
MINIGUNX i -> MINIGUNX i ->
[ Muzzle [ Muzzle
(V2 (30 + 40 * fromIntegral j / fromIntegral i) 0) (V2 (40 * fromIntegral j / fromIntegral i) 0)
0 0
0.05 0.05
maguse1 maguse1
NoFlare NoFlare
MuzzleShootBullet MuzzleShootBullet
10 10
| j <- [0 .. i -1] | j <- [1 .. i]
] ]
& ix 0 . mzFlareType .~ MiniGunFlare & ix 0 . mzFlareType .~ MiniGunFlare
BANGROD -> BANGROD ->
@@ -301,6 +303,7 @@ heldItemMuzzles itm = \case
dbwMuzzles dbwMuzzles
& ix 0 . mzEffect .~ MuzzleScroller & ix 0 . mzEffect .~ MuzzleScroller
& ix 0 . mzAmmoSlot . aps .~ UseExactly 100000 & ix 0 . mzAmmoSlot . aps .~ UseExactly 100000
FLATSHIELD -> mempty
_ -> _ ->
[ Muzzle [ Muzzle
{ _mzPos = V2 20 0 { _mzPos = V2 20 0
@@ -717,13 +720,8 @@ basicMuzFlare pos dir =
isAmmoIntLink :: Int -> ItemSF -> Bool isAmmoIntLink :: Int -> ItemSF -> Bool
isAmmoIntLink i sf = Just i == sf ^? amsfLink isAmmoIntLink i sf = Just i == sf ^? amsfLink
useLoadedAmmo :: useLoadedAmmo
LocationDT OItem -> :: LocationDT OItem -> Creature -> Muzzle -> Maybe (Int, DTree OItem) -> World -> World
Creature ->
Muzzle ->
Maybe (Int, DTree OItem) ->
World ->
World
useLoadedAmmo loc cr mz m w = useLoadedAmmo loc cr mz m w =
makeMuzzleFlare pq loc (mz ^. mzFlareType) $ case _mzEffect mz of makeMuzzleFlare pq loc (mz ^. mzFlareType) $ case _mzEffect mz of
MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w MuzzleShootBullet -> shootBullets loc cr (mz, x, magtree) w
@@ -905,7 +903,8 @@ shootPulseBall (p, q) w =
i = IM.newKey $ w ^. cWorld . lWorld . pulseBalls i = IM.newKey $ w ^. cWorld . lWorld . pulseBalls
removeAmmoFromMag :: Int -> Int -> World -> World removeAmmoFromMag :: Int -> Int -> World -> World
removeAmmoFromMag x magid = cWorld . lWorld . items . ix magid . itConsumables . _Just -~ x removeAmmoFromMag x magid
= cWorld . lWorld . items . ix magid . itConsumables . _Just -~ x
getBulletType :: DTree OItem -> Maybe Bullet getBulletType :: DTree OItem -> Maybe Bullet
getBulletType magtree = getBulletType magtree =
@@ -960,12 +959,8 @@ magAmmoParams itm = case itm ^. itType of
-- Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w -- Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
-- _ -> 0 -- _ -> 0
shootBullets :: shootBullets
LocationDT OItem -> :: LocationDT OItem -> Creature -> (Muzzle, Int, DTree OItem) -> World -> World
Creature ->
(Muzzle, Int, DTree OItem) ->
World ->
World
shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do shootBullets loc cr (mz, x, magtree) w = fromMaybe w $ do
thebullet <- getBulletType magtree thebullet <- getBulletType magtree
return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz)) return $ foldl' (&) w (replicate x (shootBullet thebullet loc cr mz))
@@ -1161,7 +1156,7 @@ doGenFloat (UniRandFloat x y) g = randomR (x, y) g
mcShootLaser :: Item -> Machine -> World -> World mcShootLaser :: Item -> Machine -> World -> World
mcShootLaser _ mc = mcShootLaser _ mc =
shootLaser (MachineSound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow shootLaser (MachinePrimarySound (_mcID mc)) (DamageLaser 11) 1 pos dir yellow
where where
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
dir = mc ^?! mcType . _McTurret . tuDir dir = mc ^?! mcType . _McTurret . tuDir
+1 -1
View File
@@ -16,13 +16,13 @@ module Dodge.Inventory (
destroyAllInvItems, destroyAllInvItems,
) where ) where
import Dodge.Euse
import Linear import Linear
import Data.Function import Data.Function
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
import Dodge.Data.SelectionList import Dodge.Data.SelectionList
import Dodge.Data.World import Dodge.Data.World
import Dodge.Equipment
import Dodge.Inventory.Location import Dodge.Inventory.Location
import Dodge.Inventory.RBList import Dodge.Inventory.RBList
import Dodge.Inventory.Swap import Dodge.Inventory.Swap
+7 -13
View File
@@ -34,7 +34,7 @@ invSelectionItem w indent loc =
SelItem SelItem
{ _siPictures = itemDisplay w cr ci { _siPictures = itemDisplay w cr ci
, _siHeight = itInvHeight $ ci ^. _1 , _siHeight = itInvHeight $ ci ^. _1
, _siWidth = 15 , _siWidth = maximum (15 : (length <$> itemDisplay w cr ci))
, _siIsSelectable = True , _siIsSelectable = True
, _siColor = itemInvColor ci , _siColor = itemInvColor ci
, _siOffX = indent , _siOffX = indent
@@ -42,7 +42,7 @@ invSelectionItem w indent loc =
, _siDisplayMod = dmod , _siDisplayMod = dmod
} }
where where
dmod = maybe NoSIDisplayMod (const HighlightSI) dmod = maybe DropShadowSI (const HighlightSI)
$ w ^? cWorld . highlightItems . ix (a ^. itID . unNInt) $ w ^? cWorld . highlightItems . ix (a ^. itID . unNInt)
ci = (a,b) ci = (a,b)
(a,b,_) = loc ^. locDT . dtValue (a,b,_) = loc ^. locDT . dtValue
@@ -51,19 +51,13 @@ invSelectionItem w indent loc =
-- note the convoluted display of the hotkey/equipment, this was done to avoid a -- note the convoluted display of the hotkey/equipment, this was done to avoid a
-- space leak -- space leak
itemDisplay :: World -> Creature -> CItem -> [String] itemDisplay :: World -> Creature -> CItem -> [String]
itemDisplay w cr ci = -- f itemDisplay w cr ci = basicItemDisplay itm `g` anyextra
basicItemDisplay itm
-- (itemNumberDisplay w cr ci)
`g` anyextra
where where
itm = ci ^. _1 itm = ci ^. _1
NInt itid = itm ^. itID NInt itid = itm ^. itID
--f (x:xs) (y:_) = itemDisplayPad x y : xs g (x:xs) (Just y) = (x <> y) : xs
--f xs _ = xs
--g (x:xs) (y:_) = (rightPad 15 ' ' x ++ y) : xs
g (x:xs) (y:_) = (x ++ y) : xs
g xs _ = xs g xs _ = xs
anyextra = maybeToList (anyscroll <> anyexternal <> anyhotkey <> anyequippos) anyextra = anyscroll <> anyexternal <> anyhotkey <> anyequippos
anyhotkey = fmap hotkeyToString anyhotkey = fmap hotkeyToString
(w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid) (w ^? cWorld . lWorld . imHotkeys . unNIntMap . ix itid)
anyequippos = do anyequippos = do
@@ -221,7 +215,7 @@ closeItemToSelectionItem w i = do
, _siColor = col , _siColor = col
, _siOffX = 0 , _siOffX = 0
, _siPayload = Nothing , _siPayload = Nothing
, _siDisplayMod = NoSIDisplayMod , _siDisplayMod = DropShadowSI
} }
closeButtonToSelectionItem :: World -> Int -> Maybe (SelectionItem ()) closeButtonToSelectionItem :: World -> Int -> Maybe (SelectionItem ())
@@ -236,7 +230,7 @@ closeButtonToSelectionItem w i = do
, _siColor = yellow , _siColor = yellow
, _siOffX = 0 , _siOffX = 0
, _siPayload = Nothing , _siPayload = Nothing
, _siDisplayMod = NoSIDisplayMod , _siDisplayMod = DropShadowSI
} }
btText :: Button -> String btText :: Button -> String
+22 -21
View File
@@ -16,68 +16,69 @@ module Dodge.Item.Ammo (
import Control.Lens import Control.Lens
import Dodge.Data.World import Dodge.Data.World
import Dodge.Default.Item import Dodge.Default.Item
import Dodge.Item.Attach
--import Dodge.Item.Weapon.Bullet
megaTinMag :: Int -> Item megaTinMag :: Int -> Item
megaTinMag x = megaTinMag x = tinMag & itConsumables ?~ x
tinMag
& itConsumables ?~ x
tinMag :: Item tinMag :: Item
tinMag = tinMag =
defaultHeldItem & itType .~ AMMOMAG TINMAG defHeldItem
& itType .~ AMMOMAG TINMAG
& itUse .~ UseNothing & itUse .~ UseNothing
& itConsumables ?~ 15 & itConsumables ?~ 15
drumMag :: Item drumMag :: Item
drumMag = drumMag =
tinMag & itType . ibtAmmoMag .~ DRUMMAG tinMag
& itType . ibtAmmoMag .~ DRUMMAG
& itUse .~ UseNothing
& itConsumables ?~ 30 & itConsumables ?~ 30
beltMag :: Item beltMag :: Item
beltMag = beltMag =
tinMag & itType . ibtAmmoMag .~ BELTMAG tinMag
& itType . ibtAmmoMag .~ BELTMAG
& itConsumables ?~ 10000 & itConsumables ?~ 10000
megaShellMag :: Item megaShellMag :: Item
megaShellMag = megaShellMag = shellMag & itConsumables ?~ 1000000
shellMag
& itConsumables ?~ 1000000
shellMag :: Item shellMag :: Item
shellMag = shellMag =
defaultHeldItem & itType .~ AMMOMAG SHELLMAG defHeldItem
& itType .~ AMMOMAG SHELLMAG
& itUse .~ UseNothing & itUse .~ UseNothing
& itConsumables ?~ 1 & itConsumables ?~ 1
megaBattery :: Item megaBattery :: Item
megaBattery = megaBattery = battery & itConsumables ?~ 1000000
battery
& itConsumables ?~ 1000000
smallBattery :: Item smallBattery :: Item
smallBattery = battery & itConsumables ?~ 999 smallBattery = battery & itConsumables ?~ 999
battery :: Item battery :: Item
battery = battery =
defaultHeldItem & itType .~ AMMOMAG BATTERY defHeldItem
& itType .~ AMMOMAG BATTERY
& itUse .~ UseNothing & itUse .~ UseNothing
& itConsumables ?~ 10 ^ (9 :: Int) & itConsumables ?~ 10 ^ (9 :: Int)
capacitor :: Item capacitor :: Item
capacitor = capacitor =
defaultHeldItem & itType .~ ATTACH CAPACITOR defHeldItem
& itType .~ ATTACH CAPACITOR
& itUse .~ UseNothing & itUse .~ UseNothing
& itConsumables ?~ 0 & itConsumables ?~ 0
chemFuelPouch :: Item chemFuelPouch :: Item
chemFuelPouch = chemFuelPouch =
defaultHeldItem & itType .~ AMMOMAG CHEMFUELPOUCH defHeldItem
& itType .~ AMMOMAG CHEMFUELPOUCH
& itUse .~ UseNothing & itUse .~ UseNothing
& itConsumables & itConsumables
?~ 100000 ?~ 100000
bulletSynthesizer :: Item bulletSynthesizer :: Item
bulletSynthesizer = makeAttach BULLETSYNTH & itUse .~ UseAttach (APInt 0) bulletSynthesizer = defHeldItem
& itType .~ ATTACH BULLETSYNTH
& itUse .~ UseAttach (APInt 0)
+4 -2
View File
@@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-} {-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
module Dodge.Item.AmmoSlots ( module Dodge.Item.AmmoSlots (
itemAmmoSlots, itemAmmoSlots,
@@ -29,14 +30,15 @@ heldItemAmmoSlots = \case
RIFLE -> singleAmmo BulletAmmo RIFLE -> singleAmmo BulletAmmo
AUTORIFLE -> singleAmmo BulletAmmo AUTORIFLE -> singleAmmo BulletAmmo
BURSTRIFLE -> singleAmmo BulletAmmo BURSTRIFLE -> singleAmmo BulletAmmo
ALTERIFLE -> IM.fromList (zip [0..1] $ repeat BulletAmmo) --ALTERIFLE -> IM.fromList (zip [0..1] $ repeat BulletAmmo)
ALTERIFLE -> IM.fromList $ [0..1] <&> (,BulletAmmo)
BANGROD -> singleAmmo BulletAmmo BANGROD -> singleAmmo BulletAmmo
ELEPHANTGUN -> singleAmmo BulletAmmo ELEPHANTGUN -> singleAmmo BulletAmmo
AMR -> singleAmmo BulletAmmo AMR -> singleAmmo BulletAmmo
AUTOAMR -> singleAmmo BulletAmmo AUTOAMR -> singleAmmo BulletAmmo
SNIPERRIFLE -> singleAmmo BulletAmmo SNIPERRIFLE -> singleAmmo BulletAmmo
MINIGUNX _ -> singleAmmo BeltBulletAmmo MINIGUNX _ -> singleAmmo BeltBulletAmmo
VOLLEYGUN i -> IM.fromList (zip [0..i-1] $ repeat BulletAmmo) VOLLEYGUN i -> IM.fromList $ [0..i-1] <&> (,BulletAmmo)
POISONSPRAYER -> singleAmmo GasAmmo POISONSPRAYER -> singleAmmo GasAmmo
FLAMETHROWER -> singleAmmo GasAmmo FLAMETHROWER -> singleAmmo GasAmmo
FLAMETORRENT -> singleAmmo GasAmmo FLAMETORRENT -> singleAmmo GasAmmo
-14
View File
@@ -1,14 +0,0 @@
module Dodge.Item.Attach
(makeAttach
)
where
import Dodge.Data.Item
import Dodge.Default.Item
import Control.Lens
makeAttach :: AttachType -> Item
makeAttach t = defaultHeldItem
& itType .~ ATTACH t
& itUse .~ UseAttach APNothing
+14
View File
@@ -2,6 +2,7 @@ module Dodge.Item.BackgroundEffect (
itEffectOnPickup, itEffectOnPickup,
itEffectOnDrop, itEffectOnDrop,
rootNotrootEff, rootNotrootEff,
rootAndAttNotEff,
createShieldWall, createShieldWall,
removeShieldWall, removeShieldWall,
) where ) where
@@ -36,6 +37,19 @@ rootNotrootEff f g it
| it ^? itLocation . ilIsRoot == Just True = f it | it ^? itLocation . ilIsRoot == Just True = f it
| otherwise = g it | otherwise = g it
rootAndAttNotEff ::
(Item -> Creature -> World -> World) ->
(Item -> Creature -> World -> World) ->
Item ->
Creature ->
World ->
World
rootAndAttNotEff f g it
| it ^? itLocation . ilIsRoot == Just True
&& it ^? itLocation . ilIsAttached == Just True
= f it
| otherwise = g it
createShieldWall :: Item -> Creature -> World -> World createShieldWall :: Item -> Creature -> World -> World
createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of createShieldWall it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
Nothing -> Nothing ->
+1 -4
View File
@@ -10,10 +10,7 @@ import Dodge.Data.Item
import Dodge.Default.Item import Dodge.Default.Item
makeTypeCraftNum :: Int -> CraftType -> [Item] makeTypeCraftNum :: Int -> CraftType -> [Item]
makeTypeCraftNum i ct = makeTypeCraftNum i ct = replicate i $ defCraftItem & itType .~ CRAFT ct
replicate i $
defaultCraftItem
& itType .~ CRAFT ct
makeTypeCraft :: CraftType -> Item makeTypeCraft :: CraftType -> Item
makeTypeCraft = head . makeTypeCraftNum 1 makeTypeCraft = head . makeTypeCraftNum 1
+14 -13
View File
@@ -321,9 +321,6 @@ shatterGunSPic =
xa = 1 xa = 1
xb = 9 xb = 9
baseCaneShape :: Shape
baseCaneShape = colorSH red $ xCylinderST 3 15
baseRifleShape :: Shape baseRifleShape :: Shape
baseRifleShape = colorSH red $ xCylinderST 3 25 baseRifleShape = colorSH red $ xCylinderST 3 25
@@ -368,18 +365,22 @@ volleyGunShape i =
-- to get this rotating should probably add extra state to the minigun -- to get this rotating should probably add extra state to the minigun
miniGunXPictItem :: Int -> Item -> SPic miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i (_wTime (_itParams it) - 10) miniGunXPictItem i it = miniGunXPict i (f $ _wTime (_itParams it))
miniGunXPict :: Int -> Int -> SPic
miniGunXPict i spin =
noPic
( colorSH red (rotateSHx a barrels)
<> baseRifleShape
)
where where
aBarrel = translateSH (V3 15 2 2) baseCaneShape f x = y * (y + z) / (100 +z)
where
z = 0 -- increase to adjust acceleration
y = fromIntegral x
miniGunXPict :: Int -> Float -> SPic
miniGunXPict i spin =
noPic .
colorSH red $ rotateSHx a barrels
<> xCylinderST 3 40
where
aBarrel = translateSH (V3 15 4 2.5) $ xCylinderST 2 25
barrels = foldMap (\an -> aBarrel & rotateSHx (2 * pi * fromIntegral an / fromIntegral i)) [1 .. i] barrels = foldMap (\an -> aBarrel & rotateSHx (2 * pi * fromIntegral an / fromIntegral i)) [1 .. i]
a = fromIntegral spin / 100 a = 2 * pi * spin / 25
--x = fromIntegral am / 10 --x = fromIntegral am / 10
-- clip y z = translateSH (V3 0 (-1) z) (rotateSHx (negate $ pi/4) -- clip y z = translateSH (V3 0 (-1) z) (rotateSHx (negate $ pi/4)
+16 -35
View File
@@ -18,74 +18,58 @@ module Dodge.Item.Equipment (
) where ) where
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
--import Dodge.Item.Weapon.Bullet
import Dodge.Data.Item import Dodge.Data.Item
import Dodge.Data.Magnet import Dodge.Data.Magnet
import Dodge.Default import Dodge.Default
import LensHelp import LensHelp
magShield :: MagnetBuBu -> Item magShield :: MagnetBuBu -> Item
magShield mt = magShield mt = defEquipment & itType .~ EQUIP (MAGSHIELD mt)
defaultEquipment
-- & itUse . uequipEffect . eeUse .~ EMagShield MagnetRepulse
& itType .~ EQUIP (MAGSHIELD mt)
flameShield :: Item flameShield :: Item
flameShield = flameShield = defEquipment & itType .~ EQUIP FLAMESHIELD
defaultEquipment
& itType .~ EQUIP FLAMESHIELD
frontArmour :: Item frontArmour :: Item
frontArmour = frontArmour = defEquipment & itType .~ EQUIP FRONTARMOUR
defaultEquipment
& itType .~ EQUIP FRONTARMOUR
wristArmour :: Item wristArmour :: Item
wristArmour = defaultEquipment & itType .~ EQUIP WRISTARMOUR wristArmour = defEquipment & itType .~ EQUIP WRISTARMOUR
batteryPack :: Item batteryPack :: Item
batteryPack = batteryPack =
defaultEquipment defEquipment
& itConsumables & itConsumables ?~ 10000000
?~ 10000000
& itType .~ EQUIP BATTERYPACK & itType .~ EQUIP BATTERYPACK
fuelPack :: Item fuelPack :: Item
fuelPack = fuelPack =
defaultEquipment defEquipment
-- & itUse . uequipEffect . eeUse .~ EFuelSource 10000 10000
& itType .~ EQUIP FUELPACK & itType .~ EQUIP FUELPACK
& itConsumables & itConsumables ?~ 100000
?~ 100000
bulletBeltPack :: Item bulletBeltPack :: Item
bulletBeltPack = bulletBeltPack =
defaultEquipment defEquipment
& itConsumables ?~ 10000000 & itConsumables ?~ 10000000
& itType .~ EQUIP BULLETBELTPACK & itType .~ EQUIP BULLETBELTPACK
bulletBeltBracer :: Item bulletBeltBracer :: Item
bulletBeltBracer = bulletBeltBracer =
defaultEquipment defEquipment
& itConsumables ?~ 100000 & itConsumables ?~ 100000
& itType .~ EQUIP BULLETBELTBRACER & itType .~ EQUIP BULLETBELTBRACER
brainHat :: Item brainHat :: Item
brainHat = defaultEquipment & itType .~ EQUIP BRAINHAT brainHat = defEquipment & itType .~ EQUIP BRAINHAT
hat :: Item hat :: Item
hat = defaultEquipment & itType .~ EQUIP HAT hat = defEquipment & itType .~ EQUIP HAT
headLamp :: Item headLamp :: Item
headLamp = headLamp = defEquipment & itType .~ EQUIP HEADLAMP
defaultEquipment
-- & itUse . uequipEffect . eeUse .~ EHeadLamp
& itType .~ EQUIP HEADLAMP
powerLegs :: Item powerLegs :: Item
powerLegs = powerLegs = defEquipment & itType .~ EQUIP POWERLEGS
defaultEquipment
& itType .~ EQUIP POWERLEGS
speedLegs :: Item speedLegs :: Item
speedLegs = powerLegs & itType .~ EQUIP SPEEDLEGS speedLegs = powerLegs & itType .~ EQUIP SPEEDLEGS
@@ -95,10 +79,7 @@ jumpLegs = powerLegs & itType .~ EQUIP JUMPLEGS
wristInvisibility :: Item wristInvisibility :: Item
wristInvisibility = wristInvisibility =
defaultEquipment defEquipment & itType .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
-- & itUse . uequipEffect . eeOnEquip .~ ECamouflage Invisible
-- & itUse . uequipEffect . eeOnRemove .~ ECamouflage FullyVisible
& itType .~ EQUIP (INVISIBILITYEQUIPMENT GoesOnWrist)
pulseChecker :: Item pulseChecker :: Item
pulseChecker = defaultEquipment & itType .~ EQUIP WRIST_ECG pulseChecker = defEquipment & itType .~ EQUIP WRIST_ECG
+3 -2
View File
@@ -197,11 +197,12 @@ rightChildList t = foldl' f l (reverse $ t ^.. dtRight . each . dtValue . _2)
leftRightCombine :: DTComb a -> DTComb a -> DTree a -> DTree a -> Maybe (DTree a) leftRightCombine :: DTComb a -> DTComb a -> DTree a -> DTree a -> Maybe (DTree a)
leftRightCombine f f' t1 t2 = f t1 t2 <|> checkdepth t1 t2 leftRightCombine f f' t1 t2 = f t1 t2 <|> checkdepth t1 t2
where where
checkdepth t t'@(DT x ls rs) = fromMaybe (checktop t t') $ do --checkdepth t t'@(DT x ls rs) = fromMaybe (checktop t t') $ do
checkdepth t t'@(DT x ls rs) = fromMaybe (f' t t') $ do
t'' <- safeHead ls t'' <- safeHead ls
tx <- checkdepth t t'' tx <- checkdepth t t''
return $ Just $ DT x (tx : tail ls) rs return $ Just $ DT x (tx : tail ls) rs
checktop t t' = f' t t' --checktop t t' = f' t t'
joinItemsInList :: (a -> a -> Maybe a) -> [a] -> [a] joinItemsInList :: (a -> a -> Maybe a) -> [a] -> [a]
joinItemsInList f = fst . h . ([],) joinItemsInList f = fst . h . ([],)
+3 -18
View File
@@ -18,7 +18,7 @@ sparkGun =
teslaGun :: Item teslaGun :: Item
teslaGun = teslaGun =
defaultHeldItem defHeldItem
& itParams .~ teslaParams & itParams .~ teslaParams
& itType .~ HELD TESLAGUN & itType .~ HELD TESLAGUN
@@ -33,14 +33,7 @@ teslaParams =
-- previous phaseV parameters: 0.2, 1, 5 -- previous phaseV parameters: 0.2, 1, 5
laser :: Item laser :: Item
laser = laser =
defaultHeldItem defHeldItem
-- & itUse . heldParams .~ BeamShooterParams-- Nothing
-- & itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldDelay .~ NoDelay
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 6 0
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ LasGunFlare
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleLaser
& itTargeting & itTargeting
.~ ItTargeting .~ ItTargeting
{ _itTgPos = Nothing { _itTgPos = Nothing
@@ -51,12 +44,4 @@ laser =
-- previous attractionPower values: 1, -1, -10, 0 -- previous attractionPower values: 1, -1, -10, 0
tractorGun :: Item tractorGun :: Item
tractorGun = tractorGun = defHeldItem & itType .~ HELD TRACTORGUN
defaultHeldItem
-- & itUse . heldParams .~ BeamShooterParams
-- & itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ NoFlare
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleTractor
& itType .~ HELD TRACTORGUN
+2 -2
View File
@@ -13,11 +13,11 @@ import Dodge.Default
import LensHelp import LensHelp
volleyGun :: Int -> Item volleyGun :: Int -> Item
volleyGun i = defaultHeldItem & itType .~ HELD (VOLLEYGUN i) volleyGun i = defHeldItem & itType .~ HELD (VOLLEYGUN i)
& itParams .~ VolleyUnfiredBarrels [0..i-1] & itParams .~ VolleyUnfiredBarrels [0..i-1]
rifle :: Item rifle :: Item
rifle = defaultHeldItem & itType .~ HELD RIFLE rifle = defHeldItem & itType .~ HELD RIFLE
alteRifle :: Item alteRifle :: Item
alteRifle = rifle alteRifle = rifle
+1 -1
View File
@@ -9,7 +9,7 @@ import Dodge.Data.Item
import Dodge.Default.Item import Dodge.Default.Item
bangCone :: Item bangCone :: Item
bangCone = defaultHeldItem & itType .~ HELD BANGCONE bangCone = defHeldItem & itType .~ HELD BANGCONE
blunderbuss :: Item blunderbuss :: Item
blunderbuss = bangCone & itType .~ HELD BLUNDERBUSS blunderbuss = bangCone & itType .~ HELD BLUNDERBUSS
+1 -1
View File
@@ -13,7 +13,7 @@ import Dodge.Default.Item
rLauncher :: Item rLauncher :: Item
rLauncher = rLauncher =
defaultHeldItem defHeldItem
-- & itUse . heldDelay . rateMax .~ 20 -- & itUse . heldDelay . rateMax .~ 20
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0 -- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0
-- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleRLauncher -- & itUse . heldMuzzles . ix 0 . mzEffect .~ MuzzleRLauncher
+1 -1
View File
@@ -17,7 +17,7 @@ import LensHelp
bangRod :: Item bangRod :: Item
bangRod = bangRod =
defaultHeldItem defHeldItem
-- & itUse . heldDelay . rateMax .~ 12 -- & itUse . heldDelay . rateMax .~ 12
& itType .~ HELD BANGROD & itType .~ HELD BANGROD
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0 -- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
+1 -1
View File
@@ -63,7 +63,7 @@ flameWall =
flameThrower :: Item flameThrower :: Item
flameThrower = flameThrower =
defaultHeldItem defHeldItem
& itType .~ HELD FLAMETHROWER & itType .~ HELD FLAMETHROWER
& itParams .~ NozzleAngle 0 & itParams .~ NozzleAngle 0
-- & itUse . heldDelay .~ NoDelay -- & itUse . heldDelay .~ NoDelay
+2 -30
View File
@@ -13,38 +13,10 @@ import Dodge.Default.Item
import LensHelp import LensHelp
bangStick :: Int -> Item bangStick :: Int -> Item
bangStick i = bangStick i = defHeldItem & itType .~ HELD (BANGSTICK i)
defaultHeldItem
-- & itUse . heldParams . recoil .~ 25
& itType .~ HELD (BANGSTICK i)
-- & itUse . heldDelay . rateMax .~ 8
-- & itUse . heldMuzzles
-- .~ [ Muzzle
-- (V2 10 0)
-- a
-- 0.01
-- 0
-- NoFlare
-- MuzzleShootBullet
-- (UseExactly 1)
-- 0
-- | a <- spreadAroundCenter i baseStickSpread
-- ]
-- & itUse . heldMuzzles . ix 0 . mzFlareType .~ NoLightFlare
-- & itUse . heldMuzzles . ix (i `div` 2) . mzFlareType .~ MiniGunFlare
-- & itUse . heldMuzzles . ix (i-1) . mzFlareType .~ NoLightFlare
--baseStickSpread :: Float
--baseStickSpread = 0.2
pistol :: Item pistol :: Item
pistol = pistol = bangStick 1 & itType .~ HELD PISTOL
bangStick 1
-- & itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMuzzles . ix 0 . mzPos %~ const (V2 10 0)
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy %~ const 0.05
-- & itUse . heldMuzzles . ix 0 . mzFlareType %~ const BasicFlare
& itType .~ HELD PISTOL
autoPistol :: Item autoPistol :: Item
autoPistol = pistol & itType .~ HELD AUTOPISTOL autoPistol = pistol & itType .~ HELD AUTOPISTOL
+5 -5
View File
@@ -15,20 +15,20 @@ import Dodge.Data.Item
import Dodge.Default.Item import Dodge.Default.Item
flatShield :: Item flatShield :: Item
flatShield = defaultHeldItem & itType .~ HELD FLATSHIELD flatShield = defHeldItem & itType .~ HELD FLATSHIELD
keyCard :: Int -> Item keyCard :: Int -> Item
keyCard n = defaultHeldItem & itType .~ HELD (KEYCARD n) keyCard n = defHeldItem & itType .~ HELD (KEYCARD n)
led :: Item led :: Item
led = defaultHeldItem & itType .~ HELD LED led = defHeldItem & itType .~ HELD LED
-- | Sends out pulses that display walls. -- | Sends out pulses that display walls.
detector :: Detector -> Item detector :: Detector -> Item
detector dt = defaultHeldItem & itType .~ DETECTOR dt detector dt = defHeldItem & itType .~ DETECTOR dt
blinker :: Item blinker :: Item
blinker = defaultHeldItem & itType .~ HELD BLINKER blinker = defHeldItem & itType .~ HELD BLINKER
unsafeBlinker :: Item unsafeBlinker :: Item
unsafeBlinker = blinker & itType .~ HELD BLINKERUNSAFE unsafeBlinker = blinker & itType .~ HELD BLINKERUNSAFE
+1 -3
View File
@@ -6,9 +6,7 @@ import Control.Lens
--import Linear.V2 --import Linear.V2
shatterGun :: Item shatterGun :: Item
shatterGun = shatterGun = defHeldItem & itType .~ HELD SHATTERGUN
defaultHeldItem
& itType .~ HELD SHATTERGUN
-- & itUse . heldDelay . rateMax .~ 10 -- & itUse . heldDelay . rateMax .~ 10
-- & itAmmoSlots .~ singleAmmo ElectricalAmmo -- & itAmmoSlots .~ singleAmmo ElectricalAmmo
-- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0 -- & itUse . heldMuzzles . ix 0 . mzPos .~ V2 30 0
+2 -7
View File
@@ -7,6 +7,7 @@ module Dodge.Item.HeldOffset (
handHandleOrient, handHandleOrient,
) where ) where
import Dodge.Creature.HandPos
import Dodge.Data.AimStance import Dodge.Data.AimStance
import Dodge.Data.ComposedItem import Dodge.Data.ComposedItem
import Dodge.Data.Creature import Dodge.Data.Creature
@@ -43,16 +44,10 @@ handOrient cr = case cr ^. crStance . posture of
OneHand -> (V3 13 (-2) shoulderHeight, Q.qID) OneHand -> (V3 13 (-2) shoulderHeight, Q.qID)
TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qID) TwoHandFlat -> (V3 13 0 shoulderHeight, Q.qID)
AtEase -> \case AtEase -> \case
OneHand -> (V3 (10 + walkhandp) (-7) 15, Q.qID) OneHand -> rightHandPQ cr
TwoHandFlat -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) $ twoFlatHRot cr) TwoHandFlat -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) $ twoFlatHRot cr)
TwoHandUnder -> (V3 7 (-8) 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2)) TwoHandUnder -> (V3 7 (-8) 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
TwoHandOver -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2)) TwoHandOver -> (V3 10 0 15, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2))
where
walkhandp = case cr ^? crStance . carriage of
Just (Walking x LeftForward) -> f x * 50 -2
_ -> - 2
f i = 0.1 * (sLen - i) / sLen
sLen = _strideLength $ _crStance cr
locOrient :: LocationDT OItem -> Creature -> Point3Q locOrient :: LocationDT OItem -> Creature -> Point3Q
locOrient loc cr = locOrient loc cr =
+12
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Item.Orientation ( module Dodge.Item.Orientation (
orientAttachment, orientAttachment,
propagateOrientation, propagateOrientation,
@@ -34,6 +35,9 @@ orientChild itm = case _itType itm of
orientByParentChSF :: Item -> ItemSF -> Point3Q orientByParentChSF :: Item -> ItemSF -> Point3Q
orientByParentChSF itm lt = case (_itType itm, lt) of orientByParentChSF itm lt = case (_itType itm, lt) of
(HELD FLAMETHROWER, AmmoMagSF{}) -> (V3 4 (-6) 0, Q.qID) (HELD FLAMETHROWER, AmmoMagSF{}) -> (V3 4 (-6) 0, Q.qID)
(HELD (VOLLEYGUN n), AmmoMagSF i _)
-> (V3 2 (2.5 + fromIntegral i * 5 - (0.5 * 5 * fromIntegral n)) 3, Q.qz (pi/2))
(HELD ALTERIFLE, AmmoMagSF i _) -> alteRifleAmmoOrient itm i
(HELD _, AmmoMagSF{_amsfType = ElectricalAmmo}) -> (V3 0 0 z, Q.qID) (HELD _, AmmoMagSF{_amsfType = ElectricalAmmo}) -> (V3 0 0 z, Q.qID)
(HELD _, AmmoMagSF{}) -> (V3 7 (itemShapeMin _y itm) 0, Q.qID) (HELD _, AmmoMagSF{}) -> (V3 7 (itemShapeMin _y itm) 0, Q.qID)
(HELD _, WeaponScopeSF) -> (V3 5 0 5, Q.qID) (HELD _, WeaponScopeSF) -> (V3 5 0 5, Q.qID)
@@ -44,6 +48,14 @@ orientByParentChSF itm lt = case (_itType itm, lt) of
y = itemShapeMaxY itm y = itemShapeMaxY itm
z = itemShapeMaxZ itm z = itemShapeMaxZ itm
alteRifleAmmoOrient :: Item -> Int -> Point3Q
alteRifleAmmoOrient itm = \case
1 -> (V3 18 (itemShapeMin _y itm + s + 1) 0, Q.qID)
_ -> (V3 18 (itemShapeMax _y itm + s - 1) 0, Q.qz pi)
where
s | itm ^? itParams . alteRifleSwitch == Just 0 = 1
| otherwise = -1
itemShapeMaxX :: Item -> Float itemShapeMaxX :: Item -> Float
itemShapeMaxX = itemShapeMax _1 itemShapeMaxX = itemShapeMax _1
+66 -43
View File
@@ -25,139 +25,162 @@ module Dodge.Item.Scope (
bingate, bingate,
) where ) where
import Dodge.Item.Attach
import Control.Lens import Control.Lens
import Dodge.Data.Item import Dodge.Data.Item
import Dodge.Default.Item import Dodge.Default.Item
zoomScope :: Item zoomScope :: Item
zoomScope = defaultHeldItem zoomScope =
& itType .~ ATTACH ZOOMSCOPE defHeldItem
& itUse .~ UseScope OpticScope{_opticPos = 0, _opticZoom = 1, _opticDefaultZoom = 0.5} & itType .~ ATTACH ZOOMSCOPE
& itUse .~ UseScope OpticScope{_opticPos = 0, _opticZoom = 1, _opticDefaultZoom = 0.5}
targetingScope :: TargetingType -> Item targetingScope :: TargetingType -> Item
targetingScope tt = defaultHeldItem targetingScope tt =
defHeldItem
& itType .~ TARGETING tt & itType .~ TARGETING tt
& itUse .~ UseNothing & itUse .~ UseNothing
& itTargeting .~ ItTargeting & itTargeting
{ _itTgPos = Nothing .~ ItTargeting
, _itTgID = Nothing { _itTgPos = Nothing
, _itTgActive = False , _itTgID = Nothing
} , _itTgActive = False
}
homingModule :: Item homingModule :: Item
homingModule = makeAttach HOMINGMODULE homingModule =
defHeldItem
& itType .~ ATTACH HOMINGMODULE
& itUse .~ UseAttach APNothing
stickyMod :: Item stickyMod :: Item
stickyMod = stickyMod =
defaultHeldItem defHeldItem
& itType .~ STICKYMOD & itType .~ STICKYMOD
& itUse .~ UseNothing & itUse .~ UseNothing
introScan :: IntroScanType -> Item introScan :: IntroScanType -> Item
introScan t = introScan t =
defaultHeldItem defHeldItem
& itType .~ INTROSCAN t & itType .~ INTROSCAN t
& itUse .~ UseNothing & itUse .~ UseNothing
itemScan :: Item itemScan :: Item
itemScan = itemScan =
defaultHeldItem defHeldItem
& itType .~ ITEMSCAN & itType .~ ITEMSCAN
& itUse .~ UseNothing & itUse .~ UseNothing
-- & itEffect . ieOnDrop .~ ItemCancelExamineInventory -- & itEffect . ieOnDrop .~ ItemCancelExamineInventory
mapper :: Item mapper :: Item
mapper = mapper =
defaultHeldItem defHeldItem
& itType .~ MAPPER & itType .~ MAPPER
& itUse .~ UseMapper mempty mempty & itUse .~ UseMapper mempty mempty
dropper :: InventoryPathing -> Item dropper :: InventoryPathing -> Item
dropper x = dropper x =
defaultHeldItem defHeldItem
& itType .~ DROPPER x & itType .~ DROPPER x
& itUse .~ UseInt 0 & itUse .~ UseInt 0
clicker :: InventoryPathing -> Item clicker :: InventoryPathing -> Item
clicker x = clicker x =
defaultHeldItem defHeldItem
& itType .~ CLICKER x & itType .~ CLICKER x
& itUse .~ UseInt 0 & itUse .~ UseInt 0
copier :: InventoryPathing -> Item copier :: InventoryPathing -> Item
copier x = copier x =
defaultHeldItem defHeldItem
& itType .~ COPIER x & itType .~ COPIER x
& itUse .~ UseValue (Left 0) & itUse .~ UseValue (Left 0)
& itScroll .~ ItemScrollInt 0 & itScroll .~ ItemScrollInt 0
nulgate :: Item nulgate :: Item
nulgate = nulgate =
defaultHeldItem defHeldItem
& itType .~ NULGATE & itType .~ NULGATE
& itUse .~ UseNothing & itUse .~ UseNothing
& itScroll .~ ItemScrollIntRange 2 0 & itScroll .~ ItemScrollIntRange 2 0
unigate :: Item unigate :: Item
unigate = unigate =
defaultHeldItem defHeldItem
& itType .~ UNIGATE & itType .~ UNIGATE
& itUse .~ UseNothing & itUse .~ UseNothing
& itScroll .~ ItemScrollIntRange 4 0 & itScroll .~ ItemScrollIntRange 4 0
bingate :: Item bingate :: Item
bingate = bingate =
defaultHeldItem defHeldItem
& itType .~ BINGATE & itType .~ BINGATE
& itUse .~ UseNothing & itUse .~ UseNothing
& itScroll .~ ItemScrollIntRange 16 0 & itScroll .~ ItemScrollIntRange 16 0
bulletModule :: BulletMod -> Item bulletModule :: BulletMod -> Item
bulletModule bm = bulletModule bm =
defaultHeldItem defHeldItem
& itType .~ BULLETMOD bm & itType .~ BULLETMOD bm
& itUse .~ UseBulletMod {_ubMod = bm} & itUse .~ UseBulletMod{_ubMod = bm}
shellModule :: Payload -> Item shellModule :: Payload -> Item
shellModule p = defaultHeldItem shellModule p =
defHeldItem
& itType .~ ATTACH (SHELLPAYLOAD p) & itType .~ ATTACH (SHELLPAYLOAD p)
& itUse .~ UseNothing & itUse .~ UseNothing
--bulletTargetingModule :: BulletTrajectoryType -> Item -- bulletTargetingModule :: BulletTrajectoryType -> Item
--bulletTargetingModule = bulletModule . BulletModTrajectory -- bulletTargetingModule = bulletModule . BulletModTrajectory
bulletPayloadModule :: BulletPayload -> Item bulletPayloadModule :: BulletPayload -> Item
bulletPayloadModule = bulletModule . BulletModPayload bulletPayloadModule = bulletModule . BulletModPayload
arHUD :: Item arHUD :: Item
arHUD = defaultHeldItem arHUD =
& itType .~ ARHUD defHeldItem
& itUse .~ UseNothing & itType .~ ARHUD
& itUse .~ UseNothing
remoteScreen :: Item remoteScreen :: Item
remoteScreen = makeAttach REMOTESCREEN remoteScreen =
-- & itUse . uaParams .~ APLinkProjectile Nothing defHeldItem
& itUse . uaParams .~ APProjectiles [] & itType .~ ATTACH REMOTESCREEN
& itUse .~ UseAttach (APProjectiles [])
remoteDetonator :: Item remoteDetonator :: Item
remoteDetonator = makeAttach REMOTEDETONATOR remoteDetonator =
-- & itUse .~ UseHammer HammerUp defHeldItem
& itUse . uaParams .~ APProjectiles [] & itType .~ ATTACH REMOTEDETONATOR
& itUse .~ UseAttach (APProjectiles [])
joystick :: Item joystick :: Item
joystick = makeAttach JOYSTICK joystick =
-- & itUse . uaParams .~ APLinkProjectile Nothing defHeldItem
& itType .~ ATTACH JOYSTICK
& itUse .~ UseNothing
gimbal :: Item gimbal :: Item
gimbal = makeAttach GIMBAL gimbal =
defHeldItem
& itType .~ ATTACH GIMBAL
& itUse .~ UseNothing
gyroscope :: Item gyroscope :: Item
gyroscope = makeAttach GYROSCOPE gyroscope =
defHeldItem
& itType .~ ATTACH GYROSCOPE
& itUse .~ UseNothing
underBarrelSlot :: Item underBarrelSlot :: Item
underBarrelSlot = makeAttach UNDERBARRELSLOT underBarrelSlot =
defHeldItem
& itType .~ ATTACH UNDERBARRELSLOT
& itUse .~ UseNothing
smokeReducer :: Item smokeReducer :: Item
smokeReducer = makeAttach SMOKEREDUCER smokeReducer =
defHeldItem
& itType .~ ATTACH SMOKEREDUCER
& itUse .~ UseNothing
+2 -1
View File
@@ -4,7 +4,8 @@ Random generation of high level layout of rooms.
module Dodge.Layout.Generate module Dodge.Layout.Generate
where where
import Data.Tree import Data.Tree
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
--import System.Random --import System.Random
generateLayout :: State g (Tree RoomProperties) generateLayout :: State g (Tree RoomProperties)
+2 -1
View File
@@ -1,7 +1,8 @@
module Dodge.LevelGen (generateWorldFromSeed) where module Dodge.LevelGen (generateWorldFromSeed) where
import Control.Lens import Control.Lens
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
import Data.Foldable import Data.Foldable
import Data.Preload.Render import Data.Preload.Render
import Dodge.Data.GenWorld import Dodge.Data.GenWorld
+20 -21
View File
@@ -1,8 +1,8 @@
module Dodge.ListDisplayParams ( module Dodge.ListDisplayParams (
invDP, invDP,
-- secDP,
invCursorParams, invCursorParams,
secondColumnLDP, secondColumnLDP,
terminalLDP,
subInvX, subInvX,
menuLDP, menuLDP,
) where ) where
@@ -16,9 +16,9 @@ import Dodge.Data.World
import Linear import Linear
import SDL (MouseButton (..)) import SDL (MouseButton (..))
defaultListDisplayParams :: ListDisplayParams defaultLDP :: LDParams
defaultListDisplayParams = defaultLDP =
ListDisplayParams LDP
{ _ldpVerticalGap = 0 { _ldpVerticalGap = 0
, _ldpScale = 1 , _ldpScale = 1
, _ldpPos = , _ldpPos =
@@ -26,24 +26,27 @@ defaultListDisplayParams =
{ _spScreenOff = V2 (-0.5) 0.5 -- top left { _spScreenOff = V2 (-0.5) 0.5 -- top left
, _spPixelOff = 0 , _spPixelOff = 0
} }
, _ldpBorder = Nothing
} }
invDP :: ListDisplayParams invDP :: LDParams
invDP = invDP = defaultLDP & ldpPos . spPixelOff .~ V2 16 (-20)
defaultListDisplayParams
-- & ldpPos . spPixelOff .~ V2 6 (-1)
& ldpPos . spPixelOff .~ V2 6 0
invCursorParams :: World -> CursorDisplay invCursorParams :: World -> CursorDisplay
invCursorParams w = BoundaryCursor $ case w ^? hud . subInventory of invCursorParams w = BoundCurs $ case w ^? hud . subInventory of
-- Just ExamineInventory{} -> [North, South, East, West] -- Just ExamineInventory{} -> [North, South, East, West]
Just CombineInventory{} -> [] Just CombineInventory{} -> []
_ | ButtonRight `M.member` _mouseButtons (_input w) -> [North, South, East, West] _
| ButtonRight `M.member` _mouseButtons (_input w)
&& null (w ^? rbState . opSel) ->
[North, South, East, West]
_ -> [North, South, West] _ -> [North, South, West]
secondColumnLDP :: ListDisplayParams secondColumnLDP :: LDParams
--secondColumnLDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 subInvX (-20) secondColumnLDP = defaultLDP & ldpPos . spPixelOff .~ V2 subInvX (-20)
secondColumnLDP = defaultListDisplayParams & ldpPos . spPixelOff .~ V2 subInvX 0
terminalLDP :: LDParams
terminalLDP = secondColumnLDP & ldpBorder ?~ (49, 16)
subInvX :: Float subInvX :: Float
subInvX = 10 * fromIntegral topInvW + 170 subInvX = 10 * fromIntegral topInvW + 170
@@ -51,9 +54,5 @@ subInvX = 10 * fromIntegral topInvW + 170
topInvW :: Int topInvW :: Int
topInvW = 15 topInvW = 15
menuLDP :: ListDisplayParams menuLDP :: LDParams
menuLDP = menuLDP = defaultLDP & ldpPos . spPixelOff .~ V2 11 (-70) & ldpScale .~ 2
defaultListDisplayParams
& ldpPos . spPixelOff .~ V2 11 (-70)
& ldpScale .~ 2
& ldpVerticalGap .~ 0
-56
View File
@@ -1,56 +0,0 @@
module Dodge.Machine where
import Linear
import Dodge.Base
import Dodge.Data.World
import Dodge.Machine.Damage
import Dodge.SoundLogic
import Dodge.Wall.Delete
import Geometry
import qualified IntMapHelp as IM
import LensHelp
import Sound.Data
basicMachineUpdate :: (Machine -> World -> World) -> Machine -> World -> World
basicMachineUpdate f mc = basicMachineApplyDamage mc . f mc
machineUpdateLiveDieEff ::
-- | effect when hp >= 1
(Machine -> World -> World) ->
-- | effect (once) when hp < 1
(Machine -> World -> World) ->
Machine ->
World ->
World
machineUpdateLiveDieEff livef dief mc
| _mcHP mc < 1 =
dief mc
. (cWorld . lWorld . machines %~ IM.delete mcid)
. deleteWallIDs (_mcWallIDs mc)
| otherwise = livef mc . (cWorld . lWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams)))
where
dams = sum $ map _dmAmount $ _mcDamage mc
mcid = _mcID mc
machineUpdateDeathEff ::
(Machine -> World -> World) ->
Machine ->
World ->
World
machineUpdateDeathEff f mc
| _mcHP mc < 1 =
f mc
. (cWorld . lWorld . machines %~ IM.delete mcid)
. deleteWallIDs (_mcWallIDs mc)
| otherwise = cWorld . lWorld . machines . ix mcid %~ ((mcDamage .~ []) . (mcHP -~ dams))
where
dams = sum $ map _dmAmount $ _mcDamage mc
mcid = _mcID mc
machineAddSound :: SoundID -> (Machine -> World -> World) -> Machine -> World -> World
machineAddSound sid f mc w
| d < 200 = soundContinueVol (1 -0.005 * d) (MachineSound mid) (_mcPos mc) sid (Just 2) $ f mc w
| otherwise = f mc w
where
d = dist (you w ^. crPos . _xy) (_mcPos mc)
mid = _mcID mc
+1
View File
@@ -24,6 +24,7 @@ destroyMcType mt mc w = case mt of
McTurret tu -> fromMaybe w $ do McTurret tu -> fromMaybe w $ do
itm <- w ^? cWorld . lWorld . items . ix (tu ^. tuWeapon) itm <- w ^? cWorld . lWorld . items . ix (tu ^. tuWeapon)
return $ copyItemToFloor (_mcPos mc) itm w return $ copyItemToFloor (_mcPos mc) itm w
McTrigger i -> w & cWorld . lWorld . triggers . ix i %~ not
_ -> w _ -> w
mcKillTerm :: Machine -> World -> World mcKillTerm :: Machine -> World -> World
+14 -12
View File
@@ -1,6 +1,5 @@
module Dodge.Machine.Draw (drawMachine) where module Dodge.Machine.Draw (drawMachine) where
import Dodge.Room.Foreground
import Control.Lens import Control.Lens
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
import Data.Maybe import Data.Maybe
@@ -8,6 +7,7 @@ import Dodge.Data.CWorld
import Dodge.Item.Draw.SPic import Dodge.Item.Draw.SPic
import Dodge.Item.HeldOffset import Dodge.Item.HeldOffset
import Dodge.Placement.TopDecoration import Dodge.Placement.TopDecoration
import Dodge.Room.Foreground
import Dodge.Terminal.Color import Dodge.Terminal.Color
import Geometry import Geometry
import Picture import Picture
@@ -20,16 +20,18 @@ drawMachine cw mc = case _mcType mc of
McTerminal -> terminalSPic lw mc McTerminal -> terminalSPic lw mc
McTurret tu -> drawBaseMachine 20 mc <> drawTurret lw tu mc McTurret tu -> drawBaseMachine 20 mc <> drawTurret lw tu mc
McDamSensor se -> drawBaseMachine 25 mc <> drawDamSensor gp se McDamSensor se -> drawBaseMachine 25 mc <> drawDamSensor gp se
McProxSensor {} -> drawBaseMachine 25 mc McProxSensor{} -> drawBaseMachine 25 mc
McStorage {} -> noPic $ colorSH (mcColor mc) storageShape McStorage{} -> noPic $ colorSH (mcColor mc) storageShape
McDistributer {} -> drawBaseMachine 25 mc McDistributer{} -> drawBaseMachine 25 mc
McTrigger{} -> drawBaseMachine 25 mc
where where
lw = cw ^. lWorld lw = cw ^. lWorld
gp = cw ^. cwGen . cwgParams . sensorCoding gp = cw ^. cwGen . cwgParams . sensorCoding
storageShape :: Shape storageShape :: Shape
storageShape = upperBox Large Typical 31 (polyCirc 4 20) <> storageShape =
foldMap toprail (take 8 [0, pi / 4 ..]) upperBox Large Typical 31 (polyCirc 4 20)
<> foldMap toprail (take 8 [0, pi / 4 ..])
where where
toprail a = rotateSH a $ thinHighBar 31 (V2 0 20) (rotateV (pi / 4) $ V2 0 20) toprail a = rotateSH a $ thinHighBar 31 (V2 0 20) (rotateV (pi / 4) $ V2 0 20)
@@ -82,12 +84,12 @@ mcColor :: Machine -> Color
mcColor mc = case mc ^. mcType of mcColor mc = case mc ^. mcType of
McStatic -> blue McStatic -> blue
McTerminal -> dark magenta McTerminal -> dark magenta
McDamSensor {} -> yellow McDamSensor{} -> yellow
McProxSensor {} -> aquamarine McProxSensor{} -> aquamarine
McTurret {} -> blue McTurret{} -> blue
McStorage {} -> orange McStorage{} -> orange
McDistributer {} -> red McDistributer{} -> green
McTrigger{} -> red
drawTurret :: LWorld -> Turret -> Machine -> SPic drawTurret :: LWorld -> Turret -> Machine -> SPic
drawTurret lw tu mc = fold $ do drawTurret lw tu mc = fold $ do
+106 -44
View File
@@ -2,8 +2,9 @@
module Dodge.Machine.Update (updateMachine) where module Dodge.Machine.Update (updateMachine) where
import Linear
import Control.Monad import Control.Monad
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List (partition) import Data.List (partition)
import Data.Maybe import Data.Maybe
import Dodge.Base.Collide import Dodge.Base.Collide
@@ -18,8 +19,8 @@ import Dodge.Terminal
import Dodge.Terminal.Color import Dodge.Terminal.Color
import Geometry import Geometry
import LensHelp import LensHelp
import qualified Data.IntMap.Strict as IM import Linear
import qualified Data.IntSet as IS import Sound.Data
updateMachine :: Machine -> World -> World updateMachine :: Machine -> World -> World
updateMachine mc updateMachine mc
@@ -36,8 +37,9 @@ mcTypeUpdate mc = \case
McTurret tu -> updateTurret (_tuTurnSpeed tu) mc McTurret tu -> updateTurret (_tuTurnSpeed tu) mc
McDamSensor se -> mcDamSensorTriggerUpdate se mc . mcDamSensorUpdate se mc McDamSensor se -> mcDamSensorTriggerUpdate se mc . mcDamSensorUpdate se mc
McProxSensor se -> mcProxSensorTriggerUpdate se mc . mcProxSensorUpdate se mc McProxSensor se -> mcProxSensorTriggerUpdate se mc . mcProxSensorUpdate se mc
McStorage {} -> id McStorage{} -> id
McDistributer {} -> id McDistributer{} -> id
McTrigger{} -> id
terminalScreenGlow :: Machine -> World -> World terminalScreenGlow :: Machine -> World -> World
terminalScreenGlow mc w = fromMaybe w $ do terminalScreenGlow mc w = fromMaybe w $ do
@@ -45,7 +47,10 @@ terminalScreenGlow mc w = fromMaybe w $ do
term <- w ^? cWorld . lWorld . terminals . ix tid term <- w ^? cWorld . lWorld . terminals . ix tid
V4 x y z _ <- termScreenColor term V4 x y z _ <- termScreenColor term
return $ return $
w & cWorld . lWorld . lights w
& cWorld
. lWorld
. lights
.:~ LSParam (_mcPos mc `v2z` 20) 30 (V3 x y z) .:~ LSParam (_mcPos mc `v2z` 20) 30 (V3 x y z)
updateTurret :: Float -> Machine -> World -> World updateTurret :: Float -> Machine -> World -> World
@@ -56,7 +61,10 @@ updateTurret rotSpeed mc w =
& elecDamBranch & elecDamBranch
where where
dodamage = dodamage =
cWorld . lWorld . machines . ix mcid cWorld
. lWorld
. machines
. ix mcid
%~ ( (mcDamage .~ [Electrical (min 2500 $ max 0 (elecDam - 10))]) %~ ( (mcDamage .~ [Electrical (min 2500 $ max 0 (elecDam - 10))])
. (mcHP -~ dam) . (mcHP -~ dam)
) )
@@ -64,7 +72,7 @@ updateTurret rotSpeed mc w =
| elecDam < 10 = updateFiringStatus . doTurn | elecDam < 10 = updateFiringStatus . doTurn
| otherwise = id | otherwise = id
mcid = _mcID mc mcid = _mcID mc
ypos = you w ^. crPos . _xy ypos = you w ^. crPos . _xy
mcpos = _mcPos mc mcpos = _mcPos mc
seesYou = hasLOSIndirect mcpos ypos w seesYou = hasLOSIndirect mcpos ypos w
(elecDams, dams) = partition isElectrical $ _mcDamage mc (elecDams, dams) = partition isElectrical $ _mcDamage mc
@@ -72,7 +80,13 @@ updateTurret rotSpeed mc w =
elecDam = sum $ map _dmAmount elecDams elecDam = sum $ map _dmAmount elecDams
doTurn doTurn
| seesYou = | seesYou =
cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuDir cWorld
. lWorld
. machines
. ix mcid
. mcType
. _McTurret
. tuDir
%~ turnTo rotSpeed mcpos ypos %~ turnTo rotSpeed mcpos ypos
| otherwise = id | otherwise = id
closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1 closeFireAngle = seesYou -- && angleVV (ypos -.- mcpos) (unitVectorAtAngle mcdir) < 1
@@ -80,7 +94,13 @@ updateTurret rotSpeed mc w =
| closeFireAngle = | closeFireAngle =
cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime .~ 20 cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime .~ 20
| otherwise = | otherwise =
cWorld . lWorld . machines . ix mcid . mcType . _McTurret . tuFireTime cWorld
. lWorld
. machines
. ix mcid
. mcType
. _McTurret
. tuFireTime
%~ (max 0 . subtract 1) %~ (max 0 . subtract 1)
isElectrical :: Damage -> Bool isElectrical :: Damage -> Bool
@@ -100,7 +120,7 @@ mcUseItem mc w = fromMaybe w $ do
mcDamSensorTriggerUpdate :: DamageSensor -> Machine -> World -> World mcDamSensorTriggerUpdate :: DamageSensor -> Machine -> World -> World
mcDamSensorTriggerUpdate se mc = fromMaybe id $ do mcDamSensorTriggerUpdate se mc = fromMaybe id $ do
trid <- mc ^? mcMounts . ix OTTrigger trid <- mc ^? mcMounts . ix OTTrigger
bval <- mcTriggerVal se let bval = se ^. sensAmount > damageTypeThreshold (se ^. sensType)
return $ cWorld . lWorld . triggers . ix trid ||~ bval return $ cWorld . lWorld . triggers . ix trid ||~ bval
mcProxSensorTriggerUpdate :: ProximitySensor -> Machine -> World -> World mcProxSensorTriggerUpdate :: ProximitySensor -> Machine -> World -> World
@@ -109,25 +129,41 @@ mcProxSensorTriggerUpdate se mc = fromMaybe id $ do
bval <- se ^? proxToggle . _Just bval <- se ^? proxToggle . _Just
return $ cWorld . lWorld . triggers . at trid ?~ bval return $ cWorld . lWorld . triggers . at trid ?~ bval
mcTriggerVal :: DamageSensor -> Maybe Bool damageTypeThreshold :: SensorType -> Int
mcTriggerVal se = Just $ _sensAmount se > _sensThreshold se damageTypeThreshold = \case
LaserSensor -> 1000
ElectricSensor -> 500
ThermalSensor -> 1000
PhysicalSensor -> 1000
mcPlaySound :: Machine -> World -> World mcPlaySound :: Machine -> World -> World
mcPlaySound mc w = case _mcType mc of mcPlaySound mc w = fromMaybe w $ do
McTerminal guard $ d < 100
| d < 100 -> (sid,x) <- mcBackgroundSound mc
soundContinueVol return $
(1 -0.01 * d) soundContinueVol
(MachineSound mid) (x * (1 - 0.01 * d))
(_mcPos mc) (MachineBackgroundSound mid)
fridgeHumS (_mcPos mc)
(Just 2) sid
w (Just 2)
_ -> w w
where where
d = max 0 (dist ( you w ^. crPos . _xy) (_mcPos mc) - 100) d = max 0 (dist (you w ^. crPos . _xy) (_mcPos mc) - 100)
mid = _mcID mc mid = _mcID mc
mcBackgroundSound :: Machine -> Maybe (SoundID,Float)
mcBackgroundSound mc = case mc ^. mcType of
McStatic -> Nothing
McTerminal -> Just (fridgeHumS,1)
McTurret{} -> Just (fridgeHumS,1)
McDamSensor{} -> Just (fridgeHumS,1)
McProxSensor{} -> Just (throbC4S,0.5)
McStorage{} -> Nothing
McDistributer{} -> Just (lowWhirS,1)
McTrigger{} -> Just (throb1S,0.5)
mcApplyDamage :: [Damage] -> Machine -> World -> World mcApplyDamage :: [Damage] -> Machine -> World -> World
mcApplyDamage ds mc = case mc ^? mcType . _McDamSensor of mcApplyDamage ds mc = case mc ^? mcType . _McDamSensor of
Nothing -> mcpointer %~ ((mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds))) Nothing -> mcpointer %~ ((mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds)))
@@ -136,7 +172,7 @@ mcApplyDamage ds mc = case mc ^? mcType . _McDamSensor of
mcpointer = cWorld . lWorld . machines . ix (_mcID mc) mcpointer = cWorld . lWorld . machines . ix (_mcID mc)
mcDamSensorUpdate :: DamageSensor -> Machine -> World -> World mcDamSensorUpdate :: DamageSensor -> Machine -> World -> World
mcDamSensorUpdate se = senseDamage (_sensThreshold se) (_sensType se) mcDamSensorUpdate se = senseDamage (damageTypeThreshold (se ^. sensType)) (se ^. sensType)
mcProxSensorUpdate :: ProximitySensor -> Machine -> World -> World mcProxSensorUpdate :: ProximitySensor -> Machine -> World -> World
mcProxSensorUpdate se mc = case se ^. proxSensorType of mcProxSensorUpdate se mc = case se ^. proxSensorType of
@@ -146,13 +182,23 @@ mcProxSensorUpdate se mc = case se ^. proxSensorType of
mcNoItemsTest :: Machine -> [Point2] -> World -> World mcNoItemsTest :: Machine -> [Point2] -> World -> World
mcNoItemsTest mc ps w mcNoItemsTest mc ps w
| t && (falsetog || notog) = | t && (falsetog || notog) =
w & mcsenslens . proxToggle ?~ True w
& mcsenslens
. proxToggle
?~ True
& playsound dedaS & playsound dedaS
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS: ZONE CLEAR" & mctermlens
. tmFutureLines
.:~ makeTermLine "SENSOR SUCCESS: ZONE CLEAR"
| not t && (truetog || notog) = | not t && (truetog || notog) =
w & mcsenslens . proxToggle ?~ False w
& mcsenslens
. proxToggle
?~ False
& playsound dedumS & playsound dedumS
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR FAIL: ITEM IN ZONE" & mctermlens
. tmFutureLines
.:~ makeTermLine "SENSOR FAIL: ITEM IN ZONE"
| otherwise = w | otherwise = w
where where
truetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just True truetog = mc ^? mcType . _McProxSensor . proxToggle . _Just == Just True
@@ -176,16 +222,23 @@ mcProximitySensorUpdate mc sens pr w
| truetog || dist (ycr ^. crPos . _xy) (_mcPos mc) > 40 = w | truetog || dist (ycr ^. crPos . _xy) (_mcPos mc) > 40 = w
| mcProxTest w pr = | mcProxTest w pr =
w w
& mcsenslens . proxToggle ?~ True & mcsenslens
. proxToggle
?~ True
& playsound dedaS & playsound dedaS
& mctermlens . tmFutureLines & mctermlens
<>~ [makeTermLine "SENSOR SUCCESS: DEACTIVATED"] . tmFutureLines
<> tlSetStatus (TerminalPressTo "QUIT") <>~ [makeTermLine "SENSOR SUCCESS: DEACTIVATED"]
<> tlDoEffect (TmWdWdLeaveTerminal "QUIT") <> tlSetStatus (TerminalPressTo "QUIT")
<> tlDoEffect (TmWdWdLeaveTerminal "QUIT")
| notog = | notog =
w & playsound dedumS w
& mcsenslens . proxToggle ?~ False & playsound dedumS
& mctermlens . tmFutureLines & mcsenslens
. proxToggle
?~ False
& mctermlens
. tmFutureLines
.:~ makeTermLine ("SENSOR FAIL: REQUIRES " ++ sensorReqToString pr) .:~ makeTermLine ("SENSOR FAIL: REQUIRES " ++ sensorReqToString pr)
| otherwise = w | otherwise = w
where where
@@ -207,10 +260,14 @@ mcProxTest w = \case
RequireHealth x -> fromMaybe 0 (cr ^? crHP . _HP) >= x RequireHealth x -> fromMaybe 0 (cr ^? crHP . _HP) >= x
RequireEquipment ct -> RequireEquipment ct ->
any any
(\itm -> _itType itm == ct) ( (\itm -> _itType itm == ct)
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr) . (\k -> w ^?! cWorld . lWorld . items . ix k)
RequireDeadCreatures is -> all (\x -> null (x ^? crHP . _HP)) )
(IM.restrictKeys (w ^. cWorld . lWorld . creatures) (IS.fromList is)) (_crInv cr)
RequireDeadCreatures is ->
all
(\x -> null (x ^? crHP . _HP))
(IM.restrictKeys (w ^. cWorld . lWorld . creatures) (IS.fromList is))
where where
cr = you w cr = you w
@@ -219,8 +276,13 @@ senseDamage threshold dt mc =
(cWorld . lWorld . machines . ix mcid %~ upmc) (cWorld . lWorld . machines . ix mcid %~ upmc)
. updatels . updatels
where where
upmc = mcType . _McDamSensor . sensAmount upmc =
%~ min (100 * threshold) . max 0 . (+ newsense) mcType
. _McDamSensor
. sensAmount
%~ min (100 * threshold)
. max 0
. (+ newsense)
mcid = _mcID mc mcid = _mcID mc
newsense newsense
| x > 0 = x | x > 0 = x
+6 -4
View File
@@ -36,7 +36,8 @@ damageStone dm ecw w = case dm of
Piercing _ p t -> Piercing _ p t ->
f dmam $ makeSpark NormalSpark (outTo p t) (rdir p t) f dmam $ makeSpark NormalSpark (outTo p t) (rdir p t)
. makeDustAt Stone 200 (addZ 20 (outTo p t)) . makeDustAt Stone 200 (addZ 20 (outTo p t))
. randsound p [slapS, slap1S] -- . 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)) 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)) Shattering _ p t -> f dmam $ makeDustAt Stone 200 (addZ 20 (outTo p t))
Crushing{} -> f dmam id Crushing{} -> f dmam id
@@ -133,7 +134,8 @@ damageDirt dm _ w =
makeDustAt Dirt 200 (addZ 20 (outTo p t)) makeDustAt Dirt 200 (addZ 20 (outTo p t))
Piercing _ p t -> Piercing _ p t ->
makeDustAt Dirt 200 (addZ 20 (outTo p t)) makeDustAt Dirt 200 (addZ 20 (outTo p t))
. randsound p [slapS, slap1S] -- . randsound p [slapS, slap1S]
. randsound p [slapS, slap1S,slap2S,slap3S,slap4S,slap5S,slap6S,slap7S]
Blunt _ p t -> makeDustAt Dirt 200 (addZ 20 (outTo p t)) Blunt _ p t -> makeDustAt Dirt 200 (addZ 20 (outTo p t))
Shattering _ p t -> makeDustAt Dirt 200 (addZ 20 (outTo p t)) Shattering _ p t -> makeDustAt Dirt 200 (addZ 20 (outTo p t))
Crushing{} -> id Crushing{} -> id
@@ -153,7 +155,7 @@ damageDirt dm _ w =
damageGlass :: Damage -> ECW -> World -> (Int,World) damageGlass :: Damage -> ECW -> World -> (Int,World)
damageGlass dm ecw w = case dm of damageGlass dm ecw w = case dm of
Lasering {} -> f 0 $ id Lasering {} -> f 0 id
Piercing _ p t -> Piercing _ p t ->
f dmam $ makeSpark NormalSpark (outTo p t) (rdir p t) f dmam $ makeSpark NormalSpark (outTo p t) (rdir p t)
-- . makeDustAt Stone 200 (addZ 20 (outTo p t)) -- . makeDustAt Stone 200 (addZ 20 (outTo p t))
@@ -219,7 +221,7 @@ damageGlass dm ecw w = case dm of
damageCrystal :: Damage -> ECW -> World -> (Int,World) damageCrystal :: Damage -> ECW -> World -> (Int,World)
damageCrystal dm ecw w = case dm of damageCrystal dm ecw w = case dm of
Lasering {} -> f $ id Lasering {} -> f id
Piercing _ p t -> Piercing _ p t ->
f $ makeSpark NormalSpark (outTo p t) (rdir p t) f $ makeSpark NormalSpark (outTo p t) (rdir p t)
. randsound p [marimbaC5S,marimbaE5S,marimbaG5S,marimbaB6S] . randsound p [marimbaC5S,marimbaE5S,marimbaG5S,marimbaB6S]
+12 -12
View File
@@ -1,4 +1,4 @@
module Dodge.Material.Sound where module Dodge.Material.Sound (destroyMatS) where
import Dodge.Data.Material import Dodge.Data.Material
import Dodge.SoundLogic.ExternallyGeneratedSounds import Dodge.SoundLogic.ExternallyGeneratedSounds
@@ -16,14 +16,14 @@ destroyMatS mat = case mat of
Flesh -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S] Flesh -> [gut1S, gut2S, gut3S, gut4S, gut5S, gut6S]
ForceField -> [] ForceField -> []
weakenMatS :: Material -> [SoundID] --weakenMatS :: Material -> [SoundID]
weakenMatS mat = case mat of --weakenMatS mat = case mat of
Glass -> [smallGlass1S, smallGlass2S, smallGlass3S, smallGlass4S] -- Glass -> [smallGlass1S, smallGlass2S, smallGlass3S, smallGlass4S]
Crystal -> [smallGlass1S, smallGlass2S, smallGlass3S, smallGlass4S] -- Crystal -> [smallGlass1S, smallGlass2S, smallGlass3S, smallGlass4S]
Stone -> [stone1S, stone2S, stone3S, stone4S, stone5S] -- Stone -> [stone1S, stone2S, stone3S, stone4S, stone5S]
Dirt -> [stone1S, stone3S] -- Dirt -> [stone1S, stone3S]
Wood -> [stone1S, stone3S] -- Wood -> [stone1S, stone3S]
Metal -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S, metal7S] -- Metal -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S, metal7S]
Electronics -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S, metal7S] -- Electronics -> [metal1S, metal2S, metal3S, metal4S, metal5S, metal6S, metal7S]
Flesh -> [blood1S, blood2S, blood3S, blood4S, blood5S, blood6S, blood7S, blood8S] -- Flesh -> [blood1S, blood2S, blood3S, blood4S, blood5S, blood6S, blood7S, blood8S]
ForceField -> [] -- ForceField -> []
+2 -4
View File
@@ -8,9 +8,7 @@ import Control.Monad
import qualified Data.Aeson.Encode.Pretty as AEP import qualified Data.Aeson.Encode.Pretty as AEP
import Data.ByteString.Lazy.Char8 (unpack) import Data.ByteString.Lazy.Char8 (unpack)
import Data.Maybe import Data.Maybe
import qualified Data.Text.IO as TIO
import Dodge.Base.Coordinate import Dodge.Base.Coordinate
import Dodge.Combine.Graph
import Dodge.Concurrent import Dodge.Concurrent
import Dodge.Config import Dodge.Config
import Dodge.Data.Universe import Dodge.Data.Universe
@@ -149,7 +147,7 @@ logOptions =
generateGraphs :: IO () generateGraphs :: IO ()
generateGraphs = do generateGraphs = do
createDirectoryIfMissing True "generated/graph" createDirectoryIfMissing True "generated/graph"
TIO.writeFile "generated/graph/itemCombinations.gv" combinationsDotGraph print "Placeholder for graph generation activated"
gameplayMenu :: Universe -> ScreenLayer gameplayMenu :: Universe -> ScreenLayer
gameplayMenu = titleOptionsMenu "OPTIONS:GAMEPLAY" gameplayMenuOptions gameplayMenu = titleOptionsMenu "OPTIONS:GAMEPLAY" gameplayMenuOptions
@@ -194,7 +192,7 @@ graphicsMenuOptions =
, enumOption gr_shadows_on_clouds "SHADOW DETAIL ON CLOUDS" id , enumOption gr_shadows_on_clouds "SHADOW DETAIL ON CLOUDS" id
, enumOption gr_shadow_size "SHADOW DETAIL" id , enumOption gr_shadow_size "SHADOW DETAIL" id
, enumOption gr_distortions "ENABLE DISTORTIONS" id , enumOption gr_distortions "ENABLE DISTORTIONS" id
, enumOption gr_bloom "ENABLE BLOOM" id -- , enumOption gr_bloom "ENABLE BLOOM" id
, boolOption gr_cloud_shadows "CLOUD SHADOWS TOGGLE" , boolOption gr_cloud_shadows "CLOUD SHADOWS TOGGLE"
, enumOption gr_num_shadow_casters "NUM SHADOW CASTERS" id , enumOption gr_num_shadow_casters "NUM SHADOW CASTERS" id
] ]
+1 -1
View File
@@ -8,7 +8,7 @@ import Picture
wedgeOfThickness :: Float -> Point2 -> Point2 -> Picture wedgeOfThickness :: Float -> Point2 -> Point2 -> Picture
wedgeOfThickness t x y wedgeOfThickness t x y
| x == y = blank | x == y = mempty
| otherwise = fold | otherwise = fold
[uncurryV translate x $ circleSolid (0.5*t) [uncurryV translate x $ circleSolid (0.5*t)
,polygon [x +.+ n x y, x -.- n x y, y] ,polygon [x +.+ n x y, x -.- n x y, y]
+1 -1
View File
@@ -75,7 +75,7 @@ fixedSizePicClampArrow xbord ybord pic p cfig w =
borderPoint = intersectSegPolyFirst campos p bords borderPoint = intersectSegPolyFirst campos p bords
windowPoint = intersectSegPolyFirst campos p winps windowPoint = intersectSegPolyFirst campos p winps
arrowPic = case borderPoint of arrowPic = case borderPoint of
Nothing -> blank Nothing -> mempty
Just bp -> thickLine 5 [bp, fromMaybe p windowPoint] Just bp -> thickLine 5 [bp, fromMaybe p windowPoint]
(V2 x y) = fromMaybe p borderPoint (V2 x y) = fromMaybe p borderPoint
campos = w ^. wCam . camCenter campos = w ^. wCam . camCenter
+5 -10
View File
@@ -62,11 +62,7 @@ triggerSwitch col ps = psPtCont ps (PutTrigger False) $
where where
trigid tp = fromJust $ _plMID tp trigid tp = fromJust $ _plMID tp
putLitButOnPos :: putLitButOnPos :: Color -> PlacementSpot -> (Placement -> Maybe Placement) -> Placement
Color ->
PlacementSpot ->
(Placement -> Maybe Placement) ->
Placement
putLitButOnPos col theps subpl = putLitButOnPos col theps subpl =
plSpot .~ theps $ plSpot .~ theps $
mntLSOn aShape (Just col) ls 0 (V3 0 (-40) 40) $ mntLSOn aShape (Just col) ls 0 (V3 0 (-40) 40) $
@@ -77,20 +73,19 @@ putLitButOnPos col theps subpl =
<&> plSpot <&> plSpot
.~ _plSpot plmnt .~ _plSpot plmnt
where where
changeLight lsid = SetLSCol (V3 0 0.5 0) lsid changeLight = SetLSCol (V3 0 0.5 0)
ls = lsColPosRad (V3 0.5 0 0) (V3 0 0 50) 50 ls = lsColPosRad (V3 0.5 0 0) (V3 0 0 50) 50
-- creates a lit external trigger, passes the trigger placement forward -- creates a lit external trigger, passes the trigger placement forward
extTrigLitPos :: PlacementSpot -> (Placement -> Maybe Placement) -> Placement extTrigLitPos :: PlacementSpot -> (Placement -> Maybe Placement) -> Placement
extTrigLitPos ps f = psPtCont ps (PutTrigger False) $ extTrigLitPos ps f = psPtCont ps (PutTrigger False) $
\tp -> Just $ \tp -> Just $
pContID (ps' tp) (PutLS thels) $ pContID (_plSpot tp) (PutLS thels) $
\lsid -> \lsid ->
Just $ Just $
pContID (ps' tp) (PutMod $ themod lsid tp) $ pContID (_plSpot tp) (PutMod $ themod lsid tp) $
const (f tp) const (f tp)
where where
ps' tp = _plSpot tp
themod lsid tp = themod lsid tp =
ModIDID ModIDID
{ _mdID = 0 { _mdID = 0
@@ -126,6 +121,6 @@ putLitButOnPosExtTrig' col thePS cnt =
.~ _plSpot plmnt .~ _plSpot plmnt
where where
trigid tp = fromJust $ _plMID tp trigid tp = fromJust $ _plMID tp
oneff tid = SetTrigger True tid oneff = SetTrigger True
changeLight = SetLSCol (V3 0 0.5 0) changeLight = SetLSCol (V3 0 0.5 0)
ls = lsColPosRad (V3 0.5 0 0) (V3 0 0 50) 50 ls = lsColPosRad (V3 0.5 0 0) (V3 0 0 50) 50
+5 -23
View File
@@ -12,34 +12,16 @@ import Geometry
damageSensor :: SensorType -> Float -> Maybe Int -> PlacementSpot -> Placement damageSensor :: SensorType -> Float -> Maybe Int -> PlacementSpot -> Placement
damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1) $ damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1) $
\lsid -> psPtJpl ps \lsid ->
$ psPtJpl ps $
PutMachine PutMachine
(reverse $ square wdth) (reverse $ square wdth)
( defaultMachine ( defaultMachine
-- & mcColor .~ yellow
& mcMounts . at OTTrigger .~ mtrid & mcMounts . at OTTrigger .~ mtrid
& mcMounts . at OTLightSource ?~ lsid & mcMounts . at OTLightSource ?~ lsid
& mcType & mcType .~ McDamSensor (DamSensor 0 dt)
.~ McDamSensor
( DamSensor
0
dt
(damageTypeThreshold dt)
)
) )
Nothing Nothing
damageTypeThreshold :: SensorType -> Int lightSensor :: Float -> Maybe Int -> PlacementSpot -> Placement
damageTypeThreshold dt = case dt of
LaserSensor -> 1000
ElectricSensor -> 500
ThermalSensor -> 1000
PhysicalSensor -> 1000
lightSensor ::
Float ->
Maybe Int ->
PlacementSpot ->
Placement
lightSensor = damageSensor LaserSensor lightSensor = damageSensor LaserSensor
+5 -10
View File
@@ -51,16 +51,11 @@ putTerminalFull f mc tm =
putTerminal :: Machine -> Terminal -> Placement putTerminal :: Machine -> Terminal -> Placement
putTerminal = putTerminalFull (\_ _ _ -> Nothing) putTerminal = putTerminalFull (\_ _ _ -> Nothing)
tmMachine :: Machine
tmMachine = defaultMachine & mcType .~ McTerminal & mcHP .~ 100
putMessageTerminal :: Terminal -> Placement putMessageTerminal :: Terminal -> Placement
putMessageTerminal = putMessageTerminal = putTerminal tmMachine
putTerminal $
defaultMachine
& mcType .~ McTerminal
& mcHP .~ 100
putImmediateMessageTerminal :: Terminal -> Placement putImmediateMessageTerminal :: Terminal -> Placement
putImmediateMessageTerminal = putImmediateMessageTerminal = putTerminalImediateAccess tmMachine
putTerminalImediateAccess $
defaultMachine
& mcType .~ McTerminal
& mcHP .~ 100
+12 -9
View File
@@ -6,7 +6,8 @@
-} -}
module Dodge.Placement.PlaceSpot (placeSpot) where module Dodge.Placement.PlaceSpot (placeSpot) where
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
import Data.Bifunctor import Data.Bifunctor
import Data.Foldable import Data.Foldable
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
@@ -57,11 +58,10 @@ placePlainPSSpot w rid plmnt shift = case plmnt ^. plType of
f x gw = fromMaybe gw $ do f x gw = fromMaybe gw $ do
j <- x ^. plExternalID j <- x ^. plExternalID
return $ gw & genPmnt . at j ?~ x return $ gw & genPmnt . at j ?~ x
recrPlace newplmnt w' pl = recrPlace newplmnt w' =
placeSpot placeSpot
rid rid
(w' & genRooms . ix rid . rmPmnts .:~ newplmnt) (w' & genRooms . ix rid . rmPmnts .:~ newplmnt)
pl
-- this should be tidied up -- this should be tidied up
placeSpotUsingLink :: placeSpotUsingLink ::
@@ -142,7 +142,8 @@ placeSpotID rid ps pt w = case pt of
PutNothing -> (0, w) PutNothing -> (0, w)
PutID i -> (i, w) PutID i -> (i, w)
PutWorldUpdate f -> (0, w & f rid ps) PutWorldUpdate f -> (0, w & f rid ps)
PutChasm ps' -> (0, placeChasm w rid ps' $ map doShift ps') PutChasm ps' qs -> (0, placeChasm w rid ps' (map (map doShift) ps')
(foldMap loopPairs (map (map doShift) qs)))
PutLabel{} -> (0, w) PutLabel{} -> (0, w)
where where
p@(V2 px py) = _psPos ps p@(V2 px py) = _psPos ps
@@ -151,13 +152,15 @@ placeSpotID rid ps pt w = case pt of
doShift = shiftPointBy (p, rot) doShift = shiftPointBy (p, rot)
pashift = compP2A (p, rot) pashift = compP2A (p, rot)
placeChasm :: GenWorld -> Int -> [Point2] -> [Point2] -> GenWorld placeChasm :: GenWorld -> Int -> [[Point2]] -> [[Point2]] -> [(Point2,Point2)] -> GenWorld
placeChasm gw rid ps shiftps = placeChasm gw rid ps shiftps cfs =
gw & gwWorld . cWorld . chasms .:~ shiftps gw & gwWorld . cWorld . chasms <>~ shiftps
& genRooms . ix rid . rmPos %~ filter (\rp -> not $ pointInPoly (_rpPos rp) ps) & gwWorld . cWorld . cliffs <>~ cfs
& genRooms . ix rid . rmPos %~ filter (\rp -> not $ any (pointInPoly (_rpPos rp)) ps)
& gwWorld %~ f & gwWorld %~ f
where where
f w = foldl' g w (loopPairs shiftps) --f w = foldl' g w (loopPairs shiftps)
f w = foldl' g w cfs
g w (x, y) = obstructPathsCrossing (S.singleton ChasmObstacle) x y w g w (x, y) = obstructPathsCrossing (S.singleton ChasmObstacle) x y w
placeWallPoly :: [Point2] -> Wall -> World -> World placeWallPoly :: [Point2] -> Wall -> World -> World
+2 -2
View File
@@ -87,8 +87,8 @@ plLineBlock basePane blwidth a b gw =
$ upperBox Medium Typical 3 $ upperBox Medium Typical 3
[a + x + n - midp, a + x - (n + midp), b - (n + x + midp), b + n - (x + midp)] [a + x + n - midp, a + x - (n + midp), b - (n + x + midp), b + n - (x + midp)]
) )
midp = (0.5 * (a + b)) midp = 0.5 * (a + b)
x = (blwidth + 1) *^ (normalize $ a - b) x = (blwidth + 1) *^ normalize (a - b)
n = vNormal x n = vNormal x
insertBlock (i, p) = insertBlock (i, p) =
insertWalls (makeWallAt p i) insertWalls (makeWallAt p i)
+8 -1
View File
@@ -14,6 +14,7 @@ module Dodge.PlacementSpot (
isUnusedLnk, isUnusedLnk,
isInLnk, isInLnk,
isOutLnk, isOutLnk,
isOutLnkNum,
unusedSpotNearInLink, unusedSpotNearInLink,
randDirPS, randDirPS,
unusedSpotAwayFromInLink, unusedSpotAwayFromInLink,
@@ -38,7 +39,8 @@ module Dodge.PlacementSpot (
) where ) where
import Control.Lens import Control.Lens
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
import Data.Bifunctor import Data.Bifunctor
import Data.Maybe import Data.Maybe
import qualified Data.Set as S import qualified Data.Set as S
@@ -168,6 +170,11 @@ isOutLnk rp = case _rpType rp of
UsedOutLink{} -> null $ _rpPlacementUse rp UsedOutLink{} -> null $ _rpPlacementUse rp
_ -> False _ -> False
isOutLnkNum :: Int -> RoomPos -> Bool
isOutLnkNum i rp = case _rpType rp of
UsedOutLink{_rplsChildNum = j} | j == i -> null $ _rpPlacementUse rp
_ -> False
useUnusedLnk :: PlacementSpot useUnusedLnk :: PlacementSpot
useUnusedLnk = rprBool isUnusedLnk useUnusedLnk = rprBool isUnusedLnk
+81 -30
View File
@@ -1,8 +1,7 @@
--{-# LANGUAGE LambdaCase #-} -- {-# LANGUAGE LambdaCase #-}
--{-# OPTIONS_GHC -Wno-unused-imports #-} -- {-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.Projectile.Update (updateProjectile) where module Dodge.Projectile.Update (updateProjectile) where
import Dodge.WorldEvent.Cloud
import Control.Monad import Control.Monad
import Data.List (delete) import Data.List (delete)
import Data.Maybe import Data.Maybe
@@ -14,7 +13,8 @@ import Dodge.Item.Location
import Dodge.Movement.Turn import Dodge.Movement.Turn
import Dodge.Payload import Dodge.Payload
import Dodge.SoundLogic import Dodge.SoundLogic
--import Dodge.WorldEvent.Cloud import Dodge.WorldEvent.Cloud
-- import Dodge.WorldEvent.Cloud
import Dodge.WorldEvent.Sound import Dodge.WorldEvent.Sound
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -50,7 +50,7 @@ applyGravityPU pj
shellExplosionCheck :: Projectile -> World -> World shellExplosionCheck :: Projectile -> World -> World
shellExplosionCheck pj shellExplosionCheck pj
| RetiredProjectile <- pj ^. pjType | RetiredProjectile <- pj ^. pjType
, timeout = , timeout =
destroyProjectile pj destroyProjectile pj
| timeout = explodeShell pj | timeout = explodeShell pj
| otherwise = id | otherwise = id
@@ -63,7 +63,7 @@ shellHitWall p n wl pj
(topj . pjType .~ Grenade (GStuckWall (wl ^. wlStructure))) (topj . pjType .~ Grenade (GStuckWall (wl ^. wlStructure)))
. stickHitSound pj . stickHitSound pj
| Just x <- pj ^? pjType . gnHitEffect . bounceTolerance | Just x <- pj ^? pjType . gnHitEffect . bounceTolerance
, abs (dot (pj ^. pjVel) (normalize n)) < x = , abs (dot (pj ^. pjVel) (normalize n)) < x =
(topj . pjVel %~ reflectInNormal n) (topj . pjVel %~ reflectInNormal n)
. (topj . pjPos .~ p + normalize n) . (topj . pjPos .~ p + normalize n)
. bounceSound pj . bounceSound pj
@@ -76,7 +76,10 @@ bounceSound pj = soundStart (ShellSound (pj ^. pjID)) (pj ^. pjPos . _xy) click1
stickHitSound :: Projectile -> World -> World stickHitSound :: Projectile -> World -> World
stickHitSound pj = stickHitSound pj =
soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos . _xy) soundOriginIDsAt
(ShellSound (pj ^. pjID))
[slapS, slap1S, slap2S, slap3S, slap4S, slap5S, slap6S, slap7S]
(pj ^. pjPos . _xy)
shellHitCreature :: Point3 -> Creature -> Projectile -> World -> World shellHitCreature :: Point3 -> Creature -> Projectile -> World -> World
shellHitCreature p cr pj shellHitCreature p cr pj
@@ -89,7 +92,7 @@ shellHitCreature p cr pj
gren = gren =
GStuckCreature GStuckCreature
(cr ^. crID) (cr ^. crID)
(rotate3z (- cr ^. crDir) (p - cr ^. crPos)) (rotate3z (-cr ^. crDir) (p - cr ^. crPos))
(pj ^. pjDir - cr ^. crDir) (pj ^. pjDir - cr ^. crDir)
shellHitFloor :: Point3 -> Projectile -> World -> World shellHitFloor :: Point3 -> Projectile -> World -> World
@@ -129,8 +132,15 @@ tryThrust pj = fromMaybe id $ do
doThrust :: Projectile -> Maybe RocketSmoke -> World -> World doThrust :: Projectile -> Maybe RocketSmoke -> World -> World
doThrust pj smoke w = doThrust pj smoke w =
w w
& randGen .~ g & randGen
& cWorld . lWorld . projectiles . ix i . pjVel . _xy %~ (\v -> accel + frict *^ v) .~ g
& cWorld
. lWorld
. projectiles
. ix i
. pjVel
. _xy
%~ (\v -> accel + frict *^ v)
& soundContinue (ShellSound i) (ep ^. _xy) missileLaunchS (Just 1) & soundContinue (ShellSound i) (ep ^. _xy) missileLaunchS (Just 1)
& makeFlamelet & makeFlamelet
(sp - 0.5 *^ vel) (sp - 0.5 *^ vel)
@@ -157,15 +167,28 @@ doThrust pj smoke w =
doBarrelSpin :: Int -> Float -> Projectile -> World -> World doBarrelSpin :: Int -> Float -> Projectile -> World -> World
doBarrelSpin cid i pj w = doBarrelSpin cid i pj w =
w & cWorld . lWorld . projectiles . ix pjid . pjSpin .~ newSpin w
& cWorld . lWorld . projectiles . ix pjid . pjBarrelSpin .~ Nothing & cWorld
. lWorld
. projectiles
. ix pjid
. pjSpin
.~ newSpin
& cWorld
. lWorld
. projectiles
. ix pjid
. pjBarrelSpin
.~ Nothing
where where
pjid = _pjID pj pjid = _pjID pj
dir = argV $ pj ^. pjVel . _xy dir = argV $ pj ^. pjVel . _xy
newSpin = case w ^? cWorld . lWorld . creatures . ix cid of newSpin = case w ^? cWorld . lWorld . creatures . ix cid of
Just cr -> Just cr ->
negate $ negate $
min 0.2 $ max (-0.2) $ normalizeAnglePi (dir - _crDir cr) / spinFactor min 0.2 $
max (-0.2) $
normalizeAnglePi (dir - _crDir cr) / spinFactor
_ -> 0 _ -> 0
spinFactor = 5 * (6 - i) spinFactor = 5 * (6 - i)
@@ -176,17 +199,25 @@ pjRemoteSetDirection ph pj w = case ph of
| lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem | lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
== lw ^? items . ix (_unNInt screenid) . itLocation . ilInvID -> == lw ^? items . ix (_unNInt screenid) . itLocation . ilInvID ->
w w
& pjlens . pjDir .~ mousedir & pjlens
& pjlens . pjSpin .~ 0.5 * diffAngles mousedir pjdir . pjDir
.~ mousedir
& pjlens
. pjSpin
.~ 0.5
* diffAngles mousedir pjdir
HomeUsingTargeting itid HomeUsingTargeting itid
| Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just -> | Just tp <- w ^? pointerToItemID itid . itTargeting . itTgPos . _Just ->
w w
& pjlens . pjDir %~ turnTo 0.2 (pj ^. pjPos . _xy) tp & pjlens
& pjlens . pjSpin . pjDir
.~ 0.5 %~ turnTo 0.2 (pj ^. pjPos . _xy) tp
* diffAngles & pjlens
(turnTo 0.2 (pj ^. pjPos . _xy) tp pjdir) . pjSpin
pjdir .~ 0.5
* diffAngles
(turnTo 0.2 (pj ^. pjPos . _xy) tp pjdir)
pjdir
_ -> w _ -> w
where where
pjdir = pj ^. pjDir pjdir = pj ^. pjDir
@@ -201,9 +232,17 @@ moveStuckGrenade cid poff d pj w = fromMaybe (w & pjlens . pjType .~ Grenade GSt
cdir = cr ^. crDir cdir = cr ^. crDir
return $ return $
w w
& pjlens . pjPos . _xy .~ xyV3 (cpos + rotate3z cdir poff) & pjlens
& pjlens . pjDir .~ d + cdir . pjPos
& pjlens . pjVel .~ (cpos - cr ^. crOldPos) . _xy
.~ xyV3 (cpos + rotate3z cdir poff)
& pjlens
. pjDir
.~ d
+ cdir
& pjlens
. pjVel
.~ (cpos - cr ^. crOldPos)
where where
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID) pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
@@ -219,9 +258,15 @@ moveProjectile pj w
(_, Just (_, OChasmWall)) -> w & pjlens . pjTimer .~ 0 -- no stick or bounce for now (_, Just (_, OChasmWall)) -> w & pjlens . pjTimer .~ 0 -- no stick or bounce for now
_ -> _ ->
w w
& pjlens . pjSpin *~ 0.99 & pjlens
& pjlens . pjPos +~ _pjVel pj . pjSpin
& pjlens . pjDir +~ _pjSpin pj *~ 0.99
& pjlens
. pjPos
+~ _pjVel pj
& pjlens
. pjDir
+~ _pjSpin pj
where where
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID) pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
sp = _pjPos pj sp = _pjPos pj
@@ -229,9 +274,15 @@ moveProjectile pj w
explodeShell :: Projectile -> World -> World explodeShell :: Projectile -> World -> World
explodeShell pj w = explodeShell pj w =
w w
& pjlens . pjType .~ RetiredProjectile & pjlens
& pjlens . pjVel .~ 0 . pjType
& pjlens . pjTimer .~ 30 .~ RetiredProjectile
& pjlens
. pjVel
.~ 0
& pjlens
. pjTimer
.~ 30
& usePayload (_pjPayload pj) (pj ^. pjPos) (pj ^. pjVel) & usePayload (_pjPayload pj) (pj ^. pjPos) (pj ^. pjVel)
& stopSoundFrom (ShellSound pjid) & stopSoundFrom (ShellSound pjid)
& updatedetonator & updatedetonator
+2 -1
View File
@@ -1,6 +1,7 @@
module Dodge.RandImpulse where module Dodge.RandImpulse where
import Control.Monad.State --import Control.Monad.State
import Control.Monad.Trans.State.Lazy
import Dodge.Data.ActionPlan import Dodge.Data.ActionPlan
import RandomHelp import RandomHelp

Some files were not shown because too many files have changed in this diff Show More