コード例 #1
0
        /// <summary> Called when the data provider is selected </summary>
        public override void NfoFieldFocus(plyDataObject data, EditorWindow ed)
        {
            // make sure the Component that handles the Rewards is registered to be added to DiaQ
            EdGlobal.RegisterAutoComponent("DiaQ", "plyRPGDiaQRewardHandler");

            selected = 0;
            int.TryParse(data.nfo[0], out selected);

            if (attribsAsset == null)
            {
                if (dataAsset == null) dataAsset = EdGlobal.GetDataAsset();
                attribsAsset = (ActorAttributesAsset)dataAsset.GetAsset<ActorAttributesAsset>();
                if (attribsAsset == null) attribsAsset = (ActorAttributesAsset)EdGlobal.LoadOrCreateAsset<ActorAttributesAsset>(EdGlobal.DATA_PATH_SYSTEM + "attributes.asset", null);
            }

            if (itemsAsset == null)
            {
                if (dataAsset == null) dataAsset = EdGlobal.GetDataAsset();
                itemsAsset = (ItemsAsset)dataAsset.GetAsset<ItemsAsset>();
                if (itemsAsset == null) itemsAsset = (ItemsAsset)EdGlobal.LoadOrCreateAsset<ItemsAsset>(EdGlobal.DATA_PATH_SYSTEM + "items.asset", null);
                itemsAsset.UpdateItemCache();
            }

            selectedIdent = -1;
            attribNames = new string[attribsAsset.attributes.Count];
            for (int i = 0; i < attribsAsset.attributes.Count; i++)
            {
                attribNames[i] = attribsAsset.attributes[i].def.screenName;
                if (selected == 1 && selectedIdent < 0)
                {
                    if (data.nfo[1].Equals(attribsAsset.attributes[i].id.ToString()))
                    {
                        selectedIdent = i;
                        data.nfo[2] = attribsAsset.attributes[selectedIdent].def.screenName; // update cached name just in case it has changed
                        GUI.changed = true;
                    }
                }
            }

            if (data.nfo[0] == "2")
            {
                if (null == itemsAsset.GetDefinition(new UniqueID(data.nfo[1])))
                {
                    data.nfo[1] = "";
                    data.nfo[2] = "";
                    GUI.changed = true;
                }
            }
        }
コード例 #2
0
		/// <summary> Called when the data provider is selected </summary>
		public override void NfoFieldFocus(plyDataObject data, EditorWindow ed)
		{
			// make sure the Component that handles the Rewards is registered to be added to DiaQ
            EdGlobal.RemoveAutoComponent("DiaQ", typeof(plyRPGDiaQRewardHandler).AssemblyQualifiedName); // make sure old one is not present as it causes problems
            EdGlobal.RegisterAutoComponent("DiaQ", typeof(InventoryProDiaQRewardHandler).AssemblyQualifiedName);

			selected = 0;
			int.TryParse(data.nfo[0], out selected);

			if (attribsAsset == null)
			{
				if (dataAsset == null) dataAsset = EdGlobal.GetDataAsset();
				attribsAsset = (ActorAttributesAsset)dataAsset.GetAsset<ActorAttributesAsset>();
				if (attribsAsset == null) attribsAsset = (ActorAttributesAsset)EdGlobal.LoadOrCreateAsset<ActorAttributesAsset>(plyEdUtil.DATA_PATH_SYSTEM + "attributes.asset", null);
			}

			if (itemsAsset == null)
			{
				if (dataAsset == null) dataAsset = EdGlobal.GetDataAsset();
				itemsAsset = (ItemsAsset)dataAsset.GetAsset<ItemsAsset>();
				if (itemsAsset == null) itemsAsset = (ItemsAsset)EdGlobal.LoadOrCreateAsset<ItemsAsset>(plyEdUtil.DATA_PATH_SYSTEM + "items.asset", null);
				itemsAsset.UpdateItemCache();
			}

			selectedIdent = -1;
			attribNames = new string[attribsAsset.attributes.Count];
			for (int i = 0; i < attribsAsset.attributes.Count; i++)
			{
				attribNames[i] = attribsAsset.attributes[i].def.screenName;
				if (selected == 1 && selectedIdent < 0)
				{
					if (data.nfo[1].Equals(attribsAsset.attributes[i].id.ToString()))
					{
						selectedIdent = i;
						data.nfo[2] = attribsAsset.attributes[selectedIdent].ToString(); // update cached name just in case it has changed
						GUI.changed = true;
					}
				}
			}
		}