Example #1
0
	// ================================================================================================================

	public static bool CheckSelectedTheme(Database db)
	{
		if (UniRPGEditorGlobal.GUIEditors.Length == 0) return false;
		if (UniRPGEditorGlobal.activeGUIThemeIdx < 0 || UniRPGEditorGlobal.activeGUIThemeIdx >= UniRPGEditorGlobal.GUIEditors.Length)
		{
			UniRPGEditorGlobal.activeGUIThemeIdx = -1;
			for (int i = 0; i < UniRPGEditorGlobal.GUIEditors.Length; i++)
			{
				if (UniRPGEditorGlobal.GUIEditors[i].name.Equals(db.activeGUITheme))
				{
					UniRPGEditorGlobal.activeGUIThemeIdx = i;
					UniRPGEditorGlobal.LoadInputsFromBinder(UniRPGEditorGlobal.GUIEditors[UniRPGEditorGlobal.activeGUIThemeIdx].editor.GetInputBinder(db.menuGUIData, db.gameGUIData));
					break;
				}
			}

			if (UniRPGEditorGlobal.activeGUIThemeIdx < 0)
			{
				UniRPGEditorGlobal.activeGUIThemeIdx = 0;
				db.activeGUITheme = UniRPGEditorGlobal.GUIEditors[UniRPGEditorGlobal.activeGUIThemeIdx].name;
				UniRPGEditorGlobal.InitGUIThemeData(db, UniRPGEditorGlobal.activeGUIThemeIdx);
				UniRPGEditorGlobal.LoadInputsFromBinder(UniRPGEditorGlobal.GUIEditors[UniRPGEditorGlobal.activeGUIThemeIdx].editor.GetInputBinder(db.menuGUIData, db.gameGUIData));
				EditorUtility.SetDirty(db);
			}
		}
		return true;
	}
Example #2
0
	/// <summary>Exit from in-game to the Main Menu</summary>
	public void LoadGameToMenu()
	{
		DestroyCameras();
		ShowLoading(State.LoadingMainMenu_Step1);

		gameAutoCallsMade = false;
		IsAutoLoadSave = false;
		PerformSave();
		saveEventListener = null;	// clear all old listeners

		// destroy the reged globals
		for (int i = 0; i < regedGlobalObjects.Count; i++)
		{
			GameObject.Destroy(regedGlobalObjects[i]);
		}
		regedGlobalObjects.Clear();

		// destroy the DB and load a new copy so that everything in it is as during deisgn time
		GameObject.Destroy(_db);
		GameObject go = (GameObject)GameObject.Instantiate(dbPrefab);
		go.name = "Database";
		go.transform.parent = gameObject.transform;
		_db = go.GetComponent<Database>();

		// load menu
		//Application.LoadLevelAsync("menudata");
		UniRPGGlobal.LoadLevel("menudata");
	}
Example #3
0
	private List<GameObject> regedGlobalObjects = new List<GameObject>(); // these are gameobjects that must be destroyed when the game is exited (when player moves back to the menu), since they have been set to not auto destroy

	#endregion
	// ================================================================================================================
	#region awake/start

	void Awake()
	{
		_instance = this;
		state = State.None;

		IsAutoLoadSave = false;
		DoNotLoad = true;
		SaveSlots = new Dictionary<string, string>(0);

		if (dbPrefab)
		{
			GameObject go = (GameObject)GameObject.Instantiate(dbPrefab);
			go.name = "Database";
			go.transform.parent = gameObject.transform;
			_db = go.GetComponent<Database>();
		}

		if (_db == null)
		{
			Debug.LogError("The Database prefab is not set. The main UniRPG scene is invalid. This issue MUST be fixed!");
			return;
		}

		_db.Initialise();

		// add the Quest List Provider component, if any
		if (!string.IsNullOrEmpty(_db.questListProviderType))
		{
			//QuestListProvider = (QuestListProviderBase)UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(gameObject, "Assets/UniRPG/Scripts/UniRPG/UniRPGGlobal.cs (217,100)", _db.questListProviderType);
			QuestListProvider = (QuestListProviderBase)gameObject.AddComponent(UniRPGUtil.FindType(_db.questListProviderType));
		}
		if (QuestListProvider == null) QuestListProvider = (QuestListProviderBase)gameObject.AddComponent<NoQuest>();

		// set some defaults
		startPlayerName = null;
		if (_db.defaultPlayerCharacterPrefab != null) startCharacterDef = _db.defaultPlayerCharacterPrefab;

		// this object is global and should exist until the game exit
		GameObject.DontDestroyOnLoad(this.gameObject);

		// setup loading-gui
		LoadGUISettings lgui = _db.loadGUISettings.GetComponent<LoadGUISettings>();
		loadGUI = gameObject.GetComponent<LoadingGUI>();
		loadGUI.skin = lgui.guiSkin;
		loadGUI.text = lgui.loadText;
		loadGUI.image = lgui.loadBackground;
		if (loadGUI.image) loadGUI.imgRect = GUIElementTransform.CalcRect(lgui.designW, lgui.designH, lgui.trLoadBackground);
		loadGUI.designW = lgui.designW;
		loadGUI.designH = lgui.designH;
		loadGUI.enabled = false;
		
		// disable the cam for now, only used when showing loading screen
		loadingCamObj.SetActive(false);

		_guiConsumedInput = false;
	}
	public static void LoadOrCreateDatabase()
	{
		if (!UniRPGEdUtil.RelativeFileExist(DB_FILE))
		{
			CreateDatabase();
		}
		else
		{
			GameObject go = AssetDatabase.LoadAssetAtPath(DB_FILE, typeof(GameObject)) as GameObject;
			_db = go.GetComponent<Database>();
			PerformAfterDBLoaded(_db);
		}
	}
	private static void CheckGUIDs(Database db)
	{
		float progress = 0f;
		float step = 1f;
		List<UniRPG.GUID> ids = new List<UniRPG.GUID>();
		foreach (string scenePath in db.gameScenePaths)
		{
			UniRPGEditorGlobal.OpenScene(scenePath);

			Object[] objs = GameObject.FindObjectsOfType(typeof(UniqueMonoBehaviour));
			if (objs.Length > 0)
			{
				progress = 0f; step = 1f / objs.Length;
				foreach (UniqueMonoBehaviour o in objs)
				{
					//EditorUtility.DisplayProgressBar("Chacking IDs ...", "Checking GUIDs for uniqueness", progress);
					if (o.id.IsEmpty) { o.id = UniRPG.GUID.Create(); EditorUtility.SetDirty(o); }
					while (UniRPG.GUID.ListContains(ids, o.id)) { o.id = UniRPG.GUID.Create(); EditorUtility.SetDirty(o); }
					ids.Add(o.id);
					progress += step;
				}
			}

			UniRPGEditorGlobal.MarkSceneDirty();
			UniRPGEditorGlobal.SaveScene();
		}
		//EditorUtility.ClearProgressBar();
		ids.Clear();
		ids = null;
	}
	// ================================================================================================================
	#region init & defaults

	public static bool LoadDatabase(bool silent = false)
	{
		if (UniRPGEditorGlobal._db != null) return true;
		if (!UniRPGEdUtil.RelativeFileExist(DB_FILE))
		{
			Debug.LogError("You must first create a UniRPG Database. From the menu, select: Window -> UniRPG -> Database");
			if (!silent) EditorUtility.DisplayDialog("Warning", "You must first create a UniRPG Database. From the menu, select: Window -> UniRPG -> Database", "Close");
			return false;
		}
		else
		{
			GameObject go = AssetDatabase.LoadAssetAtPath(DB_FILE, typeof(GameObject)) as GameObject;
			UniRPGEditorGlobal._db = go.GetComponent<Database>();
			if (_db != null)
			{
				PerformAfterDBLoaded(_db);
				return true;
			}
		}
		return false;
	}
	public static void SetupBuildSettingsAndGlobals(Database db, bool promptSave, bool setupForPlaytest)
	{
		//CheckTags();

		string prevScene = UniRPGEditorGlobal.CurrentScene();
		if (promptSave)
		{
			if (!UniRPGEditorGlobal.SaveCurrentSceneIfUserWantsTo()) return;
		}

		// ----------------------------------------------------------------------------
		// Make sure autocall list is valid
		UpdateAutoCallList(db);

		// ----------------------------------------------------------------------------
		// Update the Build Settings - adding the scenes as needed
		ArrayList scenes = new ArrayList(db.mainScenePaths.Length + db.gameScenePaths.Count);
		for (int i = 0; i < db.mainScenePaths.Length; i++)
		{
			scenes.Add(new EditorBuildSettingsScene { enabled = true, path = db.mainScenePaths[i] });
		}
		for (int i = 0; i < db.gameScenePaths.Count; i++)
		{
			scenes.Add(new EditorBuildSettingsScene { enabled = true, path = db.gameScenePaths[i] });
		}
		EditorBuildSettings.scenes = scenes.ToArray(typeof(EditorBuildSettingsScene)) as EditorBuildSettingsScene[];

		// ----------------------------------------------------------------------------
		// Check that the Startup scene is still correctly setup
		bool err = true;
		if (UniRPGEditorGlobal.OpenScene(db.mainScenePaths[0]))
		{
			GameObject go = GameObject.Find("StartupGUI");
			if (go)
			{
				Startup data = go.GetComponent<Startup>();
				if (data)
				{
					err = false;
					if (!data.settings)
					{
						data.settings = db.startGUISettings;
						EditorUtility.SetDirty(data);
						UniRPGEditorGlobal.MarkSceneDirty(); 
						UniRPGEditorGlobal.SaveScene();
					}
				}
			}
		}
		if (err) EditorUtility.DisplayDialog("Error!", "An error occured while trying to set the Startup scene Data. Your UniRPG install might be corrupt.", "Close");

		// ----------------------------------------------------------------------------
		// Check that the main UniRPG scene is still correctly setup
		err = true;
		if (UniRPGEditorGlobal.OpenScene(db.mainScenePaths[1]))
		{
			GameObject go = GameObject.Find("UniRPGGlobal");
			if (go)
			{
				UniRPGGlobal data = go.GetComponent<UniRPGGlobal>();
				if (data)
				{
					err = false;
					if (!data.dbPrefab)
					{
						data.dbPrefab = db.gameObject;
						EditorUtility.SetDirty(data);
						UniRPGEditorGlobal.MarkSceneDirty();
						UniRPGEditorGlobal.SaveScene();
					}
				}
			}
		}
		if (err) EditorUtility.DisplayDialog("Error!", "An error occured while trying to set the main UniRPG scene Data. Your UniRPG install might be corrupt.", "Close");

		// ----------------------------------------------------------------------------
		// Update the MainMenuData
		err = true;
		if (UniRPGEditorGlobal.OpenScene(db.mainScenePaths[2]))
		{
			GameObject go = GameObject.Find("MainMenuData");
			if (go)
			{
				MainMenuData data = go.GetComponent<MainMenuData>();
				if (data)
				{
					data.startupPlayerPrefabs = new List<GameObject>();

					// only set the player lists if the designer wants player selection at start
 					// of if game is run now and a default chara is not set in the db (need something to playtest with)

					if (db.playerCanSelectCharacter || (setupForPlaytest && db.defaultPlayerCharacterPrefab == null))
					{
						// find all player character prefabs and check which are set as avail at startup
						if (Cache == null) RefreshCache(true);
						else if (Cache.actors == null) RefreshCache(true);
						if (Cache.actors.Count > 0)
						{
							foreach (Actor a in Cache.actors)
							{
								if (a.Character == null)
								{
									Debug.LogError("Encountered broken character. Found an Actor with no Character related component (like Chara2_Player or Chara2_NPC): " + a.gameObject.name);
									continue;
								}

								if (a.availAtStart && a.ActorType == UniRPGGlobal.ActorType.Player)
								{
									data.startupPlayerPrefabs.Add(a.gameObject);
								}
							}
						}
						else Debug.LogError("You need to define a Player Character and Refresh the cache in Database -> Main -> Actors. Play testing will fail.");

						//List<Player> charas = UniRPGEdUtil.FindPrefabsOfTypeAll<Player>("Searching", "Finding all defined Player Characters.");
						//foreach (Player c in charas)
						//{
						//	if (c.Actor.availAtStart) data.startupPlayerPrefabs.Add(c.gameObject);
						//}
					}

					err = false;
					EditorUtility.SetDirty(data);
					UniRPGEditorGlobal.MarkSceneDirty();
					UniRPGEditorGlobal.SaveScene();
				}
			}
		}
		if (err) EditorUtility.DisplayDialog("Error!", "An error occured while trying to set the Menu scene Data. Your UniRPG install might be corrupt.", "Close");

		// ----------------------------------------------------------------------------
		// check that the IDs for all objects in scenes are unique
		CheckGUIDs(db);

		// ----------------------------------------------------------------------------
		// done, reopen open previous scene
		UniRPGEditorGlobal.OpenScene(prevScene);
	}
	private static void UpdateAutoCallList(Database db)
	{
		db.menuAutoCalls = new List<string>(0);
		db.gameAutoCalls = new List<string>(0);
		if (menuAutoCalls.Count > 0) db.menuAutoCalls.AddRange(menuAutoCalls);
		if (gameAutoCalls.Count > 0) db.gameAutoCalls.AddRange(gameAutoCalls);
	}
	public static void InitGUIThemeData(Database db, int idx)
	{
		activeGUIThemeIdx = idx;
		db.mainScenePaths[3] = UniRPGEditorGlobal.GUIEditors[idx].menuGUIPath;
		db.mainScenePaths[4] = UniRPGEditorGlobal.GUIEditors[idx].gameGUIPath;
		
		// load/create the data files for the selected gui theme
		bool created = false;
		string assetPath = DB_GUI_PATH + "GuiTheme " + db.activeGUITheme + " MenuData.prefab";
		if (!UniRPGEdUtil.RelativeFileExist(assetPath))
		{
			//Debug.Log("Creating: " + assetPath);
			Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);
			GameObject go = new GameObject("GuiTheme " + db.activeGUITheme);
			go.AddComponent(UniRPGEditorGlobal.GUIEditors[idx].menuGUIDataType);
			GameObject prefabGo = PrefabUtility.ReplacePrefab(go, prefab);
			GameObject.DestroyImmediate(go);
			db.menuGUIData = prefabGo;
			created = true;
		}
		else
		{
			Debug.Log("Loading: " + assetPath);
			db.menuGUIData = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
		}

		assetPath = DB_GUI_PATH + "GuiTheme " + db.activeGUITheme + " InGameData.prefab";
		if (!UniRPGEdUtil.RelativeFileExist(assetPath))
		{
			//Debug.Log("Creating: " + assetPath);
			Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);
			GameObject go = new GameObject("GuiTheme " + db.activeGUITheme);
			go.AddComponent(UniRPGEditorGlobal.GUIEditors[idx].gameGUIDataType);
			GameObject prefabGo = PrefabUtility.ReplacePrefab(go, prefab);
			GameObject.DestroyImmediate(go);
			db.gameGUIData = prefabGo;
			created = true;
		}
		else
		{
			Debug.Log("Loading: " + assetPath);
			db.gameGUIData = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
		}

		if (created)
		{
			UniRPGEditorGlobal.GUIEditors[idx].editor.InitDefaults(db.menuGUIData, db.gameGUIData);
		}
	}
Example #10
0
	private static void UpdateStartupScene(Database db, bool promptSave)
	{	// update the start scene with the startup settings and gui
		if (promptSave)
		{
			if (!UniRPGEditorGlobal.SaveCurrentSceneIfUserWantsTo()) return;
		}

		bool err = true;
		if (UniRPGEditorGlobal.OpenScene(db.mainScenePaths[0]))
		{
			GameObject go = GameObject.Find("StartupGUI");
			if (go)
			{
				Startup obj = go.GetComponent<Startup>();
				if (obj)
				{
					err = false;
					obj.settings = db.startGUISettings;
					EditorUtility.SetDirty(obj);
					UniRPGEditorGlobal.MarkSceneDirty();
					UniRPGEditorGlobal.SaveScene();
				}
			}
		}

		// show a blank scene
		UniRPGEditorGlobal.NewScene();		

		if (err)
		{
			EditorUtility.DisplayDialog("Error!", "An error occurred while trying to set the Startup Settings. Your UniRPG install might be corrupt.", "Close");
		}
	}
Example #11
0
	private static void InitDefaultLoadGUI(Database db)
	{
		// Default Startup Settings
		string assetPath = DB_GUI_PATH + "StartupGUI.prefab";
		if (!UniRPGEdUtil.RelativeFileExist(assetPath))
		{
			//Debug.Log("Creating: " + assetPath);
			Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);		// craete prefab space
			GameObject go = new GameObject("StartupGUI");					// create temp object in scene
			StartupSettings c = go.AddComponent<StartupSettings>();			// add component to temp objects

			c.images = new List<Texture2D>(2);
			c.guiSkin = AssetDatabase.LoadAssetAtPath(UniRPGEditorGlobal.PackagePath + "Default Assets/GUI/Startup/DefaultStartSkin.guiskin", typeof(GUISkin)) as GUISkin;
			c.images.Add((Texture2D)AssetDatabase.LoadAssetAtPath(UniRPGEditorGlobal.PackagePath + "Default Assets/GUI/Startup/splash_sample1.png", typeof(Texture2D)));
			c.images.Add((Texture2D)AssetDatabase.LoadAssetAtPath(UniRPGEditorGlobal.PackagePath + "Default Assets/GUI/Startup/splash_sample2.png", typeof(Texture2D)));
			c.trImages.size = new Vector2(c.images[0].width, c.images[0].height);

			GameObject prefabGo = PrefabUtility.ReplacePrefab(go, prefab);	// save object as prefab
			GameObject.DestroyImmediate(go);								// delete temp object from scene
			db.startGUISettings = prefabGo;
		}
		else
		{
			Debug.Log("Loading: " + assetPath);
			db.startGUISettings = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
		}

		// Default LoadeGUI Settings
		assetPath = DB_GUI_PATH  + "LoadGUI.prefab";
		if (!UniRPGEdUtil.RelativeFileExist(assetPath))		
		{
			//Debug.Log("Creating: " + assetPath);
			Object prefab = PrefabUtility.CreateEmptyPrefab(assetPath);		// craete prefab space
			GameObject go = new GameObject("LoadGUI");						// create temp object in scene
			LoadGUISettings l = go.AddComponent<LoadGUISettings>();	// add component to temp objects

			l.guiSkin = AssetDatabase.LoadAssetAtPath(UniRPGEditorGlobal.PackagePath + "Default Assets/GUI/Startup/DefaultStartSkin.guiskin", typeof(GUISkin)) as GUISkin;

			GameObject prefabGo = PrefabUtility.ReplacePrefab(go, prefab);	// save object as prefab
			GameObject.DestroyImmediate(go);								// delete temp object from scene
			db.loadGUISettings = prefabGo;
		}
		else
		{
			Debug.Log("Loading: " + assetPath);
			db.loadGUISettings = AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)) as GameObject;
		}
	}
Example #12
0
	private static void InitDatabaseDefaults(Database db)
	{
		// create default startup settings
		InitDefaultLoadGUI(db);

		// create default camera
		GameCameraBase cam = CameraEditor.CreateCamera("Default", typeof(DefaultCam1));
		//Debug.Log(cam);
		EditorUtility.SetDirty(cam);
		db.cameraPrefabs.Add(cam.gameObject); 

		// create default actorclass
		RPGActorClass ac = ScriptableObject.CreateInstance<RPGActorClass>();
		UniRPGEdUtil.AddObjectToAssetFile(ac, DB_DEF_CLASSES_FILE);
		ac.screenName = "Default";
		ac.availAtStart = false;
		EditorUtility.SetDirty(ac);
		db.classes = new List<RPGActorClass>();
		db.classes.Add(ac);

		// other defaults
		db.itemCategories = new List<RPGItem.Category>() 
		{ 
			new RPGItem.Category() { screenName = "Undefined" },
			new RPGItem.Category() { screenName = "Weapon", types = { "Wand", "Trinket", "Knife", "Dagger", "Sword", "Axe", "Hammer", "Staff", "Two-Handed Sword", "Two-Handed Axe", "Two-Handed Hammer", "Ranged" } },
			new RPGItem.Category() { screenName = "Armour", types = { "Cloth", "Leather", "Metal" } },
			new RPGItem.Category() { screenName = "Accessory" },
			new RPGItem.Category() { screenName = "Consumable" },
		};

		db.equipSlots = new List<string>() { "Head", "Body", "Main-Hand", "Off-Hand", "Necklace", "Ring1", "Ring2" };

		// select a defauilt gui theme and init scene paths
		db.mainScenePaths[0] = DB_SYS_SCENE_PATH + "startup.unity";
		db.mainScenePaths[1] = DB_SYS_SCENE_PATH + "unirpg.unity";
		db.mainScenePaths[2] = DB_SYS_SCENE_PATH + "menudata.unity";

		if (UniRPGEditorGlobal.GUIEditors.Length >= 0)
		{
			db.activeGUITheme = UniRPGEditorGlobal.GUIEditors[0].name;
			InitGUIThemeData(db, 0);
		}
		else
		{
			Debug.LogError("Error: No GUI Themes are defined.");
		}

		// --------
		// save
		EditorUtility.SetDirty(db);
		AssetDatabase.SaveAssets();
	}
Example #13
0
	public static void InitLoadSaveProvider(Database db, int forceUsing)
	{
		activeLoadSaveIdx = -1;
		if (LoadSaveEditors.Length >= 0)
		{
			if (db.loadSaveProviderPrefab && forceUsing == -1)
			{	// first try and find out what provider was selected previously and init with it, if possible
				LoadSaveProviderBase provider = db.loadSaveProviderPrefab.GetComponent<LoadSaveProviderBase>();
				if (provider)
				{
					for (int i = 0; i < LoadSaveEditors.Length; i++)
					{
						if (provider.providerName.Equals(LoadSaveEditors[i].name))
						{
							activeLoadSaveIdx = i;
							currLoadSaveProvider = provider;
							break;
						}
					}
				}
			}

			// if idx == -1 then one is not selected and must be added now
			if (activeLoadSaveIdx == -1)
			{
				if (forceUsing == -1)
				{
					// will select UniRPG's default provider
					for (int i = 0; i < LoadSaveEditors.Length; i++)
					{
						if (LoadSaveEditors[i].providerType == typeof(DefaultLoadSave)) { activeLoadSaveIdx = i; break; }
					}

					if (activeLoadSaveIdx == -1) activeLoadSaveIdx = 0; // else grab first avail
				}
				else activeLoadSaveIdx = forceUsing;

				// create object & save as prefab
				Object prefab = PrefabUtility.CreateEmptyPrefab(LOADSAVE_PREFAB);
				GameObject go = new GameObject("LoadSave Provider");			// create temp object in scene 
				go.AddComponent(LoadSaveEditors[activeLoadSaveIdx].providerType);	
				GameObject lspPrefab = PrefabUtility.ReplacePrefab(go, prefab); // save prefab
				GameObject.DestroyImmediate(go);								// wipe temp object from scene

				db.loadSaveProviderPrefab = lspPrefab;
				currLoadSaveProvider = db.loadSaveProviderPrefab.GetComponent<LoadSaveProviderBase>();
				currLoadSaveProvider.providerName = LoadSaveEditors[activeLoadSaveIdx].name;

				EditorUtility.SetDirty(db.loadSaveProviderPrefab);
				EditorUtility.SetDirty(db);
				AssetDatabase.SaveAssets();
			}
		}
	}
Example #14
0
	private static void PerformAfterDBLoaded(Database db)
	{
		// Init the LoadSave Provider vars/ or select the default one now if one is not selected
		InitLoadSaveProvider(db, -1);

		// make sure autocall are valid
		UpdateAutoCallList(db);
	}
Example #15
0
	// ================================================================================================================
	#region Equip slots and Equipped items

	/// <summary>check that enough slots in (equip) is allocated, if not it will be destroyed and inited with correct size</summary>
	public void CheckEquipSlotsSize(Database db)
	{
		if (equipped.Count != db.equipSlots.Count)
		{
			if (equipped.Count > 0)
			{	// there might be equipped items, do not wanna lose 'em
				List<RPGItem> newEquip = new List<RPGItem>(db.equipSlots.Count);
				for (int i = 0; i < db.equipSlots.Count; i++)
				{
					if (i < equipped.Count) newEquip.Add(equipped[i]);
					else equipped.Add(null);
				}
				equipped = newEquip;
			}
			else
			{
				equipped = new List<RPGItem>(db.equipSlots.Count);
				for (int i = 0; i < db.equipSlots.Count; i++) equipped.Add(null);
			}
		}
	}