39 lines
860 B
C#
39 lines
860 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using BITKit;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITFALL.Scene
|
||
|
{
|
||
|
public class ActionBasedComponent : MonoBehaviour
|
||
|
{
|
||
|
[RuntimeInitializeOnLoadMethod]
|
||
|
protected static void Reload()
|
||
|
{
|
||
|
InputActionGroup = new InputActionGroup();
|
||
|
}
|
||
|
protected static InputActionGroup InputActionGroup=new();
|
||
|
protected IActionBasedObject actionBasedObject { get; private set; }
|
||
|
|
||
|
protected virtual void OnEnable()
|
||
|
{
|
||
|
actionBasedObject = GetComponent<IActionBasedObject>();
|
||
|
actionBasedObject.OnStarted += OnStart;
|
||
|
InputActionGroup.allowInput.AddElement(this);
|
||
|
}
|
||
|
|
||
|
private void OnStart()
|
||
|
{
|
||
|
actionBasedObject.Entity.Inject(this);
|
||
|
}
|
||
|
|
||
|
protected virtual void OnDisable()
|
||
|
{
|
||
|
actionBasedObject.OnStarted -= OnStart;
|
||
|
InputActionGroup.allowInput.RemoveElement(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|