summaryrefslogtreecommitdiff
path: root/WorldlineKeepers/Assets/Scripts/Tools/FlagManager.cs
blob: b9a9454cb3283ea5a18ca16ca20330f503d0182a (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace WK
{

    /// <summary>
    /// 全局标志管理
    /// </summary>
    public class FlagManager : Singleton<FlagManager>   
    {
        public Dictionary<string, bool> m_Flags;

        public void AddFlag(string flag, bool value = false)
        {
            if(!HasFlag(flag)) 
            { 
                m_Flags.Add(flag, value);       
            }
        }

        public bool HasFlag(string flag) 
        { 
            return m_Flags.ContainsKey(flag);   
        }

        public bool IsFlag(string flag)
        {
            if(m_Flags.ContainsKey(flag)) return false;
            return m_Flags[flag];
        }

        public void RemoveFlag(string flag)
        {
            if(HasFlag(flag))
            {
                m_Flags.Remove(flag);   
            }
        }

    }

}