Start refactor storing items in single intmap, done turrets

More checks required
This commit is contained in:
2025-08-24 11:53:21 +01:00
parent 7336177edf
commit c38d03165f
22 changed files with 642 additions and 269 deletions
+1
View File
@@ -35,6 +35,7 @@ damageSensor dt wdth mtrid ps = pContID ps (PutLS $ lsPosCol (V3 0 0 30) 0.1) $
)
)
defaultSensorWall
Nothing
)
damageTypeThreshold :: SensorType -> Int
+1
View File
@@ -34,6 +34,7 @@ putTerminalFull f col mc tm =
& mcCloseSound ?~ fridgeHumS
)
defaultSensorWall
Nothing
)
$ \mcpl -> Just $ pt0 (PutWorldUpdate $ const (setids tmpl btpl mcpl)) (\_ -> f tmpl btpl mcpl)
where
+4 -2
View File
@@ -19,6 +19,7 @@ putTurret itm rotSpeed =
& mcHP .~ 50000
)
defaultMachineWall
(Just itm)
putLasTurret :: Float -> Placement
putLasTurret rotSpeed =
@@ -31,14 +32,15 @@ putLasTurret rotSpeed =
& mcHP .~ 50000
)
defaultMachineWall
(Just laser)
turret :: Item -> MachineType
turret wp = lasTurret & mctTurret . tuWeapon .~ wp
turret _ = lasTurret
lasTurret :: MachineType
lasTurret = McTurret $
Turret
{ _tuWeapon = laser
{ _tuWeapon = 0
, _tuTurnSpeed = 0.1
, _tuFireTime = 0
, _tuDir = 0
+27 -3
View File
@@ -121,7 +121,7 @@ placeSpotID' ps pt w = case pt of
-- w
PutCrit cr -> plNewUpID (cWorld . lWorld . creatures) crID (mvCr p rot cr) w
PutForeground fs -> plNewUpID (cWorld . lWorld . foregroundShapes) fsID (mvFS p rot fs) w
PutMachine pps mc wl -> plMachine (map doShift pps) mc wl p rot w
PutMachine pps mc wl mitm -> plMachine (map doShift pps) mc wl mitm p rot w
PutLS ls -> plNewUpID (cWorld . lWorld . lightSources) lsID (mvLS p' rot ls) w
PutPPlate pp -> plNewUpID (cWorld . lWorld . pressPlates) ppID (mvPP p rot pp) w
RandPS rgn -> evaluateRandPS rgn ps w
@@ -193,8 +193,32 @@ mvCr p rot cr = cr{_crPos = p, _crOldPos = p, _crDir = rot}
mvFS :: Point2 -> Float -> ForegroundShape -> ForegroundShape
mvFS p a = (fsDir +~ a) . (fsPos %~ ((p +.+) . rotateV a))
plMachine :: [Point2] -> Machine -> Wall -> Point2 -> Float -> World -> (Int, World)
plMachine wallpoly mc wl p rot gw =
plMachine :: [Point2] -> Machine -> Wall -> Maybe Item -> Point2 -> Float -> World -> (Int, World)
plMachine wallpoly mc wl mitm = case mitm of
Nothing -> plMachine' wallpoly mc wl
Just itm -> plTurret wallpoly mc wl itm
plTurret :: [Point2] -> Machine -> Wall -> Item -> Point2 -> Float -> World -> (Int, World)
plTurret wallpoly mc wl itm p rot gw =
( mcid
, gw & cWorld . lWorld . machines %~ addMc
& cWorld . lWorld . walls %~ placeMachineWalls wl col wallpoly mcid wlid
& cWorld . lWorld . items . at itid ?~ itm'
& cWorld . lWorld . itemLocations . at itid ?~ OnTurret mcid
)
where
itm' = itm & itID .~ NInt itid
& itLocation .~ OnTurret mcid
itid = IM.newKey $ gw ^. cWorld . lWorld . itemLocations
col = _mcColor mc
mcid = IM.newKey $ gw ^. cWorld . lWorld . machines
wlid = IM.newKey $ gw ^. cWorld . lWorld . walls
wlids = IS.fromList [wlid .. wlid + length wallpoly - 1]
addMc = IM.insert mcid (mc{_mcPos = p, _mcDir = rot, _mcID = mcid, _mcWallIDs = wlids}
& mcType . mctTurret . tuWeapon .~ itid)
plMachine' :: [Point2] -> Machine -> Wall -> Point2 -> Float -> World -> (Int, World)
plMachine' wallpoly mc wl p rot gw =
( mcid
, gw & cWorld . lWorld . machines %~ addMc
& cWorld . lWorld . walls %~ placeMachineWalls wl col wallpoly mcid wlid