Commit before attempting to add concurrency to loop

This commit is contained in:
2022-08-16 08:00:47 +01:00
parent 9e3097d681
commit 919a179283
12 changed files with 129 additions and 138 deletions
+5 -21
View File
@@ -1,27 +1,11 @@
module Dodge.Item.Location where
module Dodge.Item.Location (
pointerToItemLocation,
getItem,
pointerToItem,
) where
import Control.Lens
import Data.Maybe
import Dodge.Data.World
import qualified IntMapHelp as IM
setHeldItemLoc :: Creature -> World -> World
setHeldItemLoc cr = fst . getHeldItemLoc cr
getHeldItemLoc :: Creature -> World -> (World, Int)
getHeldItemLoc cr w = case maybeitid of
Nothing ->
( w & cWorld . creatures . ix cid . crInv . ix j . itID .~ newitid
& cWorld . itemLocations %~ IM.insert newitid (InInv cid j)
, itid
)
_ -> (w, itid)
where
cid = _crID cr
j = crSel cr
newitid = IM.newKey $ _itemLocations (_cWorld w)
maybeitid = cr ^? crInv . ix j . itID
itid = fromMaybe newitid maybeitid
getItem :: Int -> World -> Maybe Item
getItem itid w = do
+2 -3
View File
@@ -14,7 +14,6 @@ import Dodge.Base
import Dodge.Beam
import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.Item.Location
import Dodge.Item.Weapon.LaserPath
import Geometry
import qualified IntMapHelp as IM
@@ -157,11 +156,11 @@ circleLaser it cr w
shootDualLaser :: Item -> Creature -> World -> World
shootDualLaser it cr w =
w'
w
& cWorld . newBeams . positronBeams .:~ dualRayAt (_lasBeam $ _itParams it) itid w (_lasColor $ _itParams it) dam phasev posl dirl
& cWorld . newBeams . electronBeams .:~ basicBeamAt itid w (_lasColor2 $ _itParams it) dam phasev posr dirr
where
(w', itid) = getHeldItemLoc cr w
itid = _itID it
dir = _crDir cr
pos = _crPos cr +.+ aimlength *.* unitVectorAtAngle dir
aimlength = aimingMuzzlePos cr it