Skip to content

Commit 809969a

Browse files
committed
Merge branch 'beta'
2 parents a20ca0e + e4a81cf commit 809969a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+756
-547
lines changed

.vsconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "1.0",
3+
"components": [
4+
"Microsoft.VisualStudio.Workload.ManagedGame"
5+
]
6+
}

Assets/Facepunch/RustWorldSDK/TerrainMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,4 @@ public void FromByteArray(byte[] dat)
7575
{
7676
Buffer.BlockCopy(dat, 0, dst, 0, dat.Length);
7777
}
78-
}
78+
}

Assets/Facepunch/RustWorldSDK/WorldSerialization.cs

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using UnityEngine;
22
using System;
33
using System.Collections.Generic;
4-
using System.Linq;
54
using System.IO;
65
using ProtoBuf;
76
using LZ4;
@@ -47,6 +46,17 @@ public class PrefabData
4746
[ProtoMember(3)] public VectorData position;
4847
[ProtoMember(4)] public VectorData rotation;
4948
[ProtoMember(5)] public VectorData scale;
49+
50+
51+
public PrefabData() { }
52+
public PrefabData(string category, uint id, Vector3 position, Quaternion rotation, Vector3 scale)
53+
{
54+
this.category = category;
55+
this.id = id;
56+
this.position = position;
57+
this.rotation = rotation;
58+
this.scale = scale;
59+
}
5060
}
5161

5262
[Serializable]
@@ -113,9 +123,7 @@ public static implicit operator Quaternion(VectorData v)
113123
public MapData GetMap(string name)
114124
{
115125
for (int i = 0; i < world.maps.Count; i++)
116-
{
117126
if (world.maps[i].name == name) return world.maps[i];
118-
}
119127
return null;
120128
}
121129

@@ -129,52 +137,6 @@ public void AddMap(string name, byte[] data)
129137
world.maps.Add(map);
130138
}
131139

132-
public IEnumerable<PrefabData> GetPrefabs(string category)
133-
{
134-
return world.prefabs.Where(p => p.category == category);
135-
}
136-
137-
public void AddPrefab(string category, uint id, Vector3 position, Quaternion rotation, Vector3 scale)
138-
{
139-
var prefab = new PrefabData();
140-
141-
prefab.category = category;
142-
prefab.id = id;
143-
prefab.position = position;
144-
prefab.rotation = rotation;
145-
prefab.scale = scale;
146-
147-
world.prefabs.Add(prefab);
148-
}
149-
150-
public IEnumerable<PathData> GetPaths(string name)
151-
{
152-
return world.paths.Where(p => p.name.Contains(name));
153-
}
154-
155-
public PathData GetPath(string name)
156-
{
157-
for (int i = 0; i < world.paths.Count; i++)
158-
{
159-
if (world.paths[i].name == name) return world.paths[i];
160-
}
161-
return null;
162-
}
163-
164-
public void AddPath(PathData path)
165-
{
166-
world.paths.Add(path);
167-
}
168-
169-
public void Clear()
170-
{
171-
world.maps.Clear();
172-
world.prefabs.Clear();
173-
world.paths.Clear();
174-
175-
Version = CurrentVersion;
176-
}
177-
178140
public void Save(string fileName)
179141
{
180142
try

Assets/MapEditor/Editor/API/Elements.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public static bool ToolbarCheckBox(GUIContent guiContent, bool toggle)
2727
return EditorGUILayout.ToggleLeft(guiContent, toggle, "ToolbarButton");
2828
}
2929

30-
public static void ToolbarLabelField(GUIContent label, GUIContent label2)
31-
{
32-
EditorGUILayout.LabelField(label, label2);
33-
}
34-
3530
public static string ToolbarTextField(string text)
3631
{
3732
return EditorGUILayout.TextField(text, EditorStyles.toolbarTextField);
@@ -42,6 +37,11 @@ public static string ToolbarDelayedTextField(string text)
4237
return EditorGUILayout.DelayedTextField(text, EditorStyles.toolbarTextField);
4338
}
4439

40+
public static void ToolbarSelectableLabel(string text)
41+
{
42+
EditorGUILayout.SelectableLabel(text, EditorStyles.toolbarButton);
43+
}
44+
4545
public static int ToolbarIntField(int value)
4646
{
4747
return EditorGUILayout.IntField(value, EditorStyles.toolbarTextField);

Assets/MapEditor/Editor/API/Functions.cs

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ public static void NewMap()
5757
NewMapPanel();
5858
}
5959

60-
public static void NewMapPanel()
61-
{
62-
CreateMapWindow.Init();
63-
}
64-
60+
public static void NewMapPanel() => CreateMapWindow.Init();
61+
6562
public static void MapInfo()
6663
{
6764
if (Land != null)
@@ -152,7 +149,7 @@ public static void EditorSettings()
152149
#endregion
153150

154151
#region Prefabs
155-
public static void PrefabTools(ref bool deleteOnExport, string lootCrateSaveFile = "", string mapPrefabSaveFile = "")
152+
public static void PrefabTools()
156153
{
157154
Elements.MiniBoldLabel(ToolTips.toolsLabel);
158155

@@ -163,6 +160,7 @@ public static void PrefabTools(ref bool deleteOnExport, string lootCrateSaveFile
163160
PathManager.DeletePaths(PathManager.CurrentMapPaths);
164161
Elements.EndToolbarHorizontal();
165162
}
163+
166164
public static void AssetBundle()
167165
{
168166
Elements.MiniBoldLabel(ToolTips.assetBundleLabel);
@@ -645,14 +643,6 @@ public static void ToggleLights(PrefabDataHolder target)
645643
target.ToggleLights();
646644
Elements.EndToolbarHorizontal();
647645
}
648-
649-
public static void BreakPrefab(PrefabDataHolder target)
650-
{
651-
Elements.BeginToolbarHorizontal();
652-
if (Elements.ToolbarButton(ToolTips.breakPrefab))
653-
target.BreakPrefab();
654-
Elements.EndToolbarHorizontal();
655-
}
656646
#endregion
657647

658648
#region Functions
@@ -707,21 +697,21 @@ public static void DisplayPrefabName(string name)
707697
Elements.EndToolbarHorizontal();
708698
}
709699

710-
public static void DisplayPrefabID(WorldSerialization.PrefabData prefab)
700+
public static void DisplayPrefabID(uint prefabID)
711701
{
712702
Elements.BeginToolbarHorizontal();
713703
if (Elements.ToolbarButton(ToolTips.prefabID))
714-
CopyText(prefab.id.ToString());
715-
Elements.ToolbarLabel(new GUIContent(prefab.id.ToString(), prefab.id.ToString()));
704+
CopyText(prefabID.ToString());
705+
Elements.ToolbarLabel(new GUIContent(prefabID.ToString(), prefabID.ToString()));
716706
Elements.EndToolbarHorizontal();
717707
}
718708

719-
public static void DisplayPrefabPath(WorldSerialization.PrefabData prefab)
709+
public static void DisplayPrefabPath(string prefabPath)
720710
{
721711
Elements.BeginToolbarHorizontal();
722712
if (Elements.ToolbarButton(ToolTips.prefabPath))
723-
CopyText(AssetManager.ToPath(prefab.id));
724-
Elements.ToolbarLabel(new GUIContent(AssetManager.ToPath(prefab.id), AssetManager.ToPath(prefab.id)));
713+
CopyText(prefabPath);
714+
Elements.ToolbarLabel(new GUIContent(prefabPath, prefabPath));
725715
Elements.EndToolbarHorizontal();
726716
}
727717

@@ -737,7 +727,7 @@ public static void SelectPrefabPaths(PrefabsListTreeView treeView, ref bool show
737727
}
738728

739729

740-
public static void HierachyOptions(PrefabDataHolder[] prefabs, ref string name)
730+
public static void PrefabHierachyOptions(PrefabHierarchyTreeView treeView, ref string name, ref bool replace)
741731
{
742732
Elements.MiniBoldLabel(ToolTips.hierachyOptionsLabel);
743733

@@ -746,16 +736,29 @@ public static void HierachyOptions(PrefabDataHolder[] prefabs, ref string name)
746736
Elements.EndToolbarHorizontal();
747737

748738
Elements.BeginToolbarHorizontal();
749-
if (Elements.ToolbarButton(ToolTips.hierachyRename))
739+
if (Elements.ToolbarButton(ToolTips.hierachyCategoryRename))
750740
{
751-
PrefabManager.RenamePrefabs(prefabs, name);
741+
name = String.IsNullOrEmpty(name) ? "" : name;
742+
PrefabManager.RenamePrefabCategories(PrefabHierarchyTreeView.PrefabDataFromSelection(treeView), name);
752743
ReloadTreeViews();
753744
}
754745
Elements.EndToolbarHorizontal();
755746

747+
Elements.BeginToolbarHorizontal();
748+
replace = Elements.ToolbarToggle(ToolTips.hierachyReplace, replace);
749+
if (Elements.ToolbarButton(ToolTips.hierachyIDRename))
750+
{
751+
if (uint.TryParse(name, out uint result))
752+
{
753+
PrefabManager.RenamePrefabIDs(PrefabHierarchyTreeView.PrefabDataFromSelection(treeView), result, replace);
754+
ReloadTreeViews();
755+
}
756+
}
757+
Elements.EndToolbarHorizontal();
758+
756759
Elements.BeginToolbarHorizontal();
757760
if (Elements.ToolbarButton(ToolTips.hierachyDelete))
758-
PrefabManager.DeletePrefabs(prefabs);
761+
PrefabManager.DeletePrefabs(PrefabHierarchyTreeView.PrefabDataFromSelection(treeView));
759762
Elements.EndToolbarHorizontal();
760763
}
761764
#endregion

Assets/MapEditor/Editor/Managers/ShortcutManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public static class ShortcutManager
5959
public static void OpenMainMenu() => EditorWindow.GetWindow(typeof(MapManagerWindow), false, "Rust Map Editor");
6060

6161
[Shortcut("RustMapEditor/Settings Menu"), MenuItem("Rust Map Editor/Settings", false, 0)]
62-
public static void OpenSettings() => SettingsWindow.Init();
62+
public static void OpenSettingsMenu() => SettingsWindow.Init();
63+
64+
[Shortcut("RustMapEditor/Layers Menu"), MenuItem("Rust Map Editor/Layers", false, 0)]
65+
public static void OpenLayersMenu() => LayersWindow.Init();
6366

6467
[Shortcut("RustMapEditor/Prefab Hierarchy"), MenuItem("Rust Map Editor/Hierarchy/Prefabs", false, 1)]
6568
public static void OpenPrefabHierarchy() => EditorWindow.GetWindow(typeof(PrefabHierarchyWindow), false, "Prefab Hierarchy");

Assets/MapEditor/Editor/TreeView/PrefabHierarchy/PrefabHierarchyElement.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
namespace RustMapEditor.UI
44
{
55
[Serializable]
6-
internal class PrefabHierarchyElement : TreeElement
6+
public class PrefabHierarchyElement : TreeElement
77
{
8-
public string prefabName, type, category;
9-
public uint rustID;
8+
public string PrefabName, Type, Category;
9+
public uint RustID;
1010
public PrefabDataHolder prefabDataHolder;
1111

12-
public PrefabHierarchyElement (string name, int depth, int id) : base (name, depth, id)
12+
public PrefabHierarchyElement (int depth, int id, string name, string type= "", string category = "", uint rustID = 0) : base (name, depth, id)
1313
{
1414
if (!String.IsNullOrEmpty(name))
1515
{
16-
var values = name.Split(':');
17-
prefabName = values[0];
18-
type = values[1];
19-
category = values[2];
20-
rustID = uint.Parse(values[3]);
16+
PrefabName = name.Split(':')[0];
17+
Type = type;
18+
Category = category;
19+
RustID = rustID;
2120
}
2221
}
2322
}

0 commit comments

Comments
 (0)