jak-project/goal_src/jak1/levels/sunken/floating-launcher.gc
Tyler Wilding c162c66118
g/j1: Cleanup all main issues in the formatter and format all of goal_src/jak1 (#3535)
This PR does two main things:
1. Work through the main low-hanging fruit issues in the formatter
keeping it from feeling mature and usable
2. Iterate and prove that point by formatting all of the Jak 1 code
base. **This has removed around 100K lines in total.**
- The decompiler will now format it's results for jak 1 to keep things
from drifting back to where they were. This is controlled by a new
config flag `format_code`.

How am I confident this hasn't broken anything?:
- I compiled the entire project and stored it's `out/jak1/obj` files
separately
- I then recompiled the project after formatting and wrote a script that
md5's each file and compares it (`compare-compilation-outputs.py`
- The results (eventually) were the same:

![Screenshot 2024-05-25
132900](https://github.com/open-goal/jak-project/assets/13153231/015e6f20-8d19-49b7-9951-97fa88ddc6c2)
> This proves that the only difference before and after is non-critical
whitespace for all code/macros that is actually in use.

I'm still aware of improvements that could be made to the formatter, as
well as general optimization of it's performance. But in general these
are for rare or non-critical situations in my opinion and I'll work
through them before doing Jak 2. The vast majority looks great and is
working properly at this point. Those known issues are the following if
you are curious:

![image](https://github.com/open-goal/jak-project/assets/13153231/0edfaba1-6d36-40f5-ab23-0642209867c4)
2024-06-05 22:17:31 -04:00

99 lines
3.9 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
(bundles "SUN.DGO")
(require "engine/geometry/path.gc")
(require "engine/common-obs/baseplat.gc")
;; DECOMP BEGINS
(deftype floating-launcher (baseplat)
((trigger-height float)
(launcher (pointer launcher)))
(:states
floating-launcher-idle
floating-launcher-lowering
floating-launcher-ready))
(defskelgroup *floating-launcher-sg*
floating-launcher
floating-launcher-lod0-jg
floating-launcher-idle-ja
((floating-launcher-lod0-mg (meters 999999)))
:bounds (static-spherem 0 0 0 5))
(defstate floating-launcher-idle (floating-launcher)
:event plat-event
:trans
(behavior ()
(plat-trans)
(when (< (vector-xz-length (vector-! (new 'stack-no-clear 'vector) (target-pos 0) (-> self root trans))) 81920.0)
(if (and (>= (-> (target-pos 0) y) (-> self trigger-height))
(logtest? (-> *target* control status) (cshape-moving-flags onground)))
(go floating-launcher-lowering))))
:code
(behavior ()
(transform-post)
(suspend)
(transform-post)
(suspend)
(loop
(suspend)))
:post plat-post)
(defstate floating-launcher-lowering (floating-launcher)
:event plat-event
:trans plat-trans
:code
(behavior ()
(let ((a0-1 (entity-actor-lookup (-> self entity) 'alt-actor 0))) (if a0-1 (entity-birth-no-kill a0-1)))
(let ((f30-0 1.0))
(while (!= f30-0 0.0)
(set! f30-0 (seek f30-0 0.0 (seconds-per-frame)))
(eval-path-curve-div! (-> self path) (-> self basetrans) f30-0 'interp)
(set! (-> self launcher 0 root trans quad) (-> self basetrans quad))
(update-transforms! (-> self launcher 0 root))
(suspend)))
(eval-path-curve-div! (-> self path) (-> self basetrans) 0.0 'interp)
(set! (-> self launcher 0 root trans quad) (-> self basetrans quad))
(update-transforms! (-> self launcher 0 root))
(go floating-launcher-ready))
:post plat-post)
(defstate floating-launcher-ready (floating-launcher)
:event plat-event
:trans plat-trans
:code plat-code
:post plat-post)
(defmethod init-from-entity! ((this floating-launcher) (arg0 entity-actor))
(logior! (-> this mask) (process-mask platform))
(let ((s4-0 (new 'process 'collide-shape-moving this (collide-list-enum hit-by-player))))
(set! (-> s4-0 dynam) (copy *standard-dynamics* 'process))
(set! (-> s4-0 reaction) default-collision-reaction)
(set! (-> s4-0 no-reaction) (the-as (function collide-shape-moving collide-shape-intersect vector vector none) nothing))
(alloc-riders s4-0 1)
(let ((s3-0 (new 'process 'collide-shape-prim-mesh s4-0 (the-as uint 0) (the-as uint 0))))
(set! (-> s3-0 prim-core collide-as) (collide-kind ground-object))
(set! (-> s3-0 collide-with) (collide-kind target))
(set! (-> s3-0 prim-core action) (collide-action solid rider-plat-sticky))
(set! (-> s3-0 prim-core offense) (collide-offense indestructible))
(set! (-> s3-0 transform-index) 0)
(set-vector! (-> s3-0 local-sphere) 0.0 0.0 0.0 11468.8)
(set-root-prim! s4-0 s3-0))
(set! (-> s4-0 nav-radius) (* 0.75 (-> s4-0 root-prim local-sphere w)))
(backup-collide-with-as s4-0)
(set! (-> this root) s4-0))
(process-drawable-from-entity! this arg0)
(set! (-> this path) (new 'process 'path-control this 'path 0.0))
(logior! (-> this path flags) (path-control-flag display draw-line draw-point draw-text))
(eval-path-curve-div! (-> this path) (-> this root trans) 1.0 'interp)
(let ((f30-0 (res-lump-float arg0 'spring-height :default 163840.0)))
(set! (-> this launcher) (process-spawn launcher (-> this root trans) f30-0 0 81920.0 :to this)))
(initialize-skeleton this *floating-launcher-sg* '())
(logior! (-> this skel status) (janim-status inited))
(update-transforms! (-> this root))
(baseplat-method-21 this)
(set! (-> this trigger-height) (res-lump-float arg0 'trigger-height))
(go floating-launcher-idle)
(none))