Simplify analyser machines somewhat
This commit is contained in:
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
@@ -57,4 +57,4 @@ screenBox w = rectNSWE hh (- hh) (- hw) hw
|
|||||||
hh = halfHeight w
|
hh = halfHeight w
|
||||||
|
|
||||||
pointIsOnScreen :: Config -> Camera -> Point2 -> Bool
|
pointIsOnScreen :: Config -> Camera -> Point2 -> Bool
|
||||||
pointIsOnScreen cfig w p = pointInPolygon p $ screenPolygon cfig w
|
pointIsOnScreen cfig = flip pointInPoly . screenPolygon cfig
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import Dodge.Data.Machine.Sensor
|
|||||||
import Dodge.Data.Material
|
import Dodge.Data.Material
|
||||||
import Dodge.Data.ObjectType
|
import Dodge.Data.ObjectType
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Sound.Data
|
|
||||||
|
|
||||||
data Machine = Machine
|
data Machine = Machine
|
||||||
{ _mcID :: Int
|
{ _mcID :: Int
|
||||||
@@ -39,8 +38,7 @@ data Machine = Machine
|
|||||||
, _mcDamage :: [Damage]
|
, _mcDamage :: [Damage]
|
||||||
, _mcType :: MachineType
|
, _mcType :: MachineType
|
||||||
, _mcMounts :: M.Map ObjectType Int
|
, _mcMounts :: M.Map ObjectType Int
|
||||||
, _mcName :: String
|
-- , _mcCloseSound :: Maybe SoundID
|
||||||
, _mcCloseSound :: Maybe SoundID
|
|
||||||
, _mcWidth :: Float
|
, _mcWidth :: Float
|
||||||
}
|
}
|
||||||
--deriving (Eq, Show, Read) --, Generic)
|
--deriving (Eq, Show, Read) --, Generic)
|
||||||
@@ -49,7 +47,8 @@ data Machine = Machine
|
|||||||
data MachineType
|
data MachineType
|
||||||
= McStatic
|
= McStatic
|
||||||
| McTerminal
|
| McTerminal
|
||||||
| McSensor Sensor
|
| McDamSensor DamageSensor
|
||||||
|
| McProxSensor ProximitySensor
|
||||||
| McTurret {_mctTurret :: Turret}
|
| McTurret {_mctTurret :: Turret}
|
||||||
--deriving (Eq, Show, Read) --, Generic)
|
--deriving (Eq, Show, Read) --, Generic)
|
||||||
--hderiving (Eq, Show, Read) --Generic, Flat)
|
--hderiving (Eq, Show, Read) --Generic, Flat)
|
||||||
|
|||||||
@@ -17,19 +17,17 @@ import Dodge.Data.GenParams
|
|||||||
import Dodge.Data.Item.Combine
|
import Dodge.Data.Item.Combine
|
||||||
import Dodge.Data.Machine.Sensor.Type
|
import Dodge.Data.Machine.Sensor.Type
|
||||||
|
|
||||||
data Sensor
|
data DamageSensor = DamSensor
|
||||||
= DamageSensor
|
|
||||||
{ _sensToggle :: Bool
|
{ _sensToggle :: Bool
|
||||||
, _sensAmount :: Int
|
, _sensAmount :: Int
|
||||||
, _sensType :: SensorType
|
, _sensType :: SensorType
|
||||||
, _sensDraw :: (PaletteColor, DecorationShape)
|
, _sensDraw :: (PaletteColor, DecorationShape)
|
||||||
, _sensThreshold :: Int
|
, _sensThreshold :: Int
|
||||||
}
|
}
|
||||||
| ProximitySensor
|
|
||||||
{ _proxStatus :: CloseToggle
|
data ProximitySensor = ProxSensor
|
||||||
, _proxDist :: Float
|
{ _proxRequirement :: ProximityRequirement
|
||||||
, _proxRequirement :: ProximityRequirement
|
, _proxToggle :: Bool
|
||||||
, _sensToggle :: Bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||||
@@ -40,15 +38,9 @@ data ProximityRequirement
|
|||||||
| RequireNoItems {_proxNoItems :: [Point2]}
|
| RequireNoItems {_proxNoItems :: [Point2]}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
makeLenses ''DamageSensor
|
||||||
|
makeLenses ''ProximitySensor
|
||||||
data CloseToggle = NotClose | IsClose
|
|
||||||
deriving (Show)
|
|
||||||
|
|
||||||
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
|
||||||
|
|
||||||
makeLenses ''Sensor
|
|
||||||
makeLenses ''ProximityRequirement
|
makeLenses ''ProximityRequirement
|
||||||
deriveJSON defaultOptions ''ProximityRequirement
|
deriveJSON defaultOptions ''ProximityRequirement
|
||||||
deriveJSON defaultOptions ''CloseToggle
|
deriveJSON defaultOptions ''ProximitySensor
|
||||||
deriveJSON defaultOptions ''Sensor
|
deriveJSON defaultOptions ''DamageSensor
|
||||||
|
|||||||
@@ -58,14 +58,14 @@ outsideScreenPolygon cfig w = [tr, tl, bl, br]
|
|||||||
-- towards the center of sight
|
-- towards the center of sight
|
||||||
lineOnScreenCone :: Config -> World -> Point2 -> Point2 -> Bool
|
lineOnScreenCone :: Config -> World -> Point2 -> Point2 -> Bool
|
||||||
lineOnScreenCone cfig w p1 p2 =
|
lineOnScreenCone cfig w p1 p2 =
|
||||||
pointInPolygon p1 sp
|
pointInPoly p1 sp
|
||||||
|| pointInPolygon p2 sp
|
|| pointInPoly p2 sp
|
||||||
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
|| any (isJust . uncurry (intersectSegSeg p1 p2)) sps
|
||||||
where
|
where
|
||||||
sp' = screenPolygon cfig (w ^. wCam)
|
sp' = screenPolygon cfig (w ^. wCam)
|
||||||
vp = w ^. wCam . camViewFrom
|
vp = w ^. wCam . camViewFrom
|
||||||
sp
|
sp
|
||||||
| pointInPolygon vp sp' = sp'
|
| pointInPoly vp sp' = sp'
|
||||||
| otherwise = orderPolygon ((w ^. wCam . camViewFrom) : sp')
|
| otherwise = orderPolygon ((w ^. wCam . camViewFrom) : sp')
|
||||||
sps = zip sp (tail sp ++ [head sp])
|
sps = zip sp (tail sp ++ [head sp])
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ drawPathing cfig w =
|
|||||||
|
|
||||||
edgeToPic :: [Point2] -> PathEdge -> Picture
|
edgeToPic :: [Point2] -> PathEdge -> Picture
|
||||||
edgeToPic poly pe
|
edgeToPic poly pe
|
||||||
| not (pointInPolygon sp poly) && not (pointInPolygon ep poly) = mempty
|
| not (pointInPoly sp poly) && not (pointInPoly ep poly) = mempty
|
||||||
| otherwise = drawPathEdge pe
|
| otherwise = drawPathEdge pe
|
||||||
where
|
where
|
||||||
sp = _peStart pe
|
sp = _peStart pe
|
||||||
|
|||||||
@@ -39,9 +39,8 @@ defaultMachine =
|
|||||||
, _mcMaterial = Electronics
|
, _mcMaterial = Electronics
|
||||||
, _mcDamage = []
|
, _mcDamage = []
|
||||||
, _mcType = McStatic
|
, _mcType = McStatic
|
||||||
, _mcName = ""
|
|
||||||
, _mcMounts = mempty
|
, _mcMounts = mempty
|
||||||
, _mcCloseSound = Nothing
|
-- , _mcCloseSound = Nothing
|
||||||
, _mcWidth = 10
|
, _mcWidth = 10
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,11 +63,9 @@ defaultPP =
|
|||||||
, _ppText = "Pressure plate"
|
, _ppText = "Pressure plate"
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultProximitySensor :: Sensor
|
defaultProximitySensor :: ProximitySensor
|
||||||
defaultProximitySensor =
|
defaultProximitySensor =
|
||||||
ProximitySensor
|
ProxSensor
|
||||||
{ _proxStatus = NotClose
|
{ _proxRequirement = RequireHealth 0
|
||||||
, _proxDist = 40
|
, _proxToggle = False
|
||||||
, _proxRequirement = RequireHealth 0
|
|
||||||
, _sensToggle = False
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,16 @@ drawMachine lw mc = case _mcType mc of
|
|||||||
McStatic -> mempty
|
McStatic -> mempty
|
||||||
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
|
||||||
McSensor se -> drawBaseMachine 25 mc <> drawSensor se mc
|
McDamSensor se -> drawBaseMachine 25 mc <> drawDamSensor se mc
|
||||||
|
McProxSensor se -> drawBaseMachine 25 mc <> drawProxSensor se mc
|
||||||
|
|
||||||
drawSensor :: Sensor -> Machine -> SPic
|
drawDamSensor :: DamageSensor -> Machine -> SPic
|
||||||
drawSensor sens = case sens of
|
drawDamSensor sens = case sens of
|
||||||
DamageSensor{_sensDraw = pcds} -> sensorSPic pcds
|
DamSensor{_sensDraw = pcds} -> sensorSPic pcds
|
||||||
ProximitySensor{} -> const mempty
|
|
||||||
|
drawProxSensor :: ProximitySensor -> Machine -> SPic
|
||||||
|
drawProxSensor sens = case sens of
|
||||||
|
ProxSensor{} -> const mempty
|
||||||
|
|
||||||
terminalSPic :: LWorld -> Machine -> SPic
|
terminalSPic :: LWorld -> Machine -> SPic
|
||||||
terminalSPic lw = noPic . terminalShape lw
|
terminalSPic lw = noPic . terminalShape lw
|
||||||
|
|||||||
+42
-42
@@ -24,14 +24,15 @@ updateMachine mc
|
|||||||
| otherwise =
|
| otherwise =
|
||||||
mcApplyDamage (_mcDamage mc) mc
|
mcApplyDamage (_mcDamage mc) mc
|
||||||
. mcPlaySound mc
|
. mcPlaySound mc
|
||||||
. mcTypeUpdate mc
|
. mcTypeUpdate mc (_mcType mc)
|
||||||
|
|
||||||
mcTypeUpdate :: Machine -> World -> World
|
mcTypeUpdate :: Machine -> MachineType -> World -> World
|
||||||
mcTypeUpdate mc = case mc ^. mcType of
|
mcTypeUpdate mc = \case
|
||||||
McStatic -> id
|
McStatic -> id
|
||||||
McTerminal -> terminalScreenGlow mc
|
McTerminal -> terminalScreenGlow mc
|
||||||
McTurret tu -> updateTurret (_tuTurnSpeed tu) mc
|
McTurret tu -> updateTurret (_tuTurnSpeed tu) mc
|
||||||
McSensor se -> mcSensorTriggerUpdate se mc . mcSensorUpdate se mc
|
McDamSensor se -> mcDamSensorTriggerUpdate se mc . mcDamSensorUpdate se mc
|
||||||
|
McProxSensor se -> mcProxSensorTriggerUpdate se mc . mcProxSensorUpdate se mc
|
||||||
|
|
||||||
terminalScreenGlow :: Machine -> World -> World
|
terminalScreenGlow :: Machine -> World -> World
|
||||||
terminalScreenGlow mc w = fromMaybe w $ do
|
terminalScreenGlow mc w = fromMaybe w $ do
|
||||||
@@ -93,29 +94,33 @@ mcUseItem mc w = fromMaybe w $ do
|
|||||||
guard (_tuFireTime tu > 0)
|
guard (_tuFireTime tu > 0)
|
||||||
return $ mcUseHeld hit it mc w
|
return $ mcUseHeld hit it mc w
|
||||||
|
|
||||||
mcSensorTriggerUpdate :: Sensor -> Machine -> World -> World
|
mcDamSensorTriggerUpdate :: DamageSensor -> Machine -> World -> World
|
||||||
mcSensorTriggerUpdate se mc = fromMaybe id $ do
|
mcDamSensorTriggerUpdate se mc = fromMaybe id $ do
|
||||||
trid <- mc ^? mcMounts . ix OTTrigger
|
trid <- mc ^? mcMounts . ix OTTrigger
|
||||||
bval <- mcTriggerVal se
|
bval <- mcTriggerVal se
|
||||||
return $ cWorld . lWorld . triggers . ix trid ||~ bval
|
return $ cWorld . lWorld . triggers . ix trid ||~ bval
|
||||||
|
|
||||||
mcTriggerVal :: Sensor -> Maybe Bool
|
mcProxSensorTriggerUpdate :: ProximitySensor -> Machine -> World -> World
|
||||||
mcTriggerVal se = case se of
|
mcProxSensorTriggerUpdate se mc = fromMaybe id $ do
|
||||||
ProximitySensor{} -> se ^? sensToggle
|
trid <- mc ^? mcMounts . ix OTTrigger
|
||||||
DamageSensor{} -> Just $ _sensAmount se > _sensThreshold se
|
bval <- se ^? proxToggle
|
||||||
|
return $ cWorld . lWorld . triggers . at trid ?~ bval
|
||||||
|
|
||||||
|
mcTriggerVal :: DamageSensor -> Maybe Bool
|
||||||
|
mcTriggerVal se = Just $ _sensAmount se > _sensThreshold se
|
||||||
|
|
||||||
mcPlaySound :: Machine -> World -> World
|
mcPlaySound :: Machine -> World -> World
|
||||||
mcPlaySound mc w = case _mcCloseSound mc of
|
mcPlaySound mc w = case _mcType mc of
|
||||||
Just sid
|
McTerminal | d < 100 ->
|
||||||
| d < 100 ->
|
soundContinueVol (1 -0.01 * d)
|
||||||
soundContinueVol (1 -0.01 * d) (MachineSound mid) (_mcPos mc) sid (Just 2) w
|
(MachineSound mid) (_mcPos mc) fridgeHumS (Just 2) w
|
||||||
_ -> w
|
_ -> w
|
||||||
where
|
where
|
||||||
d = max 0 (dist (_crPos $ you w) (_mcPos mc) - 100)
|
d = max 0 (dist (_crPos $ you w) (_mcPos mc) - 100)
|
||||||
mid = _mcID mc
|
mid = _mcID mc
|
||||||
|
|
||||||
mcApplyDamage :: [Damage] -> Machine -> World -> World
|
mcApplyDamage :: [Damage] -> Machine -> World -> World
|
||||||
mcApplyDamage ds mc = case mc ^? mcType . _McSensor of
|
mcApplyDamage ds mc = case mc ^? mcType . _McDamSensor of
|
||||||
Nothing ->
|
Nothing ->
|
||||||
mcpointer
|
mcpointer
|
||||||
%~ ((mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds)))
|
%~ ((mcDamage .~ []) . (mcHP -~ sum (map _dmAmount ds)))
|
||||||
@@ -125,36 +130,31 @@ mcApplyDamage ds mc = case mc ^? mcType . _McSensor of
|
|||||||
where
|
where
|
||||||
mcpointer = cWorld . lWorld . machines . ix (_mcID mc)
|
mcpointer = cWorld . lWorld . machines . ix (_mcID mc)
|
||||||
|
|
||||||
mcSensorUpdate :: Sensor -> Machine -> World -> World
|
mcDamSensorUpdate :: DamageSensor -> Machine -> World -> World
|
||||||
mcSensorUpdate se mc w = case se of
|
mcDamSensorUpdate se mc w = senseDamage (_sensThreshold se) (_sensType se) mc w
|
||||||
s@DamageSensor{} -> senseDamage (_sensThreshold se) (_sensType s) mc w
|
|
||||||
ProximitySensor {_proxRequirement = x} -> mcProximitySensorUpdate mc x w
|
|
||||||
|
|
||||||
mcProximitySensorUpdate :: Machine -> ProximityRequirement -> World -> World
|
mcProxSensorUpdate :: ProximitySensor -> Machine -> World -> World
|
||||||
mcProximitySensorUpdate mc x w = case ( _proxStatus sens
|
mcProxSensorUpdate se mc = case se ^. proxRequirement of
|
||||||
, _sensToggle sens
|
RequireNoItems xs -> id
|
||||||
, mcProxTest mc w x
|
_ -> mcProximitySensorUpdate mc se
|
||||||
, dist (_crPos ycr) (_mcPos mc) < _proxDist sens
|
|
||||||
) of
|
mcProximitySensorUpdate :: Machine -> ProximitySensor -> World -> World
|
||||||
(_, True, _, _) -> w
|
mcProximitySensorUpdate mc sens w
|
||||||
(_, False, True, True) ->
|
| sens ^. proxToggle || dist (_crPos ycr) (_mcPos mc) > 40 = w
|
||||||
|
| mcProxTest mc w (sens ^. proxRequirement) =
|
||||||
w
|
w
|
||||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . sensToggle .~ True
|
& mcsenslens . proxToggle .~ True
|
||||||
& playsound dedaS
|
& playsound dedaS
|
||||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
& mctermlens . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS!"
|
||||||
& cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal) . tmFutureLines .:~ makeTermLine "SENSOR SUCCESS!"
|
| otherwise = w & playsound dedumS
|
||||||
(NotClose, _, False, True) ->
|
& mctermlens . tmFutureLines
|
||||||
w & playsound dedumS
|
.:~ makeTermLine ("SENSOR FAIL: REQUIRES "
|
||||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ IsClose
|
++ sensorReqToString (mc ^?! mcType . _McProxSensor . proxRequirement))
|
||||||
& cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal) . tmFutureLines
|
|
||||||
.:~ makeTermLine ("SENSOR FAIL: REQUIRES " ++ sensorReqToString (mc ^?! mcType . _McSensor . proxRequirement))
|
|
||||||
(_, _, _, False) ->
|
|
||||||
w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McSensor . proxStatus .~ NotClose
|
|
||||||
_ -> w
|
|
||||||
where
|
where
|
||||||
|
mctermlens = cWorld . lWorld . terminals . ix (mc ^?! mcMounts . ix OTTerminal)
|
||||||
|
mcsenslens = cWorld . lWorld . machines . ix (_mcID mc) . mcType . _McProxSensor
|
||||||
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
||||||
ycr = you w
|
ycr = you w
|
||||||
sens = mc ^?! mcType . _McSensor
|
|
||||||
|
|
||||||
sensorReqToString :: ProximityRequirement -> String
|
sensorReqToString :: ProximityRequirement -> String
|
||||||
sensorReqToString = \case
|
sensorReqToString = \case
|
||||||
@@ -170,7 +170,7 @@ mcProxTest mc w = \case
|
|||||||
(\itm -> _itType itm == ct)
|
(\itm -> _itType itm == ct)
|
||||||
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
|
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
|
||||||
RequireNoItems ps -> (w ^?! cWorld . lWorld . creatures . ix 0 . crInv == mempty)
|
RequireNoItems ps -> (w ^?! cWorld . lWorld . creatures . ix 0 . crInv == mempty)
|
||||||
&& not (any ((`pointInPolygon` f ps) . _flItPos) (w ^. cWorld . lWorld . floorItems) )
|
&& not (any ((`pointInPoly` f ps) . _flItPos) (w ^. cWorld . lWorld . floorItems) )
|
||||||
where
|
where
|
||||||
cr = you w
|
cr = you w
|
||||||
f = fmap ((+ _mcPos mc) . rotateV (_mcDir mc))
|
f = fmap ((+ _mcPos mc) . rotateV (_mcDir mc))
|
||||||
@@ -180,7 +180,7 @@ senseDamage threshold dt mc =
|
|||||||
(cWorld . lWorld . machines . ix mcid %~ upmc)
|
(cWorld . lWorld . machines . ix mcid %~ upmc)
|
||||||
. updatels
|
. updatels
|
||||||
where
|
where
|
||||||
upmc = mcType . _McSensor . sensAmount %~ min (100 * threshold) . max 0 . (+ newsense)
|
upmc = mcType . _McDamSensor . sensAmount %~ min (100 * threshold) . max 0 . (+ newsense)
|
||||||
mcid = _mcID mc
|
mcid = _mcID mc
|
||||||
newsense
|
newsense
|
||||||
| x > 0 = x
|
| x > 0 = x
|
||||||
@@ -188,7 +188,7 @@ senseDamage threshold dt mc =
|
|||||||
where
|
where
|
||||||
f = sensorTypeDamages dt
|
f = sensorTypeDamages dt
|
||||||
x = sum . map _dmAmount $ filter f (_mcDamage mc)
|
x = sum . map _dmAmount $ filter f (_mcDamage mc)
|
||||||
ni = fromIntegral (mc ^?! mcType . _McSensor . sensAmount) / fromIntegral threshold
|
ni = fromIntegral (mc ^?! mcType . _McDamSensor . sensAmount) / fromIntegral threshold
|
||||||
updatels = fromMaybe id $ do
|
updatels = fromMaybe id $ do
|
||||||
lsid <- mc ^? mcMounts . ix OTLightSource
|
lsid <- mc ^? mcMounts . ix OTLightSource
|
||||||
return $ cWorld . lWorld . lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
|
return $ cWorld . lWorld . lightSources . ix lsid . lsParam . lsCol .~ V3 ni ni ni
|
||||||
|
|||||||
@@ -20,33 +20,4 @@ analyser proxreq pslight psmc = extTrigLitPos pslight $ \tp ->
|
|||||||
defaultMachine & mcColor .~ aquamarine
|
defaultMachine & mcColor .~ aquamarine
|
||||||
& mcType .~ McTerminal
|
& mcType .~ McTerminal
|
||||||
& mcHP .~ 100
|
& mcHP .~ 100
|
||||||
& mcType .~ McSensor (defaultProximitySensor{_proxRequirement = proxreq})
|
& mcType .~ McProxSensor (defaultProximitySensor{_proxRequirement = proxreq})
|
||||||
|
|
||||||
--this can probably be deleted
|
|
||||||
--mcProximitySensorUpdate :: Machine -> World -> World
|
|
||||||
--mcProximitySensorUpdate mc w = case
|
|
||||||
-- (_proxStatus sens
|
|
||||||
-- , _sensToggle sens
|
|
||||||
-- , mcProxTest mc w
|
|
||||||
-- , dist (_crPos ycr) (_mcPos mc) < _proxDist sens) of
|
|
||||||
-- (_,True,_,_) -> w
|
|
||||||
-- (_,False,True,True) -> w
|
|
||||||
-- & machines . ix (_mcID mc) . mcSensor . sensToggle .~ True
|
|
||||||
-- & playsound dedaS
|
|
||||||
-- & machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
|
||||||
-- (NotClose,_,False,True) -> w & playsound dedumS
|
|
||||||
-- & machines . ix (_mcID mc) . mcSensor . proxStatus .~ IsClose
|
|
||||||
-- (_,_,_,False) -> w & machines . ix (_mcID mc) . mcSensor . proxStatus .~ NotClose
|
|
||||||
-- _ -> w
|
|
||||||
-- where
|
|
||||||
-- playsound sid = soundContinue (MachineAltSound (_mcID mc)) (_mcPos mc) sid Nothing
|
|
||||||
-- ycr = you w
|
|
||||||
-- sens = _mcSensor mc
|
|
||||||
--
|
|
||||||
--mcProxTest :: Machine -> World -> Bool
|
|
||||||
--mcProxTest mc w = case mc ^? mcSensor . proxRequirement of
|
|
||||||
-- Just (RequireHealth x) -> _crHP cr >= x
|
|
||||||
-- Just (RequireEquipment ct) -> any (\itm -> _iyBase (_itType itm) == ct) (_crInv cr)
|
|
||||||
-- _ -> False
|
|
||||||
-- where
|
|
||||||
-- cr = you w
|
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1) $
|
|||||||
& mcMounts . at OTTrigger .~ mtrid
|
& mcMounts . at OTTrigger .~ mtrid
|
||||||
& mcMounts . at OTLightSource ?~ lsid
|
& mcMounts . at OTLightSource ?~ lsid
|
||||||
& mcType
|
& mcType
|
||||||
.~ McSensor
|
.~ McDamSensor
|
||||||
( DamageSensor
|
( DamSensor
|
||||||
False
|
False
|
||||||
0
|
0
|
||||||
dt
|
dt
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import Data.Maybe
|
|||||||
import Dodge.Data.GenWorld
|
import Dodge.Data.GenWorld
|
||||||
import Dodge.Default
|
import Dodge.Default
|
||||||
import Dodge.LevelGen.PlacementHelper
|
import Dodge.LevelGen.PlacementHelper
|
||||||
import Dodge.SoundLogic
|
|
||||||
import Dodge.WorldEffect
|
import Dodge.WorldEffect
|
||||||
import Geometry
|
import Geometry
|
||||||
import LensHelp
|
import LensHelp
|
||||||
@@ -36,7 +35,6 @@ putTerminalFull f col mc tm =
|
|||||||
(reverse $ square 10)
|
(reverse $ square 10)
|
||||||
( mc & mcMounts . at OTButton ?~ fromJust (_plMID btpl)
|
( mc & mcMounts . at OTButton ?~ fromJust (_plMID btpl)
|
||||||
& mcMounts . at OTTerminal .~ _plMID tmpl
|
& mcMounts . at OTTerminal .~ _plMID tmpl
|
||||||
& mcCloseSound ?~ fridgeHumS
|
|
||||||
)
|
)
|
||||||
defaultSensorWall
|
defaultSensorWall
|
||||||
Nothing
|
Nothing
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ lightsToRender cfig campos w = take (fromEnum $ cfig ^. graphics_num_shadow_cas
|
|||||||
cbox = campos ^. camBoundBox
|
cbox = campos ^. camBoundBox
|
||||||
cpos = campos ^. camCenter
|
cpos = campos ^. camCenter
|
||||||
getlsparam ls
|
getlsparam ls
|
||||||
| not (pointInPolygon lpos cbox) && extraculltest = Nothing
|
| not (pointInPoly lpos cbox) && extraculltest = Nothing
|
||||||
| otherwise = Just (_lsPos ls, rad ^ (2 :: Int), _lsCol ls)
|
| otherwise = Just (_lsPos ls, rad ^ (2 :: Int), _lsCol ls)
|
||||||
where
|
where
|
||||||
lpos = xyV3 $ _lsPos ls
|
lpos = xyV3 $ _lsPos ls
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ shiftDraw' fpos fdir fdraw x =
|
|||||||
|
|
||||||
cullPoint :: Config -> World -> Point2 -> Bool
|
cullPoint :: Config -> World -> Point2 -> Bool
|
||||||
cullPoint cfig w p
|
cullPoint cfig w p
|
||||||
| debugOn Close_shape_culling cfig = pointInPolygon p (w ^. wCam . camBoundBox)
|
| debugOn Close_shape_culling cfig = pointInPoly p (w ^. wCam . camBoundBox)
|
||||||
| otherwise = dist (w ^. wCam . camCenter) p < (w ^. wCam . camViewDistance)
|
| otherwise = dist (w ^. wCam . camCenter) p < (w ^. wCam . camViewDistance)
|
||||||
|
|
||||||
extraPics :: Config -> Universe -> Picture
|
extraPics :: Config -> Universe -> Picture
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ decontamRoom :: State LayoutVars Room
|
|||||||
decontamRoom = do
|
decontamRoom = do
|
||||||
return $
|
return $
|
||||||
defaultRoom
|
defaultRoom
|
||||||
& rmPolys .~ [rectNSWE 100 0 0 40, switchcut]
|
& rmPolys .~ cutps
|
||||||
& rmLinks .~ muout lnks ++ muin [last lnks]
|
& rmLinks .~ muout lnks ++ muin [last lnks]
|
||||||
& rmPath .~ foldMap doublePairSet [(V2 20 95, V2 20 45), (V2 20 45, V2 20 5)]
|
& rmPath .~ foldMap doublePairSet [(V2 20 95, V2 20 45), (V2 20 45, V2 20 5)]
|
||||||
& rmPmnts
|
& rmPmnts
|
||||||
@@ -40,11 +40,13 @@ decontamRoom = do
|
|||||||
\_ _ -> Just $ putDoubleDoor DoorObstacle thewall (WdBlBtOn btid) (V2 0 80) (V2 40 80) 2
|
\_ _ -> Just $ putDoubleDoor DoorObstacle thewall (WdBlBtOn btid) (V2 0 80) (V2 40 80) 2
|
||||||
, invisibleWall $ rectNSWE 60 40 (-40) (-30)
|
, invisibleWall $ rectNSWE 60 40 (-40) (-30)
|
||||||
, spanLightI (V2 (-2) 30) (V2 (-2) 70)
|
, spanLightI (V2 (-2) 30) (V2 (-2) 70)
|
||||||
--, analyser (RequireHealth 100) (PS 50 0) (PS (V2 70 50) 0)
|
, analyser (RequireNoItems $ ps) (PS 50 0) (PS mcpos 0)
|
||||||
, analyser (RequireNoItems $ square 50) (PS 50 0) (PS (V2 70 50) 0)
|
|
||||||
]
|
]
|
||||||
& rmBound .~ [rectNSWE 75 15 0 40, switchcut]
|
& rmBound .~ [rectNSWE 75 15 0 40, switchcut]
|
||||||
where
|
where
|
||||||
|
mcpos = V2 70 50
|
||||||
|
cutps = [rectNSWE 100 0 0 40, switchcut]
|
||||||
|
ps = (\p -> p - mcpos) <$> orderPolygon (concat cutps)
|
||||||
thewall = switchWallCol col
|
thewall = switchWallCol col
|
||||||
switchcut = rectNSWE 65 35 (-40) 80
|
switchcut = rectNSWE 65 35 (-40) 80
|
||||||
lnks =
|
lnks =
|
||||||
|
|||||||
@@ -44,15 +44,9 @@ linksAndPath lnks subpth = S.fromList subpth <> foldMap linkClosest lnks
|
|||||||
linksAndPath' :: [RoomLink] -> [(Point2, Point2)] -> S.Set (Point2, Point2)
|
linksAndPath' :: [RoomLink] -> [(Point2, Point2)] -> S.Set (Point2, Point2)
|
||||||
linksAndPath' = linksAndPath . map lnkPosDir
|
linksAndPath' = linksAndPath . map lnkPosDir
|
||||||
|
|
||||||
testCrossWalls ::
|
testCrossWalls :: [(Point2, Point2)] -> (Point2, Point2) -> Bool
|
||||||
[(Point2, Point2)] ->
|
|
||||||
(Point2, Point2) ->
|
|
||||||
Bool
|
|
||||||
testCrossWalls wls (a, b) = not $ any (isJust . uncurry (intersectSegSeg a b)) wls
|
testCrossWalls wls (a, b) = not $ any (isJust . uncurry (intersectSegSeg a b)) wls
|
||||||
|
|
||||||
--extra test whether both members of the path edge are in some poly
|
--extra test whether both members of the path edge are in some poly
|
||||||
pairInPolys ::
|
pairInPolys :: [[Point2]] -> (Point2, Point2) -> Bool
|
||||||
[[Point2]] ->
|
pairInPolys polys (a, b) = any (pointInPoly a) polys && any (pointInPoly b) polys
|
||||||
(Point2, Point2) ->
|
|
||||||
Bool
|
|
||||||
pairInPolys polys (a, b) = any (pointInPolygon a) polys && any (pointInPolygon b) polys
|
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ errorPointInPolygon :: Int -> Point2 -> [Point2] -> Bool
|
|||||||
errorPointInPolygon !i !p xs
|
errorPointInPolygon !i !p xs
|
||||||
| length xs == 1 = error "one point polygon"
|
| length xs == 1 = error "one point polygon"
|
||||||
| length xs == 2 = error "two point polygon"
|
| length xs == 2 = error "two point polygon"
|
||||||
| nub xs == xs = pointInPolygon p xs
|
| nub xs == xs = pointInPoly p xs
|
||||||
| otherwise = error $ "errorPointInPolygon " ++ show i
|
| otherwise = error $ "errorPointInPolygon " ++ show i
|
||||||
|
|
||||||
-- | Debug version of 'normalizeV'.
|
-- | Debug version of 'normalizeV'.
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import Data.Aeson
|
|||||||
import Data.Aeson.TH
|
import Data.Aeson.TH
|
||||||
import Geometry.Data
|
import Geometry.Data
|
||||||
import Geometry.Intersect
|
import Geometry.Intersect
|
||||||
import Geometry.LHS
|
|
||||||
import Geometry.Polygon
|
import Geometry.Polygon
|
||||||
import Geometry.Vector
|
import Geometry.Vector
|
||||||
|
|
||||||
@@ -59,8 +58,8 @@ convexPolysOverlap cp1 cp2 =
|
|||||||
-- | Test whether two polygons intersect or if one is contained in the other.
|
-- | Test whether two polygons intersect or if one is contained in the other.
|
||||||
polyPointsOverlap :: [Point2] -> [Point2] -> Bool
|
polyPointsOverlap :: [Point2] -> [Point2] -> Bool
|
||||||
polyPointsOverlap (p : ps) (q : qs) =
|
polyPointsOverlap (p : ps) (q : qs) =
|
||||||
pointInPolygon p (q : qs)
|
pointInPoly p (q : qs)
|
||||||
|| pointInPolygon q (p : ps)
|
|| pointInPoly q (p : ps)
|
||||||
|| polyPointsIntersect (p : ps) (q : qs)
|
|| polyPointsIntersect (p : ps) (q : qs)
|
||||||
polyPointsOverlap _ _ = False
|
polyPointsOverlap _ _ = False
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ pointInOrOnPolygon _ _ = undefined
|
|||||||
{- | Test whether a point is strictly inside a polygon.
|
{- | Test whether a point is strictly inside a polygon.
|
||||||
Supposes the points in the polygon are listed in anticlockwise order.
|
Supposes the points in the polygon are listed in anticlockwise order.
|
||||||
-}
|
-}
|
||||||
pointInPolygon :: Point2 -> [Point2] -> Bool
|
pointInPoly :: Point2 -> [Point2] -> Bool
|
||||||
pointInPolygon !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x])
|
pointInPoly !p (x : xs) = all (\l -> uncurry isLHS l p) $ zip (x : xs) (xs ++ [x])
|
||||||
pointInPolygon _ [] = False
|
pointInPoly _ [] = False
|
||||||
|
|
||||||
circInPolygon :: Point2 -> Float -> [Point2] -> Bool
|
circInPolygon :: Point2 -> Float -> [Point2] -> Bool
|
||||||
circInPolygon !p !r (x : xs) = all f $ zip (x : xs) (xs ++ [x])
|
circInPolygon !p !r (x : xs) = all f $ zip (x : xs) (xs ++ [x])
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import Geometry
|
|||||||
|
|
||||||
gridInPolygon :: Float -> [Point2] -> [Point2]
|
gridInPolygon :: Float -> [Point2] -> [Point2]
|
||||||
gridInPolygon gap ps =
|
gridInPolygon gap ps =
|
||||||
filter (`pointInPolygon` ps)
|
filter (`pointInPoly` ps)
|
||||||
. maybe [] (boundedGrid gap)
|
. maybe [] (boundedGrid gap)
|
||||||
. boundPoints
|
. boundPoints
|
||||||
$ ps
|
$ ps
|
||||||
|
|||||||
Reference in New Issue
Block a user