/// <summary> /// Adds a building to a specific plan menu. /// </summary> /// <param name="menu">The menu to which to add the building.</param> private void AddPlanToCategory(PlanScreen.PlanInfo menu) { // Found category var data = menu.buildingAndSubcategoryData; if (data != null) { string addID = AddAfter; bool add = false; if (addID != null) { // Optionally choose the position int n = data.Count; for (int i = 0; i < n - 1 && !add; i++) { if (data[i].Key == addID) { data.Insert(i + 1, new KeyValuePair <string, string>(ID, SubCategory)); add = true; } } } if (!add) { data.Add(new KeyValuePair <string, string>(ID, SubCategory)); } } else { PUtil.LogWarning("Build menu " + Category + " has invalid entries!"); } }
public static void AddBuildingToPlanScreen(HashedString category, string building_id) { int num = BUILDINGS.PLANORDER.FindIndex((PlanScreen.PlanInfo x) => x.category == category); if (num >= 0) { PlanScreen.PlanInfo planInfo = BUILDINGS.PLANORDER[num]; IList <string> list = planInfo.data as IList <string>; list.Add(building_id); } }