示例#1
0
    /// <summary>
    /// 添加技能
    /// </summary>
    /// <param name="newSkillId">技能id</param>
    /// <param name="isCreateAsset">是否创建新的资源</param>
    static TreeViewItem AddSkill(int newSkillId, bool isCreateAsset = true)
    {
        Skill skill = ScriptableObject.CreateInstance <Skill>();

        _skillDic[skill.skillId] = skill;
        skill.skillId            = newSkillId;
        if (isCreateAsset)
        {
            AssetEditor.CreateAsset(skill, FixPath + newSkillId, "Skill");
        }

        TreeViewItem skillItem = _root.AddItem(newSkillId.ToString());
        SkillBase    data      = new SkillBase();

        data.type             = ItemType.Root;
        data.resPath          = ResPath + newSkillId + "/Skill";
        data.skillId          = newSkillId;
        skillItem.DataContext = data;
        AddEvents(skillItem);
        if (isCreateAsset)
        {
            TreeViewItem evtItem = AddSkillEventNode(skillItem, SkillEventType.ActiveEvent.ToString());
            if (evtItem != null)
            {
                AddSkillAction(evtItem, "PlayAnimator");
                AddSkillAction(evtItem, "FinishSkill");
            }
            AddSkillEventNode(skillItem, SkillEventType.AnimaEvent.ToString());
        }

        return(skillItem);
    }
示例#2
0
    /// <summary>
    /// 添加技能
    /// </summary>
    TreeViewItem AddSkill(TreeViewItem parent, int skillId, bool createAsset = false)
    {
        try
        {
            //技能节点的数据
            ItemData itemData = new ItemData();
            itemData.resPath = ResPath + skillId + "/Skill";
            itemData.type    = ItemType.Skill;

            //增加技能节点
            TreeViewItem item = parent.AddItem(skillId.ToString());
            item.DataContext = itemData;
            AddEvents(item);

            if (createAsset)
            {
                Skill skill = ScriptableObject.CreateInstance <Skill>();
                skill.ID = skillId;
                skillTable.Add(skill.ID, skill);
                AssetEditor.CreateAsset(skill, FixedPath + skillId, "Skill");
                TreeViewItem activeEventItem = AddEvent(item, "ActiveEvent", true);
                AddAction(activeEventItem, "AnimationAction", true);
                AddAction(activeEventItem, "FinishAction", true);
                AddEvent(item, "AnimEvent", true);
            }

            return(item);
        }
        catch (Exception e)
        {
            this.ShowNotification(new GUIContent(e.Message));
        }

        return(null);
    }
示例#3
0
 static void CreateInstance()
 {
     if (mInstance == null)
     {
         mInstance = new AssetEditor();
     }
 }
示例#4
0
    /// <summary>
    /// 添加事件
    /// </summary>
    /// <param name="item">父节点</param>
    /// <param name="name">事件名</param>
    /// <param name="isCreateAsset">是否创建新的资源</param>
    /// <returns></returns>
    static TreeViewItem AddSkillEventNode(TreeViewItem item, string name, bool isCreateAsset = true)
    {
        if (name == String.Empty)
        {
            return(null);
        }
        Skill skill = RegetditSkill(item);

        if (skill == null)
        {
            return(null);
        }
        string   evtName = name;
        Assembly ass     = typeof(SkillEvent).Assembly;

        string[]    nameList = name.Split('_');
        System.Type type     = ass.GetType(nameList[0]);
        SkillEvent  evt      = System.Activator.CreateInstance(type) as SkillEvent;
        SkillBase   evtData  = new SkillBase();

        if (evt is ActiveEvent)
        {
            if (isCreateAsset)
            {
                skill.activeEvent.Add(evt as ActiveEvent);
            }
        }
        else
        {
            if (skill.animaEvent.Count > 0)
            {
                evtName = name + "_" + skill.animaEvent.Count;
            }
            if (isCreateAsset)
            {
                skill.animaEvent.Add(evt as AnimaEvent);
            }
        }
        if (isCreateAsset)
        {
            AssetEditor.CreateAsset(evt, FixPath + skill.skillId + "/" + evtName, evtName);
        }
        else
        {
            evtName = name;
        }
        TreeViewItem evtItem = item.AddItem(evtName);

        evtData.type        = ItemType.SkillEvent;
        evtData.skillId     = skill.skillId;
        evtData.resPath     = ResPath + skill.skillId + "/" + evtName + "/" + evtName;
        evtItem.DataContext = evtData;
        AddEvents(evtItem);
        EditorUtility.SetDirty(skill);
        return(evtItem);
    }
示例#5
0
        public bool Create([FromUri] int appId, [FromUri] string path,[FromBody] ContentHelper content, bool global = false)
        {
            Log.Add($"create a#{appId}, path:{path}, global:{global}, cont-length:{content.Content?.Length}");
            path = path.Replace("/", "\\");

            var thisApp = new App(PortalSettings.Current, appId);

            if (content.Content == null)
                content.Content = "";
            var assetEditor = new AssetEditor(thisApp, path, UserInfo, PortalSettings, global);
            assetEditor.EnsureUserMayEditAsset(path);
            return assetEditor.Create(content.Content);
        }
示例#6
0
    /// <summary>
    /// 添加技能action
    /// </summary>
    /// <param name="item">父节点</param>
    /// <param name="name">action名</param>
    /// <param name="isCreateAsset">是否创建新资源</param>
    static void AddSkillAction(TreeViewItem item, string name, bool isCreateAsset = true)
    {
        SkillBase  data    = item.DataContext as SkillBase;
        SkillBase  actData = new SkillBase();
        Skill      skill   = RegetditSkill(item);
        SkillEvent evt     = Resources.Load(data.resPath) as SkillEvent;

        if (skill == null || evt == null)
        {
            return;
        }
        Assembly ass = typeof(SkillAction).Assembly;

        string[]    nameList = name.Split('_');
        System.Type type     = ass.GetType(nameList[0]);
        SkillAction act      = System.Activator.CreateInstance(type) as SkillAction;

        string actName = name;
        int    num     = 0;

        foreach (var act2 in evt.skillActions)
        {
            if (act2.name.StartsWith(name))
            {
                num++;
            }
        }
        if (num > 0)
        {
            actName = actName + "_" + num;
        }
        if (isCreateAsset)
        {
            evt.skillActions.Add(act);
            AssetEditor.CreateAsset(act, FixPath + skill.skillId + "/" + evt.name + "/SkillAction", actName);
        }
        else
        {
            actName = name;
        }

        TreeViewItem evtItem = item.AddItem(actName);

        actData.type        = ItemType.SkillAction;
        actData.skillId     = skill.skillId;
        actData.resPath     = ResPath + skill.skillId + "/" + evt.name + "/SkillAction/" + actName;
        evtItem.DataContext = actData;
        AddEvents(evtItem);
        EditorUtility.SetDirty(evt);
        EditorUtility.SetDirty(skill);
    }
示例#7
0
    TreeViewItem AddEvent(TreeViewItem parent, string type, bool createAsset = false)
    {
        try
        {
            int    skillId = (parent.DataContext as ItemData).skillId;
            string name    = type;
            if (createAsset)
            {
                Skill      skill      = skillTable[skillId];
                Assembly   ass        = typeof(SkillEvent).Assembly;
                SkillEvent skillEvent = System.Activator.CreateInstance(ass.GetType(type)) as SkillEvent;
                if (skillEvent is ActiveEvent)
                {
                    name = "ActiveEvent";
                    skill.ActiveEvents.Add(skillEvent as ActiveEvent);
                }
                else
                {
                    if (skill.AnimEvents.Count > 0)
                    {
                        name = type + skill.AnimEvents.Count;
                    }
                    else
                    {
                        name = type;
                    }
                    skill.AnimEvents.Add(skillEvent as AnimEvent);
                }
                AssetEditor.CreateAsset(skillEvent, FixedPath + skillId + "/" + name, name);
                EditorUtility.SetDirty(skill);
            }

            ItemData itemData = new ItemData();
            itemData.resPath = ResPath + skillId + "/" + name + "/" + name;
            itemData.type    = ItemType.Event;

            TreeViewItem item = parent.AddItem(name);
            item.Header      = name;
            item.DataContext = itemData;
            AddEvents(item);

            return(item);
        }
        catch (Exception e)
        {
            this.ShowNotification(new GUIContent(e.Message));
        }
        return(null);
    }
        [Step(@"^we prepare for a new service$")] public void PrepareNewService()
        {
            assetDb?.Dispose();
            assetDb = AssetDb.Instance;
            assetDb.CreateFolders(path: projectDirectory).Select();
            if (assetDb.Error)
            {
                Fail($"Can't create '{projectDirectory}'");
            }

            assetEditor?.Dispose();
            assetEditor = AssetEditor.Instance.Load(assetName: "NewService", nameSpace: "Decoupler", projectDirectory);
            newService  = (NewService)assetEditor.Asset("NewService");
            Clear();
        }
示例#9
0
        public bool Create([FromUri] int appId, [FromUri] string path, [FromBody] ContentHelper content, bool global = false)
        {
            path = path.Replace("/", "\\");

            var thisApp = new App(PortalSettings.Current, appId);

            if (content.Content == null)
            {
                content.Content = "";
            }
            var assetEditor = new AssetEditor(thisApp, path, UserInfo, PortalSettings, global);

            assetEditor.EnsureUserMayEditAsset(path);
            return(assetEditor.Create(content.Content));
        }
示例#10
0
        public bool Create([FromUri] int appId, [FromUri] string path, [FromBody] ContentHelper content, bool global = false)
        {
            Log.Add($"create a#{appId}, path:{path}, global:{global}, cont-length:{content.Content?.Length}");
            path = path.Replace("/", "\\");

            var thisApp = new App(new DnnTenant(PortalSettings.Current), appId);

            if (content.Content == null)
            {
                content.Content = "";
            }

            var isAdmin     = UserInfo.IsInRole(PortalSettings.AdministratorRoleName);
            var assetEditor = new AssetEditor(thisApp, path, UserInfo.IsSuperUser, isAdmin, global);

            assetEditor.EnsureUserMayEditAsset(path);
            return(assetEditor.Create(content.Content));
        }
示例#11
0
    /// <summary>
    /// Sets up the GMCM for this mod.
    /// </summary>
    /// <param name="sender">SMAPI.</param>
    /// <param name="e">event args.</param>
    private void SetUpConfig(object?sender, GameLaunchedEventArgs e)
    {
        GMCMHelper helper = new(this.Monitor, this.Helper.Translation, this.Helper.ModRegistry, this.ModManifest);

        if (!helper.TryGetAPI())
        {
            return;
        }
        helper.Register(
            reset: () =>
        {
            Config = new();
            AssetEditor.Invalidate();
        },
            save: () =>
        {
            this.Helper.WriteConfig(Config);
            AssetEditor.Invalidate();
        });
        foreach (PropertyInfo property in typeof(ModConfig).GetProperties())
        {
            if (property.PropertyType == typeof(bool))
            {
                helper.AddBoolOption(
                    property: property,
                    getConfig: () => Config);
            }
        }
        helper.AddPageHere("CheatyStuff", I18n.CheatyStuffTitle);
        foreach (PropertyInfo property in typeof(ModConfig).GetProperties())
        {
            if (property.PropertyType == typeof(float))
            {
                helper.AddFloatOption(
                    property: property,
                    getConfig: () => Config,
                    min: 0f,
                    max: 1f,
                    interval: 0.01f);
            }
        }
    }
示例#12
0
        public bool Create(int appId, string path, FileContentsDto content, bool global = false)
        {
            Log.Add($"create a#{appId}, path:{path}, global:{global}, cont-length:{content.Content?.Length}");
            path = path.Replace("/", "\\");

            var thisApp = Factory.Resolve <Apps.App>().InitNoData(new AppIdentity(Eav.Apps.App.AutoLookupZone, appId), Log);

            if (content.Content == null)
            {
                content.Content = "";
            }

            path = SanitizePathAndContent(path, content);

            var isAdmin     = _user.IsAdmin; // UserInfo.IsInRole(PortalSettings.AdministratorRoleName);
            var assetEditor = new AssetEditor(thisApp, path, _user.IsSuperUser, isAdmin, global, Log);

            assetEditor.EnsureUserMayEditAssetOrThrow(path);
            return(assetEditor.Create(content.Content));
        }
示例#13
0
    void CreateCurrentEditor()
    {
        switch (mActiveEditor)
        {
        case EditorType.AssetEditor:
            mCurrentEditor = AssetEditor.CreateNewAssetEditorUI();
            break;

        case EditorType.GameObjectEditor:
            mCurrentEditor = GameObjectEditor.CreateNewGameObjectEditorUI();
            break;

        case EditorType.LevelEditor:
            mCurrentEditor = LevelEditor.CreateNewLevelEditorUI();
            break;

        case EditorType.PlayerEditor:
            mCurrentEditor = PlayerEditor.CreateNewPlayerEditorUI();
            break;
        }
    }
示例#14
0
 private void OnAssetRequested(object?sender, AssetRequestedEventArgs e)
 => AssetEditor.HandleAssetRequested(e);
示例#15
0
 private void OnAssetRequested(object?sender, AssetRequestedEventArgs e)
 => AssetEditor.Edit(e, this.Helper.ModRegistry, this.Helper.DirectoryPath);
示例#16
0
 private void OnAssetInvalidated(object?sender, AssetsInvalidatedEventArgs e)
 => AssetEditor.Refresh(e.NamesWithoutLocale);
示例#17
0
    /*************
     * REGION ASSET MANAGEMENT
     * **********/

    private void OnLocaleChange(object?sender, LocaleChangedEventArgs e)
    => AssetEditor.Refresh();
示例#18
0
 private void AddAssets <T>(MappedList <T> mappedList) where T : Object, IUniqueName
 {
     AssetEditor.AddAssetsOfType(this, mappedList);
 }
 protected void AddScriptableObjectWrappedData <T, TWrapper>(MappedList <T> mappedList)
     where T : IUniqueName
     where TWrapper : ScriptableObjectDataWrapper <T>
 {
     AssetEditor.AddScriptableObjectWrappedDataOfType <T, TWrapper>(this, mappedList);
 }
示例#20
0
    TreeViewItem AddAction(TreeViewItem parent, string type, bool createAsset = false)
    {
        try
        {
            ItemData parentData    = parent.DataContext as ItemData;
            string   name          = type;
            string[] arr           = parentData.resPath.Split('/');
            string   actionResPath = "";
            for (int i = 0; i < arr.Length - 1; i++)
            {
                actionResPath += arr[i];
                actionResPath += "/";
            }

            if (createAsset)
            {
                Assembly    ass         = typeof(SkillAction).Assembly;
                SkillAction skillAction = System.Activator.CreateInstance(ass.GetType(type)) as SkillAction;

                SkillEvent parentEvent = Resources.Load <SkillEvent>(parentData.resPath);
                parentEvent.actions.Add(skillAction);

                int count = 0;
                foreach (var act in parentEvent.actions)
                {
                    if (act.name.StartsWith(type))
                    {
                        count++;
                    }
                }

                if (count > 0)
                {
                    skillAction.name = type + count.ToString();
                }
                else
                {
                    skillAction.name = type;
                }
                name = skillAction.name;

                AssetEditor.CreateAsset(skillAction, "Assets/Resources/" + actionResPath + "Actions", name);
                EditorUtility.SetDirty(parentEvent);
            }

            ItemData itemData = new ItemData();
            itemData.resPath = actionResPath + "Actions/" + name;
            itemData.type    = ItemType.Aciton;

            TreeViewItem item = parent.AddItem(name);
            item.Header      = name;
            item.DataContext = itemData;
            AddEvents(item);



            return(item);
        }
        catch (Exception e)
        {
            this.ShowNotification(new GUIContent(e.Message));
        }
        return(null);
    }
示例#21
0
    static void AssetBuildEditor()
    {
        AssetPlatform chain = new AssetEditor();

        chain.Process();
    }