Cleanup
This commit is contained in:
+91
-15
@@ -1,9 +1,13 @@
|
||||
module Dodge.Luse where
|
||||
import Dodge.Data
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
|
||||
import Dodge.Base
|
||||
import Data.Maybe
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Item.Equipment.Booster
|
||||
import Dodge.Data
|
||||
import Dodge.Default.Creature
|
||||
import Dodge.Item.Weapon.TriggerType
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
|
||||
useL :: Luse -> Item -> Creature -> World -> World
|
||||
@@ -17,25 +21,97 @@ useL lu = case lu of
|
||||
|
||||
useRewindGun :: Item -> Creature -> World -> World
|
||||
useRewindGun _ _ w = case _rewindWorlds (_cWorld w) of
|
||||
[w'] -> rewindusing w' [w']
|
||||
(w':ws) -> rewindusing w' ws
|
||||
_ -> w
|
||||
[w'] -> rewindusing w' [w']
|
||||
(w' : ws) -> rewindusing w' ws
|
||||
_ -> w
|
||||
where
|
||||
rewindusing :: CWorld -> [CWorld] -> World
|
||||
rewindusing w' ws = w
|
||||
& cWorld . maybeWorld .~ Just' ( w'
|
||||
& rewindWorlds .~ ws
|
||||
)
|
||||
rewindusing w' ws =
|
||||
w
|
||||
& cWorld . maybeWorld
|
||||
.~ Just'
|
||||
( w'
|
||||
& rewindWorlds .~ ws
|
||||
)
|
||||
|
||||
-- be careful changing this around; potential problems include updating the
|
||||
-- creature but using the old crInvSel value
|
||||
-- 22.05.23 this has been changed from using invids to items
|
||||
useShrinkGun :: Item -> Creature -> World -> World
|
||||
useShrinkGun it cr w = if _atBool $ _itAttachment it
|
||||
then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropExcept cr invid
|
||||
else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr
|
||||
useShrinkGun it cr w =
|
||||
if _atBool $ _itAttachment it
|
||||
then tryResize 0.5 $ stripNoItems cr . f False UndroppableIdentified . dropExcept cr invid
|
||||
else tryResize 1 $ f True Uncursed . setMinInvSize defaultInvSize cr
|
||||
where
|
||||
invid = _ipInvID $ _itPos it
|
||||
tryResize x g = maybe w g $ sizeSelf x cr w
|
||||
f isInUse cstatus = cWorld . creatures . ix (_crID cr) . crInv . ix invid %~
|
||||
( (itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus) )
|
||||
f isInUse cstatus =
|
||||
cWorld . creatures . ix (_crID cr) . crInv . ix invid
|
||||
%~ ((itAttachment . atBool .~ isInUse) . (itCurseStatus .~ cstatus))
|
||||
|
||||
boostSelfL ::
|
||||
-- | boost amount
|
||||
Float ->
|
||||
Item ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
boostSelfL x itm cr w = case boostPoint x cr w of
|
||||
Left p -> crEff p (itUse . leftConsumption . arLoaded .~ 0)
|
||||
Right p -> crEff p (itUse . leftConsumption . arLoaded -~ 1)
|
||||
where
|
||||
invid = _ipInvID $ _itPos itm
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
r = _crRad cr
|
||||
pid =
|
||||
fromMaybe
|
||||
(IM.newKey $ _props (_cWorld w))
|
||||
(cr ^? crInv . ix invid . itAttachment . atInt)
|
||||
crEff p ammoEff =
|
||||
addBoostShockwave pid p (r *.* normalizeV (p -.- cpos)) w
|
||||
& cWorld . creatures . ix cid
|
||||
%~ (crPos .~ p)
|
||||
. ( crInv . ix invid
|
||||
%~ ammoEff
|
||||
. (itEffect . ieCounter .~ 1)
|
||||
. (itAttachment .~ AttachInt pid)
|
||||
)
|
||||
|
||||
-- | Move a creature towards the mouse position, with shockwave
|
||||
boostPoint ::
|
||||
-- | boost amount
|
||||
Float ->
|
||||
Creature ->
|
||||
World ->
|
||||
Either Point2 Point2
|
||||
boostPoint x cr w = case mayp2 of
|
||||
Nothing -> Right p1
|
||||
Just p2 -> Left $ mvPointTowardAtSpeed r cpos $ fst p2
|
||||
where
|
||||
cpos = _crPos cr
|
||||
r = 1.5 * _crRad cr
|
||||
p1 = cpos +.+ x *.* squashNormalizeV (mouseWorldPos w -.- cpos)
|
||||
mayp2 = bouncePoint (const True) 1 cpos p1 w
|
||||
|
||||
addBoostShockwave ::
|
||||
Int ->
|
||||
Point2 ->
|
||||
Point2 ->
|
||||
World ->
|
||||
World
|
||||
addBoostShockwave pjid p v w =
|
||||
w & cWorld . linearShockwaves
|
||||
%~ IM.insertWith f pjid thePJ
|
||||
where
|
||||
thePJ =
|
||||
LinearShockwave
|
||||
{ _lwPos = p
|
||||
, _lwID = pjid
|
||||
, _lwPoints = [(p, v)]
|
||||
, _lwTimer = maxT
|
||||
}
|
||||
f newVal oldVal = newVal & lwPoints %~ (++ _lwPoints oldVal)
|
||||
|
||||
maxT :: Int
|
||||
maxT = 20
|
||||
|
||||
Reference in New Issue
Block a user