public static LwoObject CopyObject(this AccessDatabase @this, int lot, int id = -1) { var source = @this.LoadObject(lot); var destination = @this.NewObject(id); foreach (var column in source.Row) { if (column.Name == "id") { continue; } destination.Row[column.Name].Value = column.Value; destination.Row[column.Name].Type = column.Type; } foreach (var component in source) { var destinationComponent = new LwoComponent(component.Id); destination.Add(destinationComponent); var sourceRow = component.Row; if (sourceRow == default) { continue; } var destinationRow = destinationComponent.Row; foreach (var column in sourceRow) { if (column.Name == "id") { continue; } destinationRow[column.Name].Value = column.Value; destinationRow[column.Name].Type = column.Type; } } return(destination); }
public static async Task ExportToWavefrontAsync(this LuzFile @this, AccessDatabase database, string source, string resources, string result) { TerrainFile terrain; await using (var stream = File.OpenRead(Path.Combine(source, @this.TerrainFileName))) { using var reader = new BitReader(stream); terrain = new TerrainFile(); terrain.Deserialize(reader); } var levels = new LvlFile[@this.Scenes.Length]; for (var i = 0; i < @this.Scenes.Length; i++) { var scene = @this.Scenes[i]; await using var stream = File.OpenRead(Path.Combine(source, scene.FileName)); using var reader = new BitReader(stream); var level = new LvlFile(); level.Deserialize(reader); levels[i] = level; } var objects = new List <LevelObjectTemplate>(); foreach (var level in levels) { if (level.LevelObjects?.Templates == default) { continue; } foreach (var template in level.LevelObjects.Templates) { if (!template.LegoInfo.TryGetValue("add_to_navmesh", out var add)) { continue; } if (!(bool)add) { continue; } objects.Add(template); } } foreach (var template in objects) { var instance = database.LoadObject(template.Lot); var renderer = instance.GetComponent <RenderComponentTable>(); if (renderer == default) { continue; } Console.WriteLine(renderer.render_asset); } }