-
-
Save andoowhy/82b578b709ff6c57a1f947fa3f0443cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//DexStat.cs | |
using UnityEngine; | |
[DisallowMultipleComponent] | |
public class DexStat : MonoBehaviour | |
{ | |
public float dexStat = 100f; | |
} | |
... | |
//DexStatModifyer.cs | |
using UnityEngine; | |
[DisallowMultipleComponent] | |
public class DexStatModifyer : MonoBehaviour | |
{ | |
public float dexStatModifyer = 50f; | |
} | |
... | |
//DexStatSystem.cs | |
using UnityEngine; | |
public class DexStatSystem : EgoSystem<DexStat> | |
{ | |
public override void Start() | |
{ | |
EgoEvents<AddedComponent<DexStatModifyer>>.AddHandler( ( e ) => | |
{ | |
var dexStatModifyer = e.component; | |
ForEachGameObject( ( ego, dexStat ) => | |
{ | |
dexStat.dexStat += dexStatModifyer.dexStatModifyer; | |
}); | |
}); | |
EgoEvents<DestroyedComponent<DexStatModifyer>>.AddHandler( ( e ) => | |
{ | |
var dexStatModifyer = e.component; | |
ForEachGameObject( ( ego, dexStat ) => | |
{ | |
dexStat.dexStat -= dexStatModifyer.dexStatModifyer; | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment