Help for clean Event

Hello (sorry for the english)

I try to create an RPG game for fun.
I start a new project to begin with good roots.

For now I have an object the CharacteresModel, I will use this model to create Player(s) and Ennemies.
It contains 3 others objecct : Level, Health and Mana.
Each of this object contains their own methode to Get,Set,Increase,Decrease, …

Where I block now his to do event cross object.
For exemple a player level up I want his health and mana to level as well.

I kwon how use event and to do this is simple, but the probleme is all the other caracter will listen to the same event, and will react the same way, obviously I don’t want went an Player level up than the ennemies do tthe same.

Thee only way I find is went I intantiate my Level object I Give my CharacteresModel (this) as parameter and send him in the event as argument and in the listener I have a :

if (sender.Equals(this))

Where sender is the object send by the event (here the CharacteresModel I give to the level object)

It work but I find this I bit heavy and dirty (peraphs I am wrong).

By question his ; There is a better way ? can we get the object CharacteresModel directly from the Level ? Peraphs we there is an option in the event I dont kown about or an other solution witout the event ?

Here my class (I try on the Health not the level but it should work the same) :

public class CharacteresModel
{
    public string charactereName;

    public Level lvl;
    public Health health;
    public Mana mana;
  
    public CharacteresModel()
    {
        lvl = new Level(1);
        health = new Health(10, this);
        mana = new Mana(10);

        StatutSystemEvents.OnHealthChange += THealth;
        StatutSystemEvents.OnTest += Test;
    }

    public void THealth()
    {
        Debug.Log("THealth " + charactereName + " " + health.HP);
    }

    public void Test(object sender)
    {
        if (sender.Equals(this))
        {
            Debug.Log("Test " + charactereName + " " + health.HP);
        }
    }
    }

This is the problem. Don’t make NPCs listen to the player event, or the other way around.

StatusSystemEvents looks like a global design. Don’t do that for this purpose. Everybody should ONLY listen to events related to themselves, otherwise you completely defeat the purpose of decoupling.

There MIGHT be a call for a global system, such as to track statistics across the whole game, but that should be a completely different system than the instance-level tracking.

I already know the pb but thank for the reply.

What I want to know if there is a way to resolve it

My players and my ennemies will all have an Level, Health, … and so the same methode
I design the code that way (I made the StatusSystemEvents ), whent HP or Mana or Exp change en event his trigger for the HealtBar and other thing in UI to change as well.

The Players and the ennemis need to lauchn the events but what I want to find if there is a better wait to do so.
For now the best way I have like this

When I instaniate an object like the Health I passe the CharacteresModel who create it as a parameter and put that CharacteresModel as parameter of the events.
I do the same for the listener and it check every time it see an event is the CharacteresModel in parameter match his own.

But I found this solution completed stupid (the CharacteresModel have an Health object who have … CharacteresModel.

I don’t think I can create one type of event for every CharacteresModel possible

Peraphs there is an other way ?

I will try to be a bit more clear.
I have an object CharacteresModel

public class CharacteresModel
{
    public string charactereName;

    public Level lvl;
    public Health health;
    public Mana mana;

    public Characteristiques characteristiques;
    public Statistiques statistiques;

    public CharacteresModel()
    {
        lvl = new Level(1, this);
        health = new Health(10, this);
        mana = new Mana(10, this);

        characteristiques = new Characteristiques(5, 5, 5, 5, 5, 5, 5, 5);
        statistiques = new Statistiques(10, 10, 10, 10, 10, 10, 10, 10);
    }
 }

What I want his a way to communicate between the “sub-object” of this object.
For example, when I increase the level in Level, I want to launch the Increase health in Health
When I increase a Characterisitque in Characteristiques like Strenght I want to increase the PhysicalAttaque in Statistiques.

For now I have two way, the first with event but it the mess when you have differents CharacteresModel.
The second way is to give to the sub-object the reference of the CharacteresModel who use them, and I do what I want after.

For example in the Level object, whent I increase the level I call the heal parameter of the CharacteresModel to increase the health.

I think the second way is better then the first but, she has her flaws as well. Each sub-object containt the reference of the object who call them. Peraphs its juste me but I found that completly stupid.

There is no way to “give” information to the CharacteresModel whitout know him from the sub-object?
A “sub-object” can not know who call him ?

I hope some one can help me