Skip to content

Content Classes

Popax21 edited this page Sep 25, 2022 · 2 revisions

The content classes make up Procedurline's third layer: the content layer. These classes are named according to the scheme of CustomXYZ, and provide an easy way to implement derivations of already existing gameplay elements, by virtualizing all relevant methods, providing abstract methods which implement key behavior, and allowing one to modify its sprite and other relevant graphical aspects.

Common Code

ProcessSprite()

Obtains the sprite to be used for this entity. Should cache processed sprites globally when possible. By default recolors the entity to the given color.

RecolorGFX()

Recolors secondary graphics of the entity, like particles, to the specific color.

CustomBooster

MakePlayerEnter()

Makes the player enter the booster. This function is called from the PlayerCollider callback. When BoostType.CUSTOM is passed as the boost type, it acts like the player entered the booster, but doesn't call either Player.Boost or Player.RedBoost

MakePlayerExit()

Makes the player exit the booster.

OnPlayerEnter()

An abstract method called when the player enters the booster. Returns the type of boost to perform, which is passed to MakePlayerEnter.

CustomRefill

Break()

Makes the refill break, and optionally respawn after a given delay.

OnTouch()

Called when the player touches the refill while it isn't broken. Returns true if the refill should break.

CustomDreamBlock

CreateParticles()

Creates an array of ParticleData which is used to create the dream block's particles.

OnEnter()

Called when the player enters the dream block.

OnExit()

Called when the player exits the dream block.

OnCollideSolid()

Called when the player collides with a solid when inside of the dream block.

UpdatePlayer()

Updates the player while they're in the dream block. Can be used to override the default update logic.

GetParticleData()

A static method which obtains a ParticleData struct for a dream block particle.

FromParticleData()

Creates a new dream block particle from a ParticleData struct.

Content Patches

To provide the functionality of the content classes, Procedurline needs to apply various internal patches. These patches, called content patches, are specified using an internal mechanism which works using internal attributes applied to various methods. The attributes allow one to e.g. call a method on module load and unload (ContentInit / ContentUninit), apply a regular and IL hook to a target method (ContentHook / ContentILHook), virtualize a non-virtual base method using a MethodVirtualizerDetour (ContentVirtualize), create a field proxy, which is a property which proxies a (private) field of the base class (ContentFieldProxy), or patch a specific sound effect to replace it with the return value of a property (ContentPatchSFX).

The ProcedurlineModule scans through all classes for these attributes on load, and if it finds them, it performs the appropriate action, which most of the time involves calling a method from the PatchUtil class. This class can also be used to create these patches yourself, even though the content attributes are internal.