コード例 #1
0
        public override async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new McLogicAnimationResourceInfo();

            var data = createData as McLAResourceCreateData;

            result.SkeletonAsset      = data.SkeletonAsset;
            result.CenterDataTypeName = data.CenterDataTypeName;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.MacrossExtension;
            result.ResourceName      = EngineNS.RName.GetRName(reName, data.RNameType);
            result.BaseTypeIsMacross = data.IsMacrossType;
            if (result.BaseTypeIsMacross)
            {
                result.BaseTypeSaveName = data.ClassType.FullName;
                var baseResInfo = await GetBaseMacrossResourceInfo(this);

                if (baseResInfo != null)
                {
                    ReferenceRNameList.Add(baseResInfo.ResourceName);
                }
            }
            else
            {
                result.BaseTypeSaveName = EngineNS.Rtti.RttiHelper.GetTypeSaveString(data.ClassType);
            }
            //var macData = new MacrossData(result.ResourceName);
            //macData.ParentType = data.ClassType;
            //macData.CSType = data.CSType;
            //macData.Id = Guid.NewGuid();
            //macData.Save();

            //var code = "namespace MacrossClasses\r\n";
            //code += "{\r\n";
            //code += $"\t// class name:{result.ResourceName.PureName()}\r\n";
            //code += $"\tpublic class Macross_{macData.Id.ToString().Replace("-", "")} : {macData.ParentType.FullName}\r\n";
            //code += "\t{\r\n";
            //code += "\t}\r\n";
            //code += "}\r\n";
            //using(var writer = System.IO.File.CreateText(result.ResourceName.Address + MacrossData.MacrossCodeExtension))
            //{
            //    writer.WriteLine(code);
            //}

            //result.mMacrossData = macData;
            result.ResourceType = EngineNS.Editor.Editor_RNameTypeAttribute.Macross;

            // 创建时走一遍编译,保证当前Macross能够取到this类型
            var csType        = ECSType.Client;
            var codeGenerator = new CodeGenerator();
            var ctrl          = new MCLAMacrossLinkControl();

            ctrl.CurrentResourceInfo = result;
            ctrl.CSType = csType;
            var codeStr = await codeGenerator.GenerateCode(result, ctrl);

            if (!EngineNS.CEngine.Instance.FileManager.DirectoryExists(result.ResourceName.Address))
            {
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(result.ResourceName.Address);
            }
            var codeFile = $"{result.ResourceName.Address}/{result.ResourceName.PureName()}_{csType.ToString()}.cs";

            using (var fs = new System.IO.FileStream(codeFile, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite))
            {
                fs.Write(System.Text.Encoding.Default.GetBytes(codeStr), 0, Encoding.Default.GetByteCount(codeStr));
            }
            await codeGenerator.GenerateAndSaveMacrossCollector(csType);

            var files = codeGenerator.CollectionMacrossProjectFiles(csType);

            codeGenerator.GenerateMacrossProject(files.ToArray(), csType);
            EditorCommon.Program.BuildGameDll(true);

            return(result);
        }
コード例 #2
0
        public async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new MacrossEnumResourceInfo();

            var data   = createData as MacrossEnumCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, EngineNS.CEngine.Instance.FileManager.ProjectContent);

            reName += EngineNS.CEngineDesc.MacrossEnumExtension;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);
            return(result);
        }
コード例 #3
0
        public override async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new McBehaviorTreeResourceInfo();

            var data = createData as McBTResourceCreateData;

            result.CenterDataTypeName = data.CenterDataTypeName;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.MacrossExtension;
            result.ResourceName      = EngineNS.RName.GetRName(reName, data.RNameType);
            result.BaseTypeIsMacross = data.IsMacrossType;
            if (result.BaseTypeIsMacross)
            {
                result.BaseTypeSaveName = data.ClassType.FullName;
                var baseResInfo = await GetBaseMacrossResourceInfo(this);

                if (baseResInfo != null)
                {
                    ReferenceRNameList.Add(baseResInfo.ResourceName);
                }
            }
            else
            {
                result.BaseTypeSaveName = EngineNS.Rtti.RttiHelper.GetTypeSaveString(data.ClassType);
            }
            result.ResourceType = EngineNS.Editor.Editor_RNameTypeAttribute.Macross;

            // 创建时走一遍编译,保证当前Macross能够取到this类型
            var csType        = ECSType.Client;
            var codeGenerator = new CodeGenerator();
            var ctrl          = new McBTMacrossLinkControl();

            ctrl.CurrentResourceInfo = result;
            ctrl.CSType = csType;
            var codeStr = await codeGenerator.GenerateCode(result, ctrl);

            if (!EngineNS.CEngine.Instance.FileManager.DirectoryExists(result.ResourceName.Address))
            {
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(result.ResourceName.Address);
            }
            var codeFile = $"{result.ResourceName.Address}/{result.ResourceName.PureName()}_{csType.ToString()}.cs";

            using (var fs = new System.IO.FileStream(codeFile, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite))
            {
                fs.Write(System.Text.Encoding.Default.GetBytes(codeStr), 0, Encoding.Default.GetByteCount(codeStr));
            }
            await codeGenerator.GenerateAndSaveMacrossCollector(csType);

            var files = codeGenerator.CollectionMacrossProjectFiles(csType);

            codeGenerator.GenerateMacrossProject(files.ToArray(), csType);
            EditorCommon.Program.BuildGameDll(true);

            return(result);
        }
コード例 #4
0
        public override async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new ParticleResourceInfo();

            var data = createData as ParticleCreateData;
            //result.CenterDataTypeName = data.CenterDataTypeName;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.MacrossExtension;
            result.ResourceName      = EngineNS.RName.GetRName(reName, data.RNameType);
            result.BaseTypeIsMacross = data.IsMacrossType;
            if (result.BaseTypeIsMacross)
            {
                result.BaseTypeSaveName = data.ClassType.FullName;
                var baseResInfo = await GetBaseMacrossResourceInfo(this);

                if (baseResInfo != null)
                {
                    ReferenceRNameList.Add(baseResInfo.ResourceName);
                }
            }
            else
            {
                result.BaseTypeSaveName = EngineNS.Rtti.RttiHelper.GetTypeSaveString(data.ClassType);
            }
            result.ResourceType = EngineNS.Editor.Editor_RNameTypeAttribute.Macross;


            //拷贝模板
            if (string.IsNullOrEmpty(data.TemplateName) == false)
            {
                string newfolder = result.ResourceName.Address;

                string tempfolder = RName.GetRName(data.TemplateName).Address;
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(newfolder);
                EngineNS.CEngine.Instance.FileManager.CopyDirectory(tempfolder, newfolder);
                //EngineNS.CEngine.Instance.FileManager.DeleteFile(newfolder + "/particle1_Client.cs");
                //string newcsname = newfolder + "/" + data.ResourceName + "_Client.cs";
                //if (EngineNS.CEngine.Instance.FileManager.FileExists(newcsname))
                //{
                //    EngineNS.CEngine.Instance.FileManager.DeleteFile(newcsname);
                //}

                var csfiles = EngineNS.CEngine.Instance.FileManager.GetFiles(newfolder, "*.cs", System.IO.SearchOption.AllDirectories);
                if (csfiles != null && csfiles.Count != 0)
                {
                    for (int i = 0; i < csfiles.Count; i++)
                    {
                        if (EngineNS.CEngine.Instance.FileManager.FileExists(csfiles[i]))
                        {
                            EngineNS.CEngine.Instance.FileManager.DeleteFile(csfiles[i]);
                        }
                    }
                }
            }


            // 创建时走一遍编译,保证当前Macross能够取到this类型
            var csType        = ECSType.Client;
            var codeGenerator = new CodeGenerator();
            var ctrl          = new ParticleMacrossLinkControl();

            ctrl.CurrentResourceInfo = result;
            ctrl.CSType = csType;
            var codeStr = await codeGenerator.GenerateCode(result, ctrl);

            if (!EngineNS.CEngine.Instance.FileManager.DirectoryExists(result.ResourceName.Address))
            {
                EngineNS.CEngine.Instance.FileManager.CreateDirectory(result.ResourceName.Address);
            }
            var codeFile = $"{result.ResourceName.Address}/{result.ResourceName.PureName()}_{csType.ToString()}.cs";

            using (var fs = new System.IO.FileStream(codeFile, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite))
            {
                fs.Write(System.Text.Encoding.Default.GetBytes(codeStr), 0, Encoding.Default.GetByteCount(codeStr));
            }
            await codeGenerator.GenerateAndSaveMacrossCollector(csType);

            var files = codeGenerator.CollectionMacrossProjectFiles(csType);

            codeGenerator.GenerateMacrossProject(files.ToArray(), csType);
            EditorCommon.Program.BuildGameDll(true);
            return(result);
        }
コード例 #5
0
        public async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new UVAnimResourceInfo();
            var data   = createData as ResourceCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + data.ResourceName, rootFolder);

            reName += EngineNS.CEngineDesc.UVAnimExtension;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);

            var uvAnim = EngineNS.CEngine.Instance.UVAnimManager.CreateUVAnim(data.TextureRName, data.MaterialInstanceRName);

            // 默认有一帧
            uvAnim.Frames.Add(new EngineNS.UISystem.UVFrame()
            {
                ParentAnim = uvAnim,
            });
            uvAnim.Save2Xnd(result.ResourceName);

            return(result);
        }
コード例 #6
0
        public async Task <ResourceInfo> CreateEmptyResource(string absFolder, string rootFolder, IResourceCreateData createData)
        {
            await EngineNS.Thread.AsyncDummyClass.DummyFunc();

            var result = new ExcelResourceInfo();

            var data   = createData as ExcelCreateData;
            var reName = EngineNS.CEngine.Instance.FileManager._GetRelativePathFromAbsPath(absFolder + "/" + (data.ExcelName.Equals("") ? data.ResourceName : data.ExcelName), EngineNS.CEngine.Instance.FileManager.ProjectContent);

            reName += EngineNS.CEngineDesc.ExcelExtension;
            result.ResourceName = EngineNS.RName.GetRName(reName, data.RNameType);

            ExcelExporter newexport   = new ExcelExporter();
            var           macrossType = EngineNS.Macross.MacrossFactory.Instance.GetMacrossType(data.MacrossName);

            newexport.Init("", macrossType);
            List <Object> lst = new List <Object>();

            //lst.Add( Activator.CreateInstance(data._Type)); //必须要有默认构造函数

            newexport.Objects2Table(lst);
            newexport.Save(result.ResourceName.Address);
            result.MacrossName = data.MacrossName;// + ", " + data._Type.Assembly.FullName;
            return(result);
        }