Example #1
0
 protected override void Start()
 {
     base.Start();
     stationType   = StationTypeEnum.NoStation;
     OnEjection   += () => movement = Vector2.zero;
     contactPoints = new SerializedDictionary <Collider2D, ContactPoint2D[]>();
 }
Example #2
0
 public void Setup()
 {
     quantityMap = new SerializedDictionary <ResourceType, int>
     {
         { ResourceType.Wood, initWood }, { ResourceType.Rock, initRock }, { ResourceType.Mushroom, initMushroom }
     };
     onChange.Raise();
 }
Example #3
0
    private SerializedDictionary <string, KalsiumObject> BuildDict()
    {
        var res = new SerializedDictionary <string, KalsiumObject>();

        sources.RemoveAll(v => v == null);
        foreach (var source in sources)
        {
            Debug.Assert(source.identifier != "", source);
            Debug.Assert(!res.ContainsKey(source.identifier), source);
            res.Add(source.identifier, source);
        }
        return(res);
    }
Example #4
0
        public void TestDictSerializationPass()
        {
            var instance  = new TestObject();
            var reference = new SerializedDictionary <int, string>();

            instance.var1 = reference;
            reference.Add(1, "A");
            reference.Add(2, "B");
            reference.Add(3, "C");

            Assert.AreEqual(reference.Count, 3);
            Assert.AreEqual(reference.ContainsKey(1), true);
            Assert.AreEqual(reference.ContainsKey(2), true);
            Assert.AreEqual(reference.ContainsKey(3), true);
            Assert.AreEqual(reference[2], "B");
        }
        private void OnEnable() // @formatter:on
        {
            s_ActiveInspectors.Add(this);
            if (defaultStyleSheet is null)
            {
                defaultStyleSheet = idConfig.GetStyleSheet("AAIDefaultEditorStyle");
            }

            BaseOnEnable();

            if (idConfig.AAIConfiguration().enableCustomEditors)
            {
                classDataDictionary = GetFieldData();
            }
            animationTime = idConfig.AAIConfiguration().animationTime;
            cascadeDelay  = idConfig.AAIConfiguration().cascadeDelay;
        }
        // ------------------------------------------------------------ GetFieldData
        // -- Get field and type data from the editor target class                --
        // -- GetFieldData ---------------------------------------------------------
        private SerializedDictionary <string, ClassData> GetFieldData()
        {
            if (idConfig.AAIConfiguration().refreshClassData)
            {
                idConfig.AAIConfiguration().classDataDictionary = new SerializedDictionary <string, ClassData>();
            }
            var needsRefresh = idConfig.AAIConfiguration().refreshClassData;
            var thisName     = this.GetType().Name;
            var targetName   = target.GetType().Name;
            var classDict    = new SerializedDictionary <string, ClassData>();

            // --------------------------------------------- Experimental
            // -- Check for existing saved Target data ------------------
            if (idConfig.AAIConfiguration().classDataDictionary.TryGetValue(targetName, out var tmpClassData) && !needsRefresh)
            {
                classDict.TryAddValue(targetName, tmpClassData);
                if (defaultEditorDebug)
                {
                    Debug.Log($"Target: {classDict[targetName].typeName} Retrieved from Config");
                }
            }
            // ----------------------------------------- Current Default
            // -- If it does not exist, create it ----------------------
            else
            {
                var attributes = target.GetType().GetClassFields(true);
                classDict.TryAddValue(targetName, attributes);
            }

            // --------------------------------------------- Experimental
            // -- Check for existing saved Editor data ------------------
            if (idConfig.AAIConfiguration().classDataDictionary.TryGetValue(thisName, out var tmpEditorClassData) && !needsRefresh)
            {
                classDict.TryAddValue(thisName, tmpEditorClassData);
                if (defaultEditorDebug)
                {
                    Debug.Log($"Editor: {classDict[thisName].typeName} Retrieved from Config");
                }
            }
            // ----------------------------------------- Current Default
            // -- If it does not exist, create it ----------------------
            else
            {
                var attributes = this.GetEditorAttributes();
                classDict.TryAddValue(thisName, attributes);
            }

            // -- Configure categories -----------------------------------
            var classData = classDict[targetName];

            // -- Locate Default category, remove it, reorder the --------
            // -- categories as desired, replace Default at the end ------
            UICategory defaultCategory;

            try
            {
                classData.categoryList = classData.categoryList.Where(x => !(x is null) || !x.category.StartsWith(" ")).ToList();
                defaultCategory        = classData.categoryList.Find(x => x.category == "Default");
            }
            catch (Exception e)
            {
                Debug.Log(e);
                idConfig.AAIConfiguration().refreshClassData = true;
                GetFieldData();
                return(null);
            }

            isAnimated = idConfig.AAIConfiguration().enableAnimation;
            if (classData.categoryList.Count < 1)
            {
                return(classDict);
            }
            {
                classData.categoryList.RemoveAll(x => Equals(x, defaultCategory));
                classData.categoryList = classData.categoryList.OrderBy(x => x.order).ToList();
                classData.categoryList.TryAddValue(defaultCategory);

                classData.categoryList.ForEach(x =>
                {
                    bool expand;
                    expand = idConfig.AAIConfiguration().expandCategoriesByDefault || x.expand || classData.categoryList.Count == 1;

                    if (isAnimated)
                    {
                        var element = new AnimatedFoldout {
                            name = x.category, text = x.category, value = false
                        };
                        if (!categoryList.Exists(c => c.name == element.name))
                        {
                            categoryList.TryAddValue(element);
                        }
                    }
                    else
                    {
                        var element = new Foldout {
                            name = x.category, text = x.category, value = expand
                        };
                        if (!categoryList.Exists(c => c.name == element.name))
                        {
                            categoryList.TryAddValue(element);
                        }
                    }
                });
            }
            return(classDict);
        }