Commit before removing pressplates

This commit is contained in:
2025-10-12 20:59:57 +01:00
parent 5e5b24cad0
commit 408b39f160
2 changed files with 15 additions and 16 deletions
+11 -13
View File
@@ -204,25 +204,23 @@ pjRemoteSetDirection ph pj w = case ph of
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID) pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
moveStuckGrenade :: Int -> Point3 -> Float -> Projectile -> World -> World moveStuckGrenade :: Int -> Point3 -> Float -> Projectile -> World -> World
moveStuckGrenade cid poff d pj w moveStuckGrenade cid poff d pj w = fromMaybe (w & pjlens . pjType .~ Grenade GStick) $ do
| Just cr <- w ^? cWorld . lWorld . creatures . ix cid = cr <- w ^? cWorld . lWorld . creatures . ix cid
let cpos = cr ^. crPos let cpos = cr ^. crPos
cdir = cr ^. crDir cdir = cr ^. crDir
vel = cpos - cr ^. crOldPos return $
in w w
& pjlens . pjPos . _xy .~ xyV3 (cpos + rotate3z cdir poff) & pjlens . pjPos . _xy .~ xyV3 (cpos + rotate3z cdir poff)
& pjlens . pjDir .~ d + cdir & pjlens . pjDir .~ d + cdir
& pjlens . pjVel .~ vel & pjlens . pjVel .~ (cpos - cr ^. crOldPos)
| otherwise =
w & pjlens . pjType .~ Grenade GStick
where where
pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID) pjlens = cWorld . lWorld . projectiles . ix (pj ^. pjID)
moveProjectile :: Projectile -> World -> World moveProjectile :: Projectile -> World -> World
moveProjectile pj w moveProjectile pj w
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w | Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
| Just (GStuckCreature crid poff d) <- pj ^? pjType . gnHitEffect = | Just (GStuckCreature cid poff d) <- pj ^? pjType . gnHitEffect =
moveStuckGrenade crid poff d pj w moveStuckGrenade cid poff d pj w
| otherwise = case collide3 sp (sp + _pjVel pj) w of | otherwise = case collide3 sp (sp + _pjVel pj) w of
(p, Just (n, OWall wl)) -> shellHitWall p n wl pj w (p, Just (n, OWall wl)) -> shellHitWall p n wl pj w
(p, Just (_, OFloor)) -> shellHitFloor p pj w (p, Just (_, OFloor)) -> shellHitFloor p pj w
+4 -3
View File
@@ -9,6 +9,7 @@ import Geometry.Data
import Geometry.LHS import Geometry.LHS
import Geometry.Vector import Geometry.Vector
import ListHelp import ListHelp
import Linear
-- | Draw an anticlockwise rectangle based on maximal N S W E values. -- | Draw an anticlockwise rectangle based on maximal N S W E values.
rectNSWE :: Float -> Float -> Float -> Float -> [Point2] rectNSWE :: Float -> Float -> Float -> Float -> [Point2]
@@ -153,7 +154,7 @@ convexHullSafe _ = []
grahamScan :: [Point2] -> [Point2] grahamScan :: [Point2] -> [Point2]
grahamScan = foldr push [] grahamScan = foldr push []
where where
push point stack = grahamEliminate (point : stack) push p stack = grahamEliminate (p : stack)
{- | Remove second element if top three elements are not counterclockwise. {- | Remove second element if top three elements are not counterclockwise.
Repeat if necessary. See Repeat if necessary. See
@@ -164,8 +165,8 @@ grahamEliminate (x : y : z : xs)
| not $ isLHS x y z = grahamEliminate (x : z : xs) | not $ isLHS x y z = grahamEliminate (x : z : xs)
grahamEliminate xs = xs grahamEliminate xs = xs
centroid :: Foldable t => t Point2 -> Point2 centroid :: (Num (f a),Functor f, Fractional a,Foldable t) => t (f a) -> f a
centroid = L.fold $ (/) <$> L.Fold (+.+) (V2 0 0) id <*> L.genericLength centroid = L.fold $ (^/) <$> L.Fold (+) 0 id <*> L.genericLength
centroidNum :: (Fractional a, Foldable t) => t a -> a centroidNum :: (Fractional a, Foldable t) => t a -> a
centroidNum = L.fold $ (/) <$> L.Fold (+) 0 id <*> L.genericLength centroidNum = L.fold $ (/) <$> L.Fold (+) 0 id <*> L.genericLength