tModLoader icon indicating copy to clipboard operation
tModLoader copied to clipboard

[Draft] Add ChooseBestTorch Hook (resolves #2475)

Open steviegt6 opened this issue 2 years ago • 1 comments

What is the new feature?

Resolves #2475, adds a new hook that lets modders manipulate the torch placed when Torch God's Favor is active (as well as other tiles, technically).

A proposal to move this functionality to ModSceneEffect was raised, but I am not concerned since vanilla doesn't have a concept of scene effects and attempting to use a ModSceneEffect for arbitrary custom logic is not desirable here. Additionally, this logic is traditionally located only in Player, and I wish to keep it that way. Torch variations shouldn't be restricted to ModSceneEffects since you can absolutely use this functionality for other reasons, such as custom torch variations for vanilla biomes, accessories and whatnot that may disable or modify every placed torch, among other possibilities.

This hook allows modders to manipulate more about tiles that just when Torch God's Favor is active, due to the nature of the hook and its ability to toggle vanilla behavior and override the need for Torch God's Favor. There is no easy or convenient way around this.

Why should this be part of tModLoader?

See #2475.

Are there alternative designs?

Not really, but there are a some ways to rewrite the code. needs discussion.

Sample usage for the new feature

See ExampleChooseBestTorch.cs.

ExampleMod updates

See ExampleChooseBestTorch.cs.

steviegt6 avatar Jun 02 '22 03:06 steviegt6

Can't mark this as a draft after making it, I think, but I have several things to sort out with this PR at a later date.

steviegt6 avatar Jun 05 '22 01:06 steviegt6