wangguan
2020-11-17 3da3d10bfdd30a1ad7f8c48ab9fd7e7745e3d053
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using UnityEngine;
 
namespace TowerDefense.Agents
{
    /// <summary>
    /// A component that will apply various effects on an agent
    /// </summary>
    public abstract class AgentEffect : MonoBehaviour
    {
        /// <summary>
        /// Reference to the agent that will be affected
        /// </summary>
        protected Agent m_Agent;
 
        public virtual void Awake()
        {
            LazyLoad();
        }
 
        /// <summary>
        /// A lazy way to ensure that <see cref="m_Agent"/> will not be null
        /// </summary>
        public virtual void LazyLoad()
        {
            if (m_Agent == null)
            {
                m_Agent = GetComponent<Agent>();
            }
        }
    }
}