| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using UnityEngine; |
| | 5 | |
|
| | 6 | | public class FeatureFlag |
| | 7 | | { |
| 190 | 8 | | public readonly Dictionary<string, bool> flags = new Dictionary<string, bool>(); |
| 190 | 9 | | public readonly Dictionary<string, FeatureFlagVariant> variants = new Dictionary<string, FeatureFlagVariant>(); |
| | 10 | |
|
| | 11 | |
|
| | 12 | | public bool IsFeatureEnabled(string featureName) |
| | 13 | | { |
| 387 | 14 | | if (flags.ContainsKey(featureName)) |
| 40 | 15 | | return flags[featureName]; |
| | 16 | |
|
| 347 | 17 | | return false; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public string ToString() |
| | 21 | | { |
| 0 | 22 | | string result = ""; |
| | 23 | |
|
| 0 | 24 | | foreach ( var flag in flags ) |
| | 25 | | { |
| 0 | 26 | | result += $"{flag.Key}: {flag.Value}\n"; |
| | 27 | | } |
| | 28 | |
|
| 0 | 29 | | return result; |
| | 30 | | } |
| | 31 | | } |
| | 32 | |
|
| | 33 | | public class FeatureFlagVariant |
| | 34 | | { |
| | 35 | | private string name; |
| | 36 | | private bool enable; |
| | 37 | | private Payload payload; |
| | 38 | |
|
| | 39 | | struct Payload |
| | 40 | | { |
| | 41 | | private string type; |
| | 42 | | private string value; |
| | 43 | | } |
| | 44 | | } |