public static void InitializeVanillaBehaviors()
        {
            byte behaviorTypeCount = 0; //Note this is 0-indexed

            //Handle vanilla types, creating appropriate behavior for each.
            Type vanillaServiceType = typeof(ItemClass.Service);
            Type vanillaSubserviceType = typeof(ItemClass.SubService);

            SortedDictionary<int, string> serviceDict = new SortedDictionary<int, string>(Tools.EnumToDictionary<ItemClass.Service>());
            var subServiceDict = Tools.EnumToDictionary<ItemClass.SubService>();

            foreach (var entry in serviceDict)
            {
                List<BuildingBehaviorManager.Subtype> subtypes = new List<BuildingBehaviorManager.Subtype>();
                var behavior = new BuildingBehaviorManager.BehaviorType();
                behavior.defaultMaxDensity = 0;
                behavior.defaultMaxLevel = GetMaxLevel((ItemClass.Service)entry.Key);
                behavior.name = entry.Value;
                behavior.type = behaviorTypeCount;
                behavior.defaultDataModules = VanillaServicesData[(ItemClass.Service)entry.Key];
                foreach (var pair in subServiceDict)
                {
                    if (pair.Value.StartsWith(entry.Value))
                    {
                        // Handle vanilla density levels, which are currently exclusive of subservice types, so they go under default for services
                        if (pair.Value.EndsWith(VanillaDensity1Ending)) behavior.defaultMaxDensity = VanillaDensity1;
                        else if (pair.Value.EndsWith(VanillaDensity2Ending)) behavior.defaultMaxDensity = VanillaDensity2;
                        else
                        {
                            var subtype = new BuildingBehaviorManager.Subtype();

                            if (pair.Key == (int)ItemClass.SubService.IndustrialGeneric)
                                subtype.maxLevel = GenericIndustryMaxLevel - 1;
                            else
                                subtype.maxLevel = behavior.defaultMaxLevel;

                            subtype.maxDensity = behavior.defaultMaxDensity;
                            subtype.name = pair.Value;
                            subtype.defaultDataModules = behavior.defaultDataModules.Concat(VanillaSubservicesData[(ItemClass.SubService)pair.Key]).ToArray();
                            subtype.type = (byte)subtypes.Count;
                            subtypes.Add(subtype);
                            vanillaSubserviceMapping[(ItemClass.SubService)entry.Key] = (byte)subtypes.Count;
                        }
                    }
                }
                behavior.subtypes = subtypes.ToArray();
                BuildingBehaviorManager.behaviors.Insert(behaviorTypeCount, behavior);
                BuildingBehaviorManager.getBehaviorIDByName[behavior.name] = behaviorTypeCount;
                vanillaServiceMapping[(ItemClass.Service)entry.Key] = behaviorTypeCount;
                behaviorTypeCount++;
            }
        }
Beispiel #2
0
        public static void InitializeVanillaBehaviors()
        {
            byte behaviorTypeCount = 0; //Note this is 0-indexed

            //Handle vanilla types, creating appropriate behavior for each.
            Type vanillaServiceType    = typeof(ItemClass.Service);
            Type vanillaSubserviceType = typeof(ItemClass.SubService);

            SortedDictionary <int, string> serviceDict = new SortedDictionary <int, string>(Tools.EnumToDictionary <ItemClass.Service>());
            var subServiceDict = Tools.EnumToDictionary <ItemClass.SubService>();


            foreach (var entry in serviceDict)
            {
                List <BuildingBehaviorManager.Subtype> subtypes = new List <BuildingBehaviorManager.Subtype>();
                var behavior = new BuildingBehaviorManager.BehaviorType();
                behavior.defaultMaxDensity = 0;
                behavior.defaultMaxLevel   = GetMaxLevel((ItemClass.Service)entry.Key);
                behavior.name = entry.Value;
                behavior.type = behaviorTypeCount;
                behavior.defaultDataModules = VanillaServicesData[(ItemClass.Service)entry.Key];
                foreach (var pair in subServiceDict)
                {
                    if (pair.Value.StartsWith(entry.Value))
                    {
                        // Handle vanilla density levels, which are currently exclusive of subservice types, so they go under default for services
                        if (pair.Value.EndsWith(VanillaDensity1Ending))
                        {
                            behavior.defaultMaxDensity = VanillaDensity1;
                        }
                        else if (pair.Value.EndsWith(VanillaDensity2Ending))
                        {
                            behavior.defaultMaxDensity = VanillaDensity2;
                        }
                        else
                        {
                            var subtype = new BuildingBehaviorManager.Subtype();

                            if (pair.Key == (int)ItemClass.SubService.IndustrialGeneric)
                            {
                                subtype.maxLevel = GenericIndustryMaxLevel - 1;
                            }
                            else
                            {
                                subtype.maxLevel = behavior.defaultMaxLevel;
                            }

                            subtype.maxDensity         = behavior.defaultMaxDensity;
                            subtype.name               = pair.Value;
                            subtype.defaultDataModules = behavior.defaultDataModules.Concat(VanillaSubservicesData[(ItemClass.SubService)pair.Key]).ToArray();
                            subtype.type               = (byte)subtypes.Count;
                            subtypes.Add(subtype);
                            vanillaSubserviceMapping[(ItemClass.SubService)entry.Key] = (byte)subtypes.Count;
                        }
                    }
                }
                behavior.subtypes = subtypes.ToArray();
                BuildingBehaviorManager.behaviors.Insert(behaviorTypeCount, behavior);
                BuildingBehaviorManager.getBehaviorIDByName[behavior.name] = behaviorTypeCount;
                vanillaServiceMapping[(ItemClass.Service)entry.Key]        = behaviorTypeCount;
                behaviorTypeCount++;
            }
        }