diff --git a/.gitignore b/.gitignore index cef7dc8..37dba55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,81 @@ .vs/ +.vscode/ +.vsconfig Library/ obj/ Temp/ *.csproj -*.suo -*.sln +*.suo*.sln + jkedit/ -Extracted/ \ No newline at end of file +Extracted/ + +/[Ll]ibrary/ +/[Tt]emp/ +/[Oo]bj/ +/[Bb]uild/ +/[Bb]uilds/ +/[Ll]ogs/ +/[Uu]ser[Ss]ettings/ + +# MemoryCaptures can get excessive in size. +# They also could contain extremely sensitive data +/[Mm]emoryCaptures/ + +# Recordings can get excessive in size +/[Rr]ecordings/ + +# Uncomment this line if you wish to ignore the asset store tools plugin +# /[Aa]ssets/AssetStoreTools* + +# Autogenerated Jetbrains Rider plugin +/[Aa]ssets/Plugins/Editor/JetBrains* + +# Visual Studio cache directory +.vs/ + +# Gradle cache directory +.gradle/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.mdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta +*.mdb.meta + +# Unity3D generated file on crash reports +sysinfo.txt + +# Builds +*.apk +*.aab +*.unitypackage +*.app + +# Crashlytics generated file +crashlytics-build.properties + +# Packed Addressables +/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* + +# Temporary auto-generated Android Assets +/[Aa]ssets/[Ss]treamingAssets/aa.meta +/[Aa]ssets/[Ss]treamingAssets/aa/* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c1e71fc..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Unity Editor", - "type": "unity", - "request": "launch" - }, - { - "name": "Windows Player", - "type": "unity", - "request": "launch" - }, - { - "name": "OSX Player", - "type": "unity", - "request": "launch" - }, - { - "name": "Linux Player", - "type": "unity", - "request": "launch" - }, - { - "name": "iOS Player", - "type": "unity", - "request": "launch" - }, - { - "name": "Android Player", - "type": "unity", - "request": "launch" - } - ] -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4edd970..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "files.exclude": - { - "**/.DS_Store":true, - "**/.git":true, - "**/.gitignore":true, - "**/.gitmodules":true, - "**/*.booproj":true, - "**/*.pidb":true, - "**/*.suo":true, - "**/*.user":true, - "**/*.userprefs":true, - "**/*.unityproj":true, - "**/*.dll":true, - "**/*.exe":true, - "**/*.pdf":true, - "**/*.mid":true, - "**/*.midi":true, - "**/*.wav":true, - "**/*.gif":true, - "**/*.ico":true, - "**/*.jpg":true, - "**/*.jpeg":true, - "**/*.png":true, - "**/*.psd":true, - "**/*.tga":true, - "**/*.tif":true, - "**/*.tiff":true, - "**/*.3ds":true, - "**/*.3DS":true, - "**/*.fbx":true, - "**/*.FBX":true, - "**/*.lxo":true, - "**/*.LXO":true, - "**/*.ma":true, - "**/*.MA":true, - "**/*.obj":true, - "**/*.OBJ":true, - "**/*.asset":true, - "**/*.cubemap":true, - "**/*.flare":true, - "**/*.mat":true, - "**/*.meta":true, - "**/*.prefab":true, - "**/*.unity":true, - "build/":true, - "Build/":true, - "Library/":true, - "library/":true, - "obj/":true, - "Obj/":true, - "ProjectSettings/":true, - "temp/":true, - "Temp/":true - } -} \ No newline at end of file diff --git a/Assets/DeactivateLights.cs b/Assets/DeactivateLights.cs new file mode 100644 index 0000000..b832715 --- /dev/null +++ b/Assets/DeactivateLights.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +[ExecuteAlways] +public class DeactivateLights : MonoBehaviour +{ + public bool deacivateLights; + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + if (deacivateLights) + { + Light[] lights = GetComponentsInChildren(); + + foreach (Light light in lights) + { + light.enabled = false; + } + deacivateLights = false; + DestroyImmediate(this); + } + } +} diff --git a/Assets/Scripts/GOBManager.cs.meta b/Assets/DeactivateLights.cs.meta similarity index 83% rename from Assets/Scripts/GOBManager.cs.meta rename to Assets/DeactivateLights.cs.meta index 531c53c..4a67a43 100644 --- a/Assets/Scripts/GOBManager.cs.meta +++ b/Assets/DeactivateLights.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c583c298051cfe54dbcde7b3faaf5d74 +guid: a2e3e61a45554c4409855e6e5517a24d MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Editor/SithEditor.cs b/Assets/Editor/SithEditor.cs index e14a101..c03e603 100644 --- a/Assets/Editor/SithEditor.cs +++ b/Assets/Editor/SithEditor.cs @@ -1,11 +1,16 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using jksharp.jklviewer; using UnityEditor; using UnityEngine; using System.Collections; -using Assets.Scripts; +using Assets.Sith; + +using Assets.Sith.Content; +using Assets.Sith.Game; +using Assets.Sith.Game.World; +using Assets.Sith.Vfs; + public class SithEditor : EditorWindow { @@ -15,10 +20,12 @@ public static void ShowWindow() EditorWindow.GetWindow(typeof(SithEditor)); } - private string _jkPath = @"D:\Spel\Steam\steamapps\common\Star Wars Jedi Knight"; + private string _gamePath = @""; private string _assetPath = "Extracted\\"; private IEnumerable _gobFiles; private bool _gobFilesEnabled; + private IEnumerable _levelFiles; + private Vector2 _scrollPos; void Start() { @@ -26,10 +33,13 @@ void Start() void OnGUI() { - _jkPath = EditorGUILayout.TextField("Jedi Knight path", _jkPath); + _gamePath = EditorGUILayout.TextField("Game path", _gamePath); + if (!Directory.Exists(_gamePath)) return; if (GUILayout.Button("Find GOBs")) { - _gobFiles = Directory.GetFiles(_jkPath, "*.gob", SearchOption.AllDirectories).Select(x => new GobFile { Path = x.Replace(_jkPath + "\\", ""), Enabled = false }).ToArray(); + _gobFiles = Directory.EnumerateFiles(_gamePath, "*.*", SearchOption.AllDirectories) + .Where(s => s.ToLower().EndsWith(".gob") || s.ToLower().EndsWith(".goo")) + .Select(x => new GobFile { Path = x.Replace(_gamePath + "\\", ""), Enabled = false }).ToArray(); } if (_gobFiles != null) @@ -47,12 +57,69 @@ void OnGUI() { foreach (var gobFile in _gobFiles.Where(x => x.Enabled)) { - using (var stream = new GOBStream(Path.Combine(_jkPath, gobFile.Path))) + using (var stream = new GOBStream(Path.Combine(_gamePath, gobFile.Path))) { stream.Extract(Path.Combine(_assetPath, gobFile.Path)); } } } + + if (GUILayout.Button("Find levels")) + { + _levelFiles = Directory.EnumerateFiles(_gamePath, "*.*", SearchOption.AllDirectories) + .Where(s => s.ToLower().EndsWith(".jkl") || s.ToLower().EndsWith(".ndy")) + .Select(x => x.Replace(_gamePath + "\\", "")) + .ToArray(); + } + + if (_levelFiles != null) + { + GUILayout.Label("Level Files"); + EditorGUILayout.BeginHorizontal(); + _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos); + foreach (var file in _levelFiles) + { + //gobFile.Enabled = EditorGUILayout.Toggle(gobFile.Path, gobFile.Enabled); + EditorGUILayout.BeginHorizontal(); + GUILayout.Label(file); + if (GUILayout.Button("Load", GUILayout.Width(100))) + { + SithAssets.Instance.AddSystemPath(_gamePath); + SithAssets.Instance.AddSystemPath(Path.Combine(_gamePath, "Resource")); + SithAssets.Instance.AddSystemPath(Path.Combine(_gamePath, "Extracted")); + + // JKDF2 + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\Res1hi.gob")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\Res2.gob")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JK1.GOB")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JK1CTF.GOB")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JK1MP.GOB")); + + // MOTS + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\JKMRES.GOO")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\JKMsndLO.goo")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JKM.GOO")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JKM_KFY.GOO")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\JKM_MP.GOO")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Episode\\Jkm_saber.GOO")); + + // IJIM + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "cd1.gob")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "cd2.gob")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\cd1.gob")); + SithAssets.Instance.AddGob(Path.Combine(_gamePath, "Resource\\cd2.gob")); + + var go = new GameObject("SithWorld"); + var world = go.AddComponent(); + world.Load(file); + } + + EditorGUILayout.EndHorizontal(); + } + EditorGUILayout.EndScrollView(); + EditorGUILayout.EndHorizontal(); + } + } class GobFile diff --git a/Assets/ExportMaterial.cs b/Assets/ExportMaterial.cs new file mode 100644 index 0000000..e8ba543 --- /dev/null +++ b/Assets/ExportMaterial.cs @@ -0,0 +1,65 @@ +using System.Collections; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; +using UnityEditor; +using UnityEngine.UI; +using System.IO; + +public class ExportMaterial : MonoBehaviour +{ + public bool export; + //public Button m_HitMeButton; + + private void Start() + { + //Button btn = m_HitMeButton.GetComponent