private void InitializePrefab(BuildingInfo prefab, PrivateBuildingAI ai, String aiClass)
 {
     prefab.m_buildingAI        = ai;
     ai.m_constructionTime      = 0;
     prefab.m_buildingAI.m_info = prefab;
     prefab.InitializePrefab();
     prefab.m_class = ItemClassCollection.FindClass(aiClass);
 }
Beispiel #2
0
 private void Awake()
 {
     if (this.IsIgnored())
     {
         Destroy(this);
         return;
     }
     ItemClassCollection.InitializeClasses(this.m_classes);
 }
Beispiel #3
0
        public void Reload()
        {
            ItemClassCollection items = new ItemClassCollection();
            items.LoadConfig(MotionConfiguration.Instance.ItemSettings);
            items.SetGroup(this);

            foreach (ItemClass i in items.Values)
            {
                this.Add(i);
            }
        }
        /// <summary>
        /// Applies settings to a BuildingInfo prefab.
        /// </summary>
        /// <param name="prefab">The prefab to modify.</param>
        /// <param name="ai">The building AI to apply.</param>
        /// <param name="aiClass">The AI class string to apply.</param>
        /// <param name="growable">Whether the prefab should be growable.</param>
        private void InitializePrefab(BuildingInfo prefab, BuildingAI ai, String aiClass, bool growable)
        {
            // Non-zero construction time important for other mods (Real Time, Real Construction) - only for private building AIs.
            if (ai is PrivateBuildingAI)
            {
                ((PrivateBuildingAI)ai).m_constructionTime = 30;
            }

            prefab.m_buildingAI        = ai;
            prefab.m_buildingAI.m_info = prefab;
            prefab.m_class             = ItemClassCollection.FindClass(aiClass);
            prefab.m_placementStyle    = growable ? ItemClass.Placement.Automatic : ItemClass.Placement.Manual;
            prefab.m_autoRemove        = false;
        }
        /// <summary>
        /// Applies settings to a BuildingInfo prefab.
        /// </summary>
        /// <param name="prefab">The prefab to modify.</param>
        /// <param name="ai">The building AI to apply.</param>
        /// <param name="aiClass">The AI class string to apply.</param>
        /// <param name="growable">Whether the prefab should be growable.</param>
        private void InitializePrefab(BuildingInfo prefab, BuildingAI ai, String aiClass, bool growable)
        {
            // Non-zero construction time important for other mods (Real Time, Real Construction) - only for private building AIs.
            if (ai is PrivateBuildingAI privateBuildingAI)
            {
                privateBuildingAI.m_constructionTime = 30;
            }

            // Assign required fields.
            prefab.m_buildingAI        = ai;
            prefab.m_buildingAI.m_info = prefab;
            prefab.m_class             = ItemClassCollection.FindClass(aiClass);
            prefab.m_placementStyle    = growable ? ItemClass.Placement.Automatic : ItemClass.Placement.Manual;
            prefab.m_autoRemove        = growable || !ModSettings.warnBulldoze;
        }
Beispiel #6
0
        public static ItemClassCollection GetbyUser(string CreatedUser)
        {
            ItemClassCollection collection = new ItemClassCollection();
            ItemClass           obj;

            using (var reader = SqlHelper.ExecuteReader("tblItemClass_GetAll_byUser", new SqlParameter("@CreatedUser", CreatedUser)))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Beispiel #7
0
        public static ItemClassCollection GetAllItem()
        {
            ItemClassCollection collection = new ItemClassCollection();

            using (var reader = SqlHelper.ExecuteReader("tblItemClass_GetAll", null))
            {
                while (reader.Read())
                {
                    ItemClass obj = new ItemClass();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
        public static void AssignServiceClass()
        {
            for (uint i = 0; i < PrefabCollection <BuildingInfo> .LoadedCount(); i++)
            {
                var prefab = PrefabCollection <BuildingInfo> .GetLoaded(i);

                if (prefab.m_buildingAI is PloppableRICO.PloppableExtractor || prefab.m_buildingAI is PloppableResidential ||
                    prefab.m_buildingAI is PloppableOffice || prefab.m_buildingAI is PloppableCommercial ||
                    prefab.m_buildingAI is PloppableIndustrial)
                {
                    // Just assign any RICO prefab a ploppable ItemClass so it will reload. It gets set back once the mod loads.
                    prefab.m_class = ItemClassCollection.FindClass("Beautification Item");
                    prefab.InitializePrefab();
                }
            }
        }
Beispiel #9
0
        void RefreshItemClasses()
        {
            if (itemClasses == null)
            {
                itemClasses = new List <string>();
            }
            itemClasses.Clear();
            ItemClassCollection classCollection = FindObjectOfType <ItemClassCollection>();

            if (classCollection == null)
            {
                return;
            }
            foreach (var item in classCollection.m_classes)
            {
                itemClasses.Add(item.name);
                ModDebug.Log(item.name);
            }
        }
        public static void InitializePrefab(BuildingInfo prefab, PrivateBuildingAI ai, String aiClass)
        {
            prefab.m_buildingAI        = ai;
            ai.m_constructionTime      = 30;
            prefab.m_buildingAI.m_info = prefab;

            try
            {
                prefab.InitializePrefab();
            }
            catch
            {
                Debug.Log("InitPrefab Failed" + prefab.name);
            }

            prefab.m_class          = ItemClassCollection.FindClass(aiClass);
            prefab.m_placementStyle = ItemClass.Placement.Manual;
            prefab.m_autoRemove     = true;
            //prefab.m_dontSpawnNormally = false;
        }
Beispiel #11
0
 private void FillGrid(ItemClassCollection its)
 {
     if (its == null)
     {
         return;
     }
     foreach (ItemClass i in its.Values)
     {
         CameraClass c = i as CameraClass;
         if (c != null)
         {
             this.FillGrid(c);
         }
         else
         {
             GroupClass g = i as GroupClass;
             if (g != null)
             {
                 this.FillGrid(g.Children);
             }
         }
     }
 }
Beispiel #12
0
 private void PopulateTreeView(ItemClassCollection items, TreeNode parentNode)
 {
     foreach (ItemClass item in items.Values)
     {
         if (this.AtTheEdge())
         {
             break;
         }
         CameraTreeNode n = new CameraTreeNode(item);
         if (parentNode == null)
         {
             this.treeViewCamera.Nodes.Add(n);
         }
         else
         {
             parentNode.Nodes.Add(n);
         }
         GroupClass g = item as GroupClass;
         if (g != null)
         {
             PopulateTreeView(g.Children, n);
         }
     }
 }
Beispiel #13
0
        public virtual void LoadConfig(IConfigSetting s)
        {
            this.ID = s["id"].Value;
            this.Name = s["name"].Value;

            this.mChildren = new ItemClassCollection(s, this);
        }
Beispiel #14
0
 private void FillGrid(ItemClassCollection its)
 {
     if (its == null)
     {
         return;
     }
     foreach (ItemClass i in its.Values)
     {
         CameraClass c = i as CameraClass;
         if (c != null)
         {
             this.FillGrid(c);
         }
         else
         {
             GroupClass g = i as GroupClass;
             if (g != null)
             {
                 this.FillGrid(g.Children);
             }
         }
     }
 }
Beispiel #15
0
 private void PopulateTreeView(ItemClassCollection items, TreeNode parentNode)
 {
     foreach (ItemClass item in items.Values)
     {
         if (this.AtTheEdge())
         {
             break;
         }
         CameraTreeNode n = new CameraTreeNode(item);
         if (parentNode == null)
         {
             this.treeViewCamera.Nodes.Add(n);
         }
         else
         {
             parentNode.Nodes.Add(n);
         }
         GroupClass g = item as GroupClass;
         if (g != null)
         {
             PopulateTreeView(g.Children, n);
         }
     }
 }