MMA is an architectural framework for managing communications that do not communicate directly with each other.
Setup:
- Add MMA with PackageManager or Sourcetree as Submodule.
- Add others modules (example => MMA.Scenes )
- implement the Symbol of keys in 'ProjectSettings>Player>OtherSettings>ScriptCompilation>ScriptingDefineSymbols => MMA_INT || MMA_STRING (MMA_STRING is better for prototyping and MMA_INT for a better performance, maybe in next releases will exist MMA_BYTE for best performance)
Quick start guide:
- Middleware is a class for pub/sub Action, Func, Coroutines, Task
- Module is used as a federated manager in a Scene to handle a specification
- Application works as a entity of a Module of the scene, these are GameObject/s, children of the Module GameObject
using MMA;
public sealed partial class BootstrapModule : Module
{
private void Start() => "Bootstrap.Test".Invoke();
[Subscribe("Bootstrap.Test")] private void OnTest() => "OnLog".Invoke(123);
[Subscribe("OnLog")] private void OnLog(int value) => Debug.Log($"Hello World! {value}");
}
using MMA;
namespace Core.MenuHeaderUIModule {
public sealed partial class MenuHeaderUIModule : Module {
[SerializeField] private Text text_gold = default;
protected override void OnSubscription(bool condition) => Middleware<float>.Subscribe_Publish(condition, Data.Key.OnChangeGold, OnChangeGold);
private void OnChangeGold(float gold) => text_gold.text = gold.ToString();
}
}
namespace Core.FakeModule{ //module to simulate the money obtention
public sealed partial class FakeModule : Module {
protected override void OnSubscription(bool condition){}
void Start() =>Service.Common.OnChangeGold(100)
}
}
namespace Service { //Static classes to manage functions or implementations of Modules, it uses Data's Assembly reference
public static Common {
public static void OnChangeGold(float gold) => Middleware<float>.Invoke_Publish(Data.Key.OnChangeGold, gold);
}
}
namespace Data { // Used to store the information used in this project (because is only useful for this project)
public static Key {
public const int OnChangeGold = Middleware.indexMethodCount++;
}
}