Esempio n. 1
0
        public CfgEncoder Add(string tag, ICfg other)
        {
            if (other.IsNullOrDestroyed_Obj())
            {
                return(this);
            }

            var safe = other as ICfgSafeEncoding;

            if (safe == null)
            {
                return(Add(tag, other.Encode()));
            }

            var ll = safe.GetLoopLock;

            if (ll.Unlocked)
            {
                using (ll.Lock()) {
                    Add(tag, other.Encode());
                }
            }
            else
            {
                Debug.LogError("Infinite encoding loop detected");
            }

            return(this);
        }
Esempio n. 2
0
        public CfgEncoder Add_IfNotDefault(string tag, ICfg cfg)
        {
            if (cfg.IsNullOrDestroyed_Obj())
            {
                return(this);
            }

            var def = cfg as ICanBeDefaultCfg;

            return((def == null || !def.IsDefault) ? Add(tag, cfg) : this);
        }