Defunction-ify item modules, requires more cleanup

This commit is contained in:
2022-06-08 12:28:11 +01:00
parent d91a53f76c
commit bcbfd7d2fa
48 changed files with 762 additions and 740 deletions
+64
View File
@@ -0,0 +1,64 @@
module Dodge.Combine.Module where
import Dodge.Data
import Dodge.Tesla
import Dodge.Particle.HitEffect.ExpireAndDamage
import Dodge.WorldEvent.SpawnParticle
import Dodge.Particle.Damage
import Dodge.IncBall
import Dodge.Item.Weapon.ExtraEffect
import Dodge.Item.Weapon.Launcher
import Dodge.Item.Weapon.TriggerType
import LensHelp
import Geometry
--import Dodge.Item.Weapon.BatteryGuns
import Dodge.Beam
import Dodge.Base.Coordinate
import Data.Maybe
fromModuleType :: ItemModuleType -> ItemModule
fromModuleType imt = case imt of
EMPTYMODULE -> ItemModule ["EMPTYMODULE"] 1 id
DRUMMAG -> mod "+DRUM MAG" (itConsumption . laMax .~ 45)
BELTMAG -> mod "+BELT FEED" (itConsumption . laMax .~ 150)
MAGNETMAG -> mod "+MAGNET FEED" (itUse . useDelay . rateMax .~ 4)
INCENDBUL -> mod "+INCENDIARY" (f $ expireAndDamage $ spawnAtBulDams incBall)
BOUNCEBUL -> mod "+BOUNCE" (f $ expireAndDamage bounceBulDams)
STATICBUL -> mod "+STATIC" (f $ expireAndDamage $ spawnAtBulDams aStaticBall)
CONCUSBUL -> mod "+CONCUSS" (f $ expireAndDamage $ spawnAtBulDams concBall)
TARGCR -> mod "+CREATURETARGETING" (itTargeting .~ targetRBCreature)
TARGLAS -> mod "+LASERTARGETING" (itTargeting .~ targetLaser)
TARGPOS -> mod "+POSTIONALTARGETING" (itTargeting .~ targetRBPress)
MAGNETTRAJ -> mod "+MAGNETTRAJECTORY"
( (itConsumption . laType . amBulTraj .~ MagnetTrajectory)
. (itConsumption . laType . amBulVel .~ V2 10 0)
)
FLECHETRAJ -> mod "+FLECHETTETRAJECTORY"
(itConsumption . laType . amBulTraj .~ FlechetteTrajectory)
BEZIERTRAJ -> mod "+BEZIERTRAJECTORY"
(itConsumption . laType . amBulTraj .~ BezierTrajectory)
INCENDLAS -> mod "+INCENDIARY" (itParams . lasBeam .~ BeamCombine flameBeamCombine)
SPLITLAS -> mod "+SPLIT" (itParams . lasBeam .~ BeamCombine splitBeamCombine)
STATICLAS -> mod "+STATIC"
( (itParams . lasBeam .~ BeamCombine teslaBeamCombine)
. (itParams . subParams ?~ teslaParams)
)
WEPTELE -> mod "+DIRECTEDTELE" makeDirectedTele
LAUNCHHOME -> mod "+TARGET HOMING" (itConsumption . laType . amPjCreation .~ fireTrackingShell)
EXTRABATTERY -> mod "+BATTERY" (itConsumption . laMax +~ 1000)
where
mod str func = ItemModule [str] 1 func
f ameff = itConsumption . laType . amBulEff .~ ameff
makeDirectedTele it = it
& itTargeting .~ targetRBPress
& itUse . useMods .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset
& itUse . useAim . aimZoom . itZoomFac .~ 1
& itUse . useAim . aimRange .~ 0
-- a better option would be to involve a "scope" centered on the firing
-- position
directedTelPos it cr w = (p,a)
where
p = fromMaybe (_crPos cr) $ it ^? itTargeting . tgPos . _Just
a = argV (mouseWorldPos w -.- p)
--amod cts str func = (cts,ItemModule [str] 1 func)