Questions about composition.

Currently I have a dialogue trigger attached to an npc player and when the player is very close to the NPC and E is pressed, the dialogue triggers. However I want an invisible collider that has the same dialogue trigger attached to it automatically activates when the player collide with it. They both have dialogue triggers component but their trigger should differently. How can i implement almost the same components with different modification?

Should I use a base class called Dialogue Trigger where children called NPCTrigger and ColliderTrigger Inherits from it? Would that defeat the purpose of composition?

I don’t know what exactly what are you wanting to do, but I think you can create different empty objects as a child of your NPC player, each empty object has a trigger collider. Here you have 2 options, the first one is to create a layer (for example one called “NPC dialogue”), and then configure it to only detects collisions with the main player, on the script you just have to show the text when it enters on the trigger collision. The second option is not creating the layer and just specifying the tag, what I mean is that on the script, when it detects a trigger collision compare if the tag is equal to the one of your main player, if it is true then show the message.
I hope it helps you.