示例#1
0
        public async Task HandleMessage(StreamManager streamManager, string messageType, string messageData)
        {
            switch (messageType)
            {
            case PUT:
                _featureStore.Init(JsonUtil.DecodeJson <PutData>(messageData).Data.ToGenericDictionary());
                streamManager.Initialized = true;
                break;

            case PATCH:
                PatchData patchData = JsonUtil.DecodeJson <PatchData>(messageData);
                string    patchKey;
                if (GetKeyFromPath(patchData.Path, VersionedDataKind.Features, out patchKey))
                {
                    FeatureFlag flag = patchData.Data.ToObject <FeatureFlag>();
                    _featureStore.Upsert(VersionedDataKind.Features, flag);
                }
                else if (GetKeyFromPath(patchData.Path, VersionedDataKind.Segments, out patchKey))
                {
                    Segment segment = patchData.Data.ToObject <Segment>();
                    _featureStore.Upsert(VersionedDataKind.Segments, segment);
                }
                else
                {
                    Log.WarnFormat("Received patch event with unknown path: {0}", patchData.Path);
                }
                break;

            case DELETE:
                DeleteData deleteData = JsonUtil.DecodeJson <DeleteData>(messageData);
                string     deleteKey;
                if (GetKeyFromPath(deleteData.Path, VersionedDataKind.Features, out deleteKey))
                {
                    _featureStore.Delete(VersionedDataKind.Features, deleteKey, deleteData.Version);
                }
                else if (GetKeyFromPath(deleteData.Path, VersionedDataKind.Segments, out deleteKey))
                {
                    _featureStore.Delete(VersionedDataKind.Segments, deleteKey, deleteData.Version);
                }
                else
                {
                    Log.WarnFormat("Received delete event with unknown path: {0}", deleteData.Path);
                }
                break;

            case INDIRECT_PATCH:
                await UpdateTaskAsync(messageData);

                break;
            }
        }
    private void Remove(PatchData siteData)
    {
        int count = mapLayers.Count;

        for (int i = 0; i < count; ++i)
        {
            if (mapLayers[i].PatchData == siteData)
            {
                Destroy(mapLayers[i].gameObject);
                mapLayers.RemoveAt(i);
                break;
            }
        }
    }
示例#3
0
        private async void DeleteSecurityGroups()
        {
            Enabled = false;

            PatchData patch = new PatchData(DataAccess.APIs.UserManagement, "User/PatchUser", PatchData.PatchMethods.Remove, UserID, new Dictionary <string, object>()
            {
                { "MemberOf", lstSecurityGroups.SelectedItems.Cast <ListViewItem>().Select(lvi => lvi.Text).ToList() }
            });
            await patch.Execute();

            await LoadSecurityGroups();

            Enabled = true;
        }
示例#4
0
    //
    // Inheritance Methods
    //

    public virtual void Init(MapController map, PatchData patchData)
    {
        base.Init(map, patchData.north, patchData.east, patchData.south, patchData.west);

        // Deregister old events
        if (this.patchData != null)
        {
            this.patchData.OnBoundsChange -= OnPatchBoundsChange;
        }

        this.patchData = patchData;

        // Register events
        patchData.OnBoundsChange += OnPatchBoundsChange;
    }
示例#5
0
        private void RemoveSdxReference(PatchData data)
        {
            var filesToRemove = new[] { "SDX.Core.dll", "SDX.Payload.dll", };


            foreach (var s in filesToRemove)
            {
                var path = data.ManagedFolder + s;
                if (File.Exists(path))
                {
                    LogWarning("Removing SDX reference as it's no longer needed: " + s);
                    File.Delete(path);
                }
            }
        }
    //
    // Private Methods
    //

    private PatchMapLayer Add(PatchData patch, Color color)
    {
        PatchMapLayer layer = Instantiate(layerPrefab);

        layer.Init(map, patch);
        layer.SetColor(color);
        layer.transform.SetParent(transform, false);
        if (!showBoundaries && patch.patch.DataLayer != highlightedLayer)
        {
            layer.Show(false);
        }

        mapLayers.Add(layer);

        return(layer);
    }
示例#7
0
        private void buttonLoadGame_Click(object sender, EventArgs e)
        {
            GamePatcher.FileUtil.GameHasher gh = new GamePatcher.FileUtil.GameHasher();
            string pdJson = "";

            gh.LoadPDString(out pdJson, textBoxDirectory.Text);
            PatchData newPD = gh.MakePatchData(pdJson);

            textBoxGVMajor.Text    = newPD.GameVersion.Major.ToString();
            textBoxGVMinor.Text    = newPD.GameVersion.Minor.ToString();
            textBoxGVRevision.Text = newPD.GameVersion.Revision.ToString();
            foreach (FileData fd in newPD.Files)
            {
                Console.WriteLine(fd.Path + "\\" + fd.FileName + " Hash: " + fd.Hash + " Version: " + fd.NewestVersion.ToString());
            }
        }
示例#8
0
    public PatchData(PatchData other)
    {
        west  = other.west;
        east  = other.east;
        north = other.north;
        south = other.south;

        if (other.metadata == null)
        {
            metadata = null;
        }
        else
        {
            metadata = new List <MetadataPair>(other.metadata);
        }
    }
示例#9
0
        public override bool Patch(PatchData data)
        {
            RemoveSdxReference(data);

            var ass = AssemblyDefinition.ReadAssembly(data.GameDllLocation);

            Module = ass.MainModule;
            GetVersionInfo(Module);

            data.BackupFolder = data.BackupFolder + (data.IsDedicatedServer ? "Dedi/" : "SP/") + BuildSettings.MajorVersion + "." + BuildSettings.MinorVersion + "b" + BuildSettings.BuildNumber + "/";
            data.BackupFolder.MakeFolder();
            data.BackupDllLocataion = data.BackupFolder + PatchData.AssemblyFilename;


            if (BuildSettings.IsLocalBuild)
            {
                Helper.CopyFolder(data.ManagedFolder, data.BackupFolder, true, "Assembly-CSharp.dll");
            }

            if (File.Exists(data.BackupDllLocataion))
            {
                LogInfo("Backup dll found: " + data.BackupDllLocataion);
                return(true);
            }

            var modManager    = Module.Types.FirstOrDefault(d => d.Name == "ModManager");
            var patchedObject = modManager?.Fields.FirstOrDefault(d => d.Name == "SdxPatchedCheck");
            var isPatched     = patchedObject != null;

            if (isPatched)
            {
                LogError("This Assembly-CSharp.dll file has already been patched by SDX so can not be used as a backup. Reset your game files and try again.");
                return(false);
            }


            File.Copy(data.GameDllLocation, data.BackupDllLocataion, true);

            if (BuildSettings.IsLocalBuild)
            {
                Helper.CopyFolder(data.ManagedFolder, data.BackupFolder, true);
            }

            Helper.CopyFolder(data.ConfigFolder, data.BackupFolder + "Config", true);
            LogInfo("Copied backup dll to: " + data.BackupDllLocataion);
            return(true);
        }
示例#10
0
    public static PatchData ReadBinBoundsHeader(BinaryReader br, string filename, PatchData patch)
    {
        patch.west  = br.ReadDouble();
        patch.east  = br.ReadDouble();
        patch.north = br.ReadDouble();
        patch.south = br.ReadDouble();

        if (/*patch.west < GeoCalculator.MinLongitude ||
            *  patch.east > GeoCalculator.MaxLongitude ||*/
            patch.north > GeoCalculator.MaxLatitude ||
            patch.south < GeoCalculator.MinLatitude)
        {
            UnityEngine.Debug.LogWarning("File " + filename + " has bounds beyond limits (W,E,N,S): " + patch.west + ", " + patch.east + ", " + patch.north + ", " + patch.south);
        }

        return(patch);
    }
示例#11
0
        public async Task <ActionResult <CommentDto> > PutComment(PatchData data)
        {
            var uid = User.GetNumericId();

            if (uid == null)
            {
                return(Unauthorized());
            }

            var(body, commentId) = data;

            var comm = _context.Comments.FirstOrDefault(c => c.Id == commentId);

            if (comm == null)
            {
                return(NotFound());
            }
            if (uid != comm.AuthorId)
            {
                return(Unauthorized());
            }

            // Create revision
            await _context.CommentRevisions.AddAsync(new CommentRevision
            {
                Body     = comm.Body,
                ParentId = comm.Id,
                EditTime = DateTime.Now
            });

            // Edit the comment
            comm.Id        = commentId;
            comm.Body      = body;
            comm.LastEdit  = DateTime.Now;
            comm.EditCount = (ushort?)(comm.EditCount + 1) ?? 1;

            await _context.SaveChangesAsync();

            var dto = _mapper.Map <Comment, CommentDto>(comm);

            dto.Owned = uid == comm.AuthorId;

            return(dto);
        }
示例#12
0
 public bool Apply(string arg, string next, PatchData data)
 {
     if (arg.EqualsIgnoreCase("/InitialPatch"))
     {
         data.RunSection = RunSection.InitialPatch;
         return(true);
     }
     if (arg.EqualsIgnoreCase("/LinkedPatch"))
     {
         data.RunSection = RunSection.LinkedPatch;
         return(true);
     }
     if (arg.EqualsIgnoreCase("/FinalPatch"))
     {
         data.RunSection = RunSection.FinalPatch;
         return(true);
     }
     return(false);
 }
示例#13
0
        public IHttpActionResult PatchUser(PatchData patchData)
        {
            User user = DataObject.GetEditableByPrimaryKey <User>(patchData.PrimaryKey, null, Enumerable.Empty <string>())?.PopulateActiveDirectoryInformation();

            if (user == null)
            {
                return(NotFound());
            }

            user.PatchData(patchData.Method, patchData.Values);

            if (!user.Save())
            {
                return(BadRequest());
            }

            user.UpdateActiveDirectoryInformation();

            return(Ok());
        }
示例#14
0
        public void SetPatch(PatchData patch)
        {
            PatchContainer.Subtitles.Visibility  = patch is SubtitlePatch ? Visibility.Visible : Visibility.Hidden;
            PatchContainer.Subtitles.DataContext = patch as SubtitlePatch;

            PatchContainer.VideoPatch.Visibility  = patch is VideoPatchBase ? Visibility.Visible : Visibility.Hidden;
            PatchContainer.VideoPatch.DataContext = patch as VideoPatchBase;

            PatchContainer.Image.Visibility  = patch is ImagePatch ? Visibility.Visible : Visibility.Hidden;
            PatchContainer.Image.DataContext = patch as ImagePatch;
            if (patch is ImagePatch)
            {
                var p           = patch as ImagePatch;
                var model       = (EditorModel)DataContext;
                var videotheque = model.Videotheque;
                var path        = System.IO.Path.Combine(videotheque.PatchFolder.FullName, p.RelativeFilePath);
                var uri         = new Uri(path);
                PatchContainer.Image.image.Source = new BitmapImage(uri);
            }
        }
示例#15
0
        private async void cmdSave_Click(object sender, EventArgs e)
        {
            Enabled = false;

            if (PreselectedSecurityGroups == null)
            {
                PatchData patch = new PatchData(DataAccess.APIs.UserManagement, "User/PatchUser", PatchData.PatchMethods.Replace, UserID, new Dictionary <string, object>()
                {
                    { "MemberOf", _selectedGroups }
                });

                await patch.Execute();
            }
            else
            {
                PreselectedSecurityGroups = _selectedGroups;
            }

            Close();
        }
示例#16
0
        public bool RunPatchScripts(PatchData data, out IPatcherMod[] ret)
        {
            var settings = CompilerSettings.CreatePatchScripts(data);

            if (settings.Files.Count == 0)
            {
                Logging.Log("No patch scripts found...");
                ret = Empty;
                return(true);
            }

            settings.AssemblyName = "PatchScripts";
            settings.OutputPath   = data.BuildFolder + settings.AssemblyName + ".dll";
            var compilerResults = Compile(data, settings); // ScriptCompiler.Compile(compilerSettings, Plugin.DataDirectory, gamePath, false);

            Logging.LogInfo($"Built patch file in {compilerResults.Duration}ms");

            if (compilerResults.Success == false)
            {
                Logging.LogError("Compile errors");
                foreach (var t in compilerResults.Warnings)
                {
                    Logging.LogWarning(t);
                }
                foreach (var t in compilerResults.Errors)
                {
                    Logging.LogError(t);
                }

                Logging.LogError("Failed to compile PatchMods");
                ret = Empty;
                return(false);
            }

            Logging.Log("PatchMods compile successful");
            var patches = compilerResults.Assembly.GetInterfaceImplementers <IPatcherMod>();

            Logging.Log("Found patcher mods: " + patches.Length);
            ret = patches;
            return(true);
        }
示例#17
0
    public override bool Read(string filename, ProgressInfo progress, out PatchData data)
    {
        data = null;

        using (var shapefile = new Shapefile(filename))
        {
            if (shapefile == null)
            {
                return(false);
            }

            // TODO: Rasterize shapefile
        }

        string rasterFile = Path.ChangeExtension(filename, "tif");

        GeoTiffInterpreter geoTiffInterpreter = new GeoTiffInterpreter();

        geoTiffInterpreter.Read(rasterFile, progress, out data);

        return(true);
    }
示例#18
0
    public PatchData(PatchData other)
    {
        west  = other.west;
        east  = other.east;
        north = other.north;
        south = other.south;
        units = other.units;

        if (other.metadata == null)
        {
            metadata = null;
        }
        else
        {
            metadata = new Metadata(other.metadata);
        }

        categoryMask = other.categoryMask;
        if (other.categories != null)
        {
            categories = (Category[])other.categories.Clone();
        }
    }
        public void PatchReturns401WhenUserDoesntOwnList()
        {
            var options = new DbContextOptionsBuilder <ReadingListApiContext>()
                          .UseInMemoryDatabase("patch_returns_401")
                          .Options;

            using (var context = new ReadingListApiContext(options))
            {
                ReadingList readingList      = new ReadingListFixture().ReadingList();
                User        user             = new UserFixture().User();
                User        unauthorizedUser = new User
                {
                    Email  = "unauthorized test email",
                    Avatar = "unauthorized test avatar",
                };
                user.ReadingLists.Add(readingList);
                context.Users.AddRange(new List <User>()
                {
                    user, unauthorizedUser
                });
                context.SaveChanges();

                SessionHelperStub     session    = new SessionHelperStub(unauthorizedUser);
                ReadingListController controller = new ReadingListController(context, session);

                PatchData data = new PatchData
                {
                    BookId  = readingList.Books[0].BookId,
                    Ranking = 2
                };

                var result = controller.Patch(readingList.ReadingListId, data);

                Assert.IsType <NotFoundResult>(result);
            }
        }
示例#20
0
    protected override void OnPatchBoundsChange(PatchData patchData)
    {
        base.OnPatchBoundsChange(patchData);

        UpdateProjectionValues();
    }
				public PatchInfo(int rvaDecryptMethod, PatchData patchData) {
					this.RvaDecryptMethod = rvaDecryptMethod;
					this.PatchData = new List<PatchData> { patchData };
				}
示例#22
0
 public PatchesViewControllerCell(PatchData data) : base(UITableViewCellStyle.Value1, Key)
 {
     TextLabel.Text = data.PatchName;
 }
示例#23
0
        public override bool Patch(PatchData data)
        {
            try
            {
                if (!BuildSettings.ScriptOnly)
                {
                    Logging.Log("Copying mod folders");

                    var disabledMods = data.InactiveMods;
                    for (int i = 0; i < disabledMods.Count; i++)
                    {
                        ModInfo mod = disabledMods[i];

                        string nativeModsDir = $"{data.GameFolder}\\Mods";
                        Helper.MakeFolder(nativeModsDir);

                        string sdxDir = $"{nativeModsDir}/{mod.Name}";

                        if (Directory.Exists(sdxDir))
                        {
                            if (i > 0)
                            {
                                Logging.NewLine();
                            }

                            Logging.LogInfo($"Removing disabled mod " + sdxDir);
                            Directory.Delete(sdxDir, true);
                        }
                    }
                }

                IList <ModInfo> enabledMods = data.ActiveMods;
                for (int i = 0; i < enabledMods.Count; i++)
                {
                    ModInfo mod = enabledMods[i];
                    if (i > 0)
                    {
                        Logging.NewLine();
                    }

                    Logging.Log($"Copy from {mod.Location}");

                    string nativeModsDir = $"{data.GameFolder}/Mods";
                    Helper.MakeFolder(nativeModsDir);

                    string gameModDir = $"{nativeModsDir}/{mod.Name}";
                    gameModDir.MakeFolder();

                    string modInfoSource      = $"{mod.Location}/ModInfo.xml";
                    string modInfoDestination = $"{gameModDir}/ModInfo.xml";
                    var    p1 = Path.GetFullPath(modInfoSource);
                    var    p2 = Path.GetFullPath(modInfoDestination);

                    if (p1.Equals(p2))
                    {
                        Logging.Log("Skipping copy as destination matches source: " + modInfoSource);
                        continue;
                    }

                    //Logging.Log("Copying ");
                    //Logging.Log("p1: " + p1);
                    //Logging.Log("p2: " + p2);

                    if (File.Exists(modInfoSource))
                    {
                        Logging.Log("Copying " + modInfoSource);
                        File.Copy(modInfoSource, modInfoDestination, true);
                    }
                    else
                    {
                        File.WriteAllText(modInfoDestination, $@"<?xml version=""1.0"" encoding=""UTF-8"" ?>
<xml>
	<ModInfo>
		<Name value=""{System.Security.SecurityElement.Escape(mod.Name)}"" />
		<Description value=""{System.Security.SecurityElement.Escape(mod.Description)}"" />
		<Author value=""{System.Security.SecurityElement.Escape(mod.Author)}"" />
		<Version value=""{System.Security.SecurityElement.Escape(mod.ModVersion)}"" />
		<Website value="""" />
	</ModInfo>
</xml>");
                    }

                    if (BuildSettings.ScriptOnly)
                    {
                        continue;
                    }

                    var foldersToCopy = new List <string>()
                    {
                        "ItemIcons",
                        "Config",
                        "Resources",
                        "Harmony",
                        "Texture",
                        "Textures",
                        "UIAtlases",
                        "Worlds",
                        "Prefabs",
                    };

                    foreach (var s in foldersToCopy)
                    {
                        CopyFolder(mod.Location, gameModDir, s, true, true);
                    }

                    CopyFolder($"{mod.Location}/Prefabs", $"{data.GameFolder}/Data/Prefabs", "", false, false);

                    var deployDir = $"{mod.Location}/Deploy";
                    if (Directory.Exists(deployDir))
                    {
                        CopyFolder(deployDir, gameModDir, "", false, true);
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                Logging.LogError(ex.Message);
            }

            return(false);
        }
示例#24
0
        public static CompilerSettings CreatePatchScripts(PatchData data)
        {
            CompilerSettings compilerSettings = new CompilerSettings();
            var patchScriptPaths = data.FindFiles("PatchScripts", "*.cs", true);

            if (patchScriptPaths.Count == 0)
            {
                //return compilerSettings;
            }

            foreach (string path in patchScriptPaths)
            {
                compilerSettings.Files.Add(path);
            }

            compilerSettings.GenerateInMemory = true;
            compilerSettings.AddReference("DMT.dll");
            compilerSettings.AddReference("Mono.Cecil.dll");
            compilerSettings.AddReferences(data.FindFiles("PatchScripts", "*.dll", true));

            var dllPaths = Directory.GetFiles(data.ManagedFolder, "*.dll").Where(d => d.EndsWith("/Mods.dll") == false && d.Contains("Assembly-CSharp") == false).ToArray();

            compilerSettings.AddReferences(dllPaths);

            if (data.RunSection == RunSection.InitialPatch)
            {
                compilerSettings.AddReference(data.BackupDllLocataion);
            }
            else if (data.RunSection == RunSection.LinkedPatch)
            {
                compilerSettings.AddReference(data.InitialDllLocation);
                //compilerSettings.AddReference(data.ManagedFolder + "Assembly-CSharp.dll");
            }
            else
            {
                compilerSettings.AddReference(data.LinkedDllLocation);
            }

            //for (int i = 0; i < dllPaths.Length; i++)
            //{
            //    var path = dllPaths[i];
            //    if (path.EndsWith(Path.DirectorySeparatorChar + "Assembly-CSharp.dll"))
            //    {
            //        var z = dllPaths[0];
            //        dllPaths[0] = path;
            //        dllPaths[i] = z;
            //        break;
            //    }
            //}

            List <string> namespaces = new List <string>();

            for (int i = 0; i < dllPaths.Length; i++)
            {
                string dllPath = dllPaths[i];
                if (!Path.GetFileName(dllPath).Contains("mscorlib") && !Path.GetFileName(dllPath).Contains("Mono.Cecil")) //
                {
                    var mod = data.ReadModuleDefinition(dllPath);
                    if (namespaces.Contains(mod.Name))
                    {
                        Logging.LogWarning($"Duplicate dll namespace found '{mod.Name}'. Skipping dll at path: '{dllPath}'");
                        continue;
                    }
                    namespaces.Add(mod.Name);
                    compilerSettings.AddReference(dllPath);
                }
            }

            compilerSettings.GenerateInMemory = true;
            return(compilerSettings);
        }
示例#25
0
文件: BaseTask.cs 项目: blipvert/DMT
 public virtual bool Patch(PatchData data)
 {
     return(true);
 }
示例#26
0
    //
    // Private/Protected Methods
    //

    protected virtual void OnPatchBoundsChange(PatchData patchData)
    {
        UpdateAreaCenterAndSize(patchData.north, patchData.east, patchData.south, patchData.west);
    }
示例#27
0
        public CompilerResult Compile(PatchData data, CompilerSettings settings)
        {
            CompilerResult scriptCompilerResults = new CompilerResult();

            if (File.Exists(settings.OutputPath))
            {
                scriptCompilerResults.Assembly = Assembly.LoadFile(settings.OutputPath);
                scriptCompilerResults.Success  = true;
                return(scriptCompilerResults);
            }


            Logging.Log("Compiling Roslyn Scripts assembly for " + data.RunSection + "...");

            var trees = new List <SyntaxTree>();

            foreach (var f in settings.Files)
            {
                var sourceCode = System.IO.File.ReadAllText(f);
                var tree       = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceCode)).WithFilePath(f);
                trees.Add(tree);
            }
            //var syntaxTree = SyntaxFactory.ParseSyntaxTree(SourceText.From(sourceCode));

            var assName = settings.AssemblyName;

            var compilation = CSharpCompilation.Create(assName)
                              .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, false, assName))
                              .AddReferences(
                settings.References.Select(d => MetadataReference.CreateFromFile(d))
                )
                              .AddSyntaxTrees(trees);

            //scriptCompilerResults.AssemblyLocation = assemblyPath;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            var result = compilation.Emit(settings.OutputPath);

            stopwatch.Stop();


            if (result.Success)
            {
                scriptCompilerResults.Assembly = Assembly.LoadFile(settings.OutputPath);
                scriptCompilerResults.Success  = true;
                //File.Copy(assemblyPath, data.ModsDllTempLocation, true);
            }

            foreach (var d in result.Diagnostics)
            {
                if (d.Severity == DiagnosticSeverity.Error)
                {
                    scriptCompilerResults.Errors.Add(d.ToString());
                }
                else
                {
                    if (d.ToString().Contains("Assuming assembly reference 'mscorlib") && (scriptCompilerResults.Warnings.Any(e => e.Contains("Assuming assembly reference 'mscorlib"))))
                    {
                        continue;
                    }
                    //result.Success ||
                    scriptCompilerResults.Warnings.Add(d.ToString());
                }
            }


            return(scriptCompilerResults);
        }
示例#28
0
 public void Test_GetAssemblyByName_NoAssembly()
 {
     Assert.Throws <DllNotFoundException>(() => PatchData.GetAssemblyByNameAndVersion("null", "*"));
 }
示例#29
0
    private void GenerateTerrain()
    {
        GameObject = new GameObject
        {
            name  = "Patch_LOD_ " + SplitLevel + " : [" + Up + "]",
            layer = Sphere.gameObject.layer
        };

        Mesh = new Mesh();
        Data = new PatchData(PatchSettings.Vertices);

        var origin  = Volume.Vertices[0];
        var spacing = Size / (PatchSettings.VerticesPerSide - 1);

        for (ushort y = 0; y < PatchSettings.VerticesPerSide; y++)
        {
            var offset = origin;

            for (ushort x = 0; x < PatchSettings.VerticesPerSide; x++)
            {
                var vertex = offset;

                Data.Vertices.Add(vertex.NormalizeToRadius(Sphere.Radius));
                Data.Normals.Add(vertex.normalized);
                Data.Volume.Add(offset);

                Data.UV1.Add(VectorHelper.CartesianToPolarUV(vertex));
                Data.UV2.Add(new Vector2(0, 0));

                offset += Right * spacing;
            }

            origin -= Front * spacing;
        }

        //update projected center
        MiddleProjected = MiddleProjected.NormalizeToRadius(Sphere.Radius);

        //save original parent transformations
        var parentPosition = Sphere.gameObject.transform.position;
        var parentRotation = Sphere.gameObject.transform.rotation;

        //reset parent transformations before assigning data (so our vertices will be centered on the parent transform)
        Sphere.gameObject.transform.position = Vector3.zero;
        Sphere.gameObject.transform.rotation = Quaternion.identity;

        //put this node as a child of parent
        GameObject.transform.parent = Sphere.gameObject.transform;

        var indices = Sphere.PatchManager.Patches[Edges];

        //assign data to this node's mesh
        Mesh.SetVertices(Data.Vertices);
        Mesh.SetNormals(Data.Normals);
        Mesh.SetTriangles(indices, 0);
        Mesh.SetUVs(0, Data.UV1);
        Mesh.SetUVs(1, Data.UV2);

        Mesh.hideFlags = HideFlags.HideAndDontSave;

        Mesh.SolveTangents(ref indices, ref Data.Vertices, ref Data.Normals, ref Data.UV1);
        Mesh.RecalculateBounds();

        //restore parent transformations
        Sphere.gameObject.transform.position = parentPosition;
        Sphere.gameObject.transform.rotation = parentRotation;

        NeedsTerrain = false;

        //discard parent's resources
        if (Parent != null)
        {
            Parent.DestroyNode();
        }

        var patch      = GameObject.AddComponent <Patch>();
        var meshFilter = GameObject.AddComponent <MeshFilter>();

        GameObject.AddComponent <MeshRenderer>();
        GameObject.GetComponent <MeshRenderer>().sharedMaterial = MaterialHelper.CreateTemp(Sphere.Shader, "Patch");

        meshFilter.mesh = Mesh;
        patch.PatchTree = this;
    }
示例#30
0
 public PointData(PatchData other) : base(other)
 {
 }
				public PatchInfo(int rvaDecryptMethod, PatchData patchData) {
					RvaDecryptMethod = rvaDecryptMethod;
					PatchData = new List<PatchData> { patchData };
				}