EtG Modding Guide
  • ETG Modding Guide
  • Getting started
    • Modding EtG: Installing Mods
    • Modding EtG: Creating a Mod
    • Uploading a Mod
    • Useful Tools
      • Using IlSpy
  • Making An Item
    • Creating A Passive
    • Creating An Active
    • Creating An Ammolet
    • Creating A Guon
    • Synergies
  • Making a Gun
    • Creating A Gun
      • Setting Up Gun Sprite Folders
      • Creating Gun Jsons/Jtk2ds
        • Pixel Measurement Conversions
    • Setting Up Projectiles
      • Adding Components To A Projectile
      • Projectile HitEffects (Visual Effects)
      • Adding status effects to a projectile
    • Continuous Fire Animations
    • Gun Ammo Types
  • Custom Characters
    • Creating A Standalone Custom Character
  • Making a Floor
    • Introduction
    • Setup
    • Making The Dungeon
    • Tileset
    • Rooms
    • Making the flow
    • Making the Entrance
    • All Files
  • Text, Text Boxes, Etc
    • Textboxes
    • Text Formatting
  • Sounds
    • Using Custom Sounds
    • Customising Gun Sounds
    • Basegame Sound List
    • wwise Sound Dump
  • Misc
    • Making Asset bundles
    • Assetbundles: How-To
    • How to create a hook
    • Creating A Command
    • Subscribing Methods to Actions
    • Reversing Player Controls
    • Undodgeable Projectiles
    • Creating An Enemy
  • Shaders
    • Creating Shaders
  • All things Spriting
    • Important Sprite Creation Information.
    • Importing a Sprite To Visual Studios
  • Monobehaviour Documentation
    • BounceProjModifier
    • PierceProjModifier
    • KeyProjModifier
    • CompanionFollowPlayerBehaviour
  • Various Lists of IDs, Sounds, Etc.
    • List of Item and Gun IDs
    • Enemy Guids
    • List of Base Game Synergies
    • dfSpriteList
    • All Custom Ammo Types
    • Gun .Json Dump
  • OFF TOPIC MEMES
    • Modders Anthem
Powered by GitBook
On this page
  • Step 1 Identifying an Event/Action's Parameters
  • Step 2 Making a Valid Method
  • Step 3 Subscribing The Method
  • Step 4 Unsubscribing The Method

Was this helpful?

  1. Misc

Subscribing Methods to Actions

Quick guide to making pre existing actions call methods automatically when triggered by the base game

PreviousCreating A CommandNextReversing Player Controls

Last updated 4 years ago

Was this helpful?

Gungeon comes with a large number of events and actions already set up, subscribing methods to events is what enables a large amount of items more complex than a simple passive stat modifier to exist. Here I'll walk you through making a simple bullet modifier as well as the general principles involved

Step 1 Identifying an Event/Action's Parameters

The first step in subscribing an action to a method is identifying which parameters the action will output, we need to know this because the arguments of methods subscribed always need to match with the action's output. Lucky for us finding this information is as simple as hovering over the action with the cursor in VisualStudio

here we are looking at the PostProcessProjectile action, which is triggered by the game when a projectile is fired by the player and is one of the easiest and most common ways to handle projectile modifiers. The parameters inside Action<>, in this case, Projectile and float, are the ones we need to know.

Step 2 Making a Valid Method

An action will call all methods subscribed to it with its parameters as arguments, for this reason, it is important that they match exactly.

Here we're simply increasing the projectile's size, so even though we have no need of the float, which for this action is the base chance for a projectile to trigger an effect like say, frost bullets', it must be part of the method's parameters regardless. Likewise, the method cannot have any extra parameters.

Step 3 Subscribing The Method

Now that we have a valid method all that we need to do is simply attach it to the action through the use of the += operator. When done our method is successfully subscribed to the PostProcessProjectile action and will be called every time the action is triggered. Methods can be subscribed anywhere, but when making passive items Pickup is a common place for it.

Note how the method does NOT have any arguments being passed to it, that is because we are not calling the method directly and the action will take care of that. You CANNOT pass arguments to a method (at least when subscribing it this way).

Step 4 Unsubscribing The Method

Once subscribed, a method will be called every time the action is triggered, but there are a variety of reasons why you could want that to stop being the case, a common one would be stopping a projectile modifier from being applied when the item that grants it is dropped. Unsubscribing methods can be done through the use of the -= operator.

Methods MUST be unsubscribed manually or they will keep being called when an action is triggered even after the item is dropped.