From 90cb0a60e27be4be2458aee1c6961f543f3110c9 Mon Sep 17 00:00:00 2001 From: igorseabra4 Date: Fri, 28 Sep 2018 00:25:27 -0300 Subject: [PATCH] env, tssm events, transparency --- IndustrialPark/ArchiveEditor/ArchiveEditor.cs | 63 +- .../ArchiveEditor/ArchiveEditorFunctions.cs | 84 +- .../AssetEditor/InternalAssetEditor.cs | 8 +- .../AssetEditor/InternalCamEditor.cs | 31 +- .../AssetEditor/InternalDynaEditor.cs | 18 +- .../AssetEditor/InternalSoundEditor.cs | 12 +- .../AssetEditor/InternalTextEditor.cs | 20 +- IndustrialPark/Assets/Binary/AssetMAPR.cs | 4 +- IndustrialPark/Assets/Binary/AssetPICK.cs | 2 + .../Assets/ObjectAssets/AssetENV.cs | 109 +++ .../ObjectAssets/ClickableAssets/AssetCAM.cs | 9 +- .../ObjectAssets/ClickableAssets/AssetMRKR.cs | 9 +- .../ObjectAssets/ClickableAssets/AssetMVPT.cs | 9 +- .../PlaceableAssets/AssetTRIG.cs | 18 +- IndustrialPark/Assets/Renderable/AssetJSP.cs | 7 +- IndustrialPark/Assets/Shared/Asset.cs | 36 - IndustrialPark/Assets/Shared/AssetEvent.cs | 118 ++- .../Assets/Shared/AssetEventBFBB.cs | 21 + .../Assets/Shared/AssetEventTSSM.cs | 21 + .../Assets/Shared/Enums/EventType.cs | 2 +- .../Assets/Shared/Enums/EventTypeTSSM.cs | 809 ++++++++++++++++++ .../Shared/Interfaces/IRenderableAsset.cs | 2 + IndustrialPark/Assets/Shared/ObjectAsset.cs | 40 +- .../Assets/Shared/PlaceableAsset.cs | 9 +- IndustrialPark/IndustrialPark.csproj | 4 + IndustrialPark/MainForm/AboutBox.Designer.cs | 2 +- IndustrialPark/MainForm/MainForm.cs | 24 +- IndustrialPark/SharpDX/RenderWareModelFile.cs | 2 +- IndustrialPark/SharpDX/SharpRenderer.cs | 103 ++- IndustrialPark/SharpDX/TextureManager.cs | 2 +- 30 files changed, 1331 insertions(+), 267 deletions(-) create mode 100644 IndustrialPark/Assets/ObjectAssets/AssetENV.cs create mode 100644 IndustrialPark/Assets/Shared/AssetEventBFBB.cs create mode 100644 IndustrialPark/Assets/Shared/AssetEventTSSM.cs create mode 100644 IndustrialPark/Assets/Shared/Enums/EventTypeTSSM.cs diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs index 10c86177..dcb0fea6 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditor.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditor.cs @@ -88,10 +88,16 @@ private void closeToolStripMenuItem_Click(object sender, EventArgs e) } archive.Dispose(); + Program.MainForm.CloseAssetEditor(this); Close(); } + public void DisposeAll() + { + archive.Dispose(); + } + private bool programIsChangingStuff = false; public bool HasAsset(uint assetID) @@ -330,7 +336,6 @@ private void buttonRemoveAsset_Click(object sender, EventArgs e) { if (listBoxAssets.SelectedIndex < 0) return; - RemoveInternalEditor(CurrentlySelectedAssetID()); archive.RemoveAsset(CurrentlySelectedAssetID()); comboBoxLayers.Items[comboBoxLayers.SelectedIndex] = LayerToString(comboBoxLayers.SelectedIndex); @@ -359,7 +364,6 @@ private void buttonEditAsset_Click(object sender, EventArgs e) if (success) { UnsavedChanges = true; - RemoveInternalEditor(oldAssetID); archive.RemoveAsset(oldAssetID); while (archive.ContainsAsset(AHDR.assetID)) @@ -382,43 +386,11 @@ private void buttonEditAsset_Click(object sender, EventArgs e) } } - private List internalEditors = new List(); - - public void RemoveInternalEditor(IInternalEditor i) - { - internalEditors.Remove(i); - } - - public void RemoveInternalEditor(uint assetID) - { - for (int i = 0; i < internalEditors.Count; i++) - if (internalEditors[i].GetAssetID() == assetID) - internalEditors[i].Close(); - } - private void buttonInternalEdit_Click(object sender, EventArgs e) { if (listBoxAssets.SelectedItem != null) { - Asset asset = archive.GetFromAssetID(CurrentlySelectedAssetID()); - - for (int i = 0; i < internalEditors.Count; i++) - if (internalEditors[i].GetAssetID() == asset.AHDR.assetID) - internalEditors[i].Close(); - - if (asset is AssetCAM CAM) - internalEditors.Add(new InternalCamEditor(CAM, this)); - else if (asset is AssetDYNA DYNA) - internalEditors.Add(new InternalDynaEditor(DYNA, this)); - else if (asset is AssetTEXT TEXT) - internalEditors.Add(new InternalTextEditor(TEXT, this)); - else if (asset.AHDR.assetType == AssetType.SND | asset.AHDR.assetType == AssetType.SNDS) - internalEditors.Add(new InternalSoundEditor(asset, this)); - else - internalEditors.Add(new InternalAssetEditor(asset, this)); - - internalEditors.Last().Show(); - + archive.OpenInternalEditor(); UnsavedChanges = true; } } @@ -499,23 +471,21 @@ private void listBoxAssets_SelectedIndexChanged(object sender, EventArgs e) } } - public void ScreenClicked(Ray ray, bool isMouseDown) + public static void ScreenClicked(Ray ray, bool isMouseDown) { if (isMouseDown) - archive.GizmoSelect(ray); - else if (archive.FinishedMovingGizmo) - archive.FinishedMovingGizmo = false; + ArchiveEditorFunctions.GizmoSelect(ray); else { - uint assetID = archive.GetClickedAssetID(ray); + uint assetID = ArchiveEditorFunctions.GetClickedAssetID(ray); if (assetID != 0) - SetSelectedIndex(assetID); + Program.MainForm.SetSelectedIndex(assetID); } } - public void ScreenUnclicked() + public static void ScreenUnclicked() { - archive.ScreenUnclicked(); + ArchiveEditorFunctions.ScreenUnclicked(); } public void MouseMoveX(SharpCamera camera, int deltaX) @@ -528,10 +498,14 @@ public void MouseMoveY(SharpCamera camera, int deltaY) archive.MouseMoveY(camera, deltaY); } - private void SetSelectedIndex(uint assetID) + public void SetSelectedIndex(uint assetID) { if (!archive.ContainsAsset(assetID)) + { + archive.SelectAsset(0); + listBoxAssets.SelectedIndex = -1; return; + } try { @@ -554,6 +528,7 @@ private void SetSelectedIndex(uint assetID) } System.Drawing.Color defaultColor; + private void textBoxFindAsset_TextChanged(object sender, EventArgs e) { uint assetID = 0; diff --git a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs index 75c84cbd..571231e6 100644 --- a/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs +++ b/IndustrialPark/ArchiveEditor/ArchiveEditorFunctions.cs @@ -13,7 +13,9 @@ namespace IndustrialPark { public class ArchiveEditorFunctions { - public static HashSet renderableAssetSet = new HashSet(); + public static HashSet renderableAssetSetCommon = new HashSet(); + public static HashSet renderableAssetSetTrans = new HashSet(); + public static HashSet renderableAssetSetJSP = new HashSet(); public static Dictionary renderingDictionary = new Dictionary(); public static void AddToRenderingDictionary(uint key, IAssetWithModel value) @@ -188,6 +190,12 @@ private void AddAssetToDictionary(Section_AHDR AHDR) assetDictionary.Add(AHDR.assetID, newAsset); } break; + case AssetType.ENV: + { + AssetENV newAsset = new AssetENV(AHDR); + assetDictionary.Add(AHDR.assetID, newAsset); + } + break; case AssetType.FOG: { AssetFOG newAsset = new AssetFOG(AHDR); @@ -340,7 +348,6 @@ private void AddAssetToDictionary(Section_AHDR AHDR) case AssetType.DTRK: case AssetType.DUPC: case AssetType.EGEN: - case AssetType.ENV: case AssetType.GRSM: case AssetType.GUST: case AssetType.HANG: @@ -419,6 +426,8 @@ public void AddAssetWithUniqueID(int layerIndex, Section_AHDR AHDR) public void RemoveAsset(uint assetID) { + CloseInternalEditor(currentlySelectedAssetID); + for (int i = 0; i < DICT.LTOC.LHDRList.Count; i++) if (DICT.LTOC.LHDRList[i].assetIDlist.Contains(assetID)) DICT.LTOC.LHDRList[i].assetIDlist.Remove(assetID); @@ -438,8 +447,14 @@ public void RemoveAsset(uint assetID) private void DisposeAsset(uint key) { if (assetDictionary[key] is IRenderableAsset ra) - if (renderableAssetSet.Contains(ra)) - renderableAssetSet.Remove(ra); + { + if (renderableAssetSetCommon.Contains(ra)) + renderableAssetSetCommon.Remove(ra); + else if (renderableAssetSetTrans.Contains(ra)) + renderableAssetSetTrans.Remove(ra); + else if (renderableAssetSetJSP.Contains(ra)) + renderableAssetSetJSP.Remove((AssetJSP)ra); + } if (renderingDictionary.ContainsKey(key)) renderingDictionary.Remove(key); @@ -466,6 +481,7 @@ public void SelectAsset(uint assetID) if (assetDictionary.ContainsKey(currentlySelectedAssetID)) assetDictionary[currentlySelectedAssetID].isSelected = false; currentlySelectedAssetID = assetID; + if (currentlySelectedAssetID != 0) { assetDictionary[currentlySelectedAssetID].isSelected = true; @@ -474,7 +490,6 @@ public void SelectAsset(uint assetID) else ClearGizmos(); } - else ClearGizmos(); } public int GetLayerFromAssetID(uint assetID) @@ -486,12 +501,49 @@ public int GetLayerFromAssetID(uint assetID) throw new Exception($"Asset ID {assetID.ToString("X8")} is not present in any layer."); } - public uint GetClickedAssetID(Ray ray) + private List internalEditors = new List(); + + public void CloseInternalEditor(IInternalEditor i) + { + internalEditors.Remove(i); + } + + public void CloseInternalEditor(uint assetID) + { + for (int i = 0; i < internalEditors.Count; i++) + if (internalEditors[i].GetAssetID() == assetID) + internalEditors[i].Close(); + } + + public void OpenInternalEditor() + { + Asset asset = GetFromAssetID(currentlySelectedAssetID); + + for (int i = 0; i < internalEditors.Count; i++) + if (internalEditors[i].GetAssetID() == asset.AHDR.assetID) + internalEditors[i].Close(); + + if (asset is AssetCAM CAM) + internalEditors.Add(new InternalCamEditor(CAM, this)); + else if (asset is AssetDYNA DYNA) + internalEditors.Add(new InternalDynaEditor(DYNA, this)); + else if (asset is AssetTEXT TEXT) + internalEditors.Add(new InternalTextEditor(TEXT, this)); + else if (asset.AHDR.assetType == AssetType.SND | asset.AHDR.assetType == AssetType.SNDS) + internalEditors.Add(new InternalSoundEditor(asset, this)); + else + internalEditors.Add(new InternalAssetEditor(asset, this)); + + internalEditors.Last().Show(); + } + + public static uint GetClickedAssetID(Ray ray) { List l = new List(); try { - l.AddRange(renderableAssetSet); + l.AddRange(renderableAssetSetCommon); + l.AddRange(renderableAssetSetTrans); } catch { return 0; } @@ -516,14 +568,18 @@ public uint GetClickedAssetID(Ray ray) public void RecalculateAllMatrices() { - foreach (IRenderableAsset a in renderableAssetSet) + foreach (IRenderableAsset a in renderableAssetSetCommon) + a.CreateTransformMatrix(); + foreach (IRenderableAsset a in renderableAssetSetTrans) + a.CreateTransformMatrix(); + foreach (AssetJSP a in renderableAssetSetJSP) a.CreateTransformMatrix(); } // Gizmos - private static Gizmo[] gizmos; + private static Gizmo[] gizmos = new Gizmo[0]; private static bool DrawGizmos = false; - public bool FinishedMovingGizmo = false; + public static bool FinishedMovingGizmo = false; public static void RenderGizmos(SharpRenderer renderer) { @@ -538,19 +594,19 @@ public void UpdateGizmoPosition() UpdateGizmoPosition(currentAsset.GetGizmoCenter(), currentAsset.GetGizmoRadius()); } - private void UpdateGizmoPosition(Vector3 position, float distance) + private static void UpdateGizmoPosition(Vector3 position, float distance) { DrawGizmos = true; foreach (Gizmo g in gizmos) g.SetPosition(position, distance); } - private void ClearGizmos() + private static void ClearGizmos() { DrawGizmos = false; } - public void GizmoSelect(Ray r) + public static void GizmoSelect(Ray r) { if (!DrawGizmos) return; @@ -577,7 +633,7 @@ public void GizmoSelect(Ray r) gizmos[index].isSelected = true; } - public void ScreenUnclicked() + public static void ScreenUnclicked() { foreach (Gizmo g in gizmos) g.isSelected = false; diff --git a/IndustrialPark/ArchiveEditor/AssetEditor/InternalAssetEditor.cs b/IndustrialPark/ArchiveEditor/AssetEditor/InternalAssetEditor.cs index 5a78eade..66db4be0 100644 --- a/IndustrialPark/ArchiveEditor/AssetEditor/InternalAssetEditor.cs +++ b/IndustrialPark/ArchiveEditor/AssetEditor/InternalAssetEditor.cs @@ -4,13 +4,13 @@ namespace IndustrialPark { public partial class InternalAssetEditor : Form, IInternalEditor { - public InternalAssetEditor(Asset asset, ArchiveEditor archiveEditor) + public InternalAssetEditor(Asset asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; - this.archiveEditor = archiveEditor; + this.archive = archive; propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; @@ -18,11 +18,11 @@ public InternalAssetEditor(Asset asset, ArchiveEditor archiveEditor) private void InternalAssetEditor_FormClosing(object sender, FormClosingEventArgs e) { - archiveEditor.RemoveInternalEditor(this); + archive.CloseInternalEditor(this); } private Asset asset; - private ArchiveEditor archiveEditor; + private ArchiveEditorFunctions archive; public uint GetAssetID() { diff --git a/IndustrialPark/ArchiveEditor/AssetEditor/InternalCamEditor.cs b/IndustrialPark/ArchiveEditor/AssetEditor/InternalCamEditor.cs index c6c176f4..ea8ccd43 100644 --- a/IndustrialPark/ArchiveEditor/AssetEditor/InternalCamEditor.cs +++ b/IndustrialPark/ArchiveEditor/AssetEditor/InternalCamEditor.cs @@ -4,12 +4,13 @@ namespace IndustrialPark { public partial class InternalCamEditor : Form, IInternalEditor { - public InternalCamEditor(AssetCAM asset, ArchiveEditor archiveEditor) + public InternalCamEditor(AssetCAM asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; - assetCAM = asset; + this.asset = asset; + this.archive = archive; propertyGridAsset.SelectedObject = asset; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; @@ -17,32 +18,32 @@ public InternalCamEditor(AssetCAM asset, ArchiveEditor archiveEditor) private void InternalCamEditor_FormClosing(object sender, FormClosingEventArgs e) { - archiveEditor.RemoveInternalEditor(this); + archive.CloseInternalEditor(this); } - private AssetCAM assetCAM; - private ArchiveEditor archiveEditor; + private AssetCAM asset; + private ArchiveEditorFunctions archive; private void buttonGetPos_Click(object sender, System.EventArgs e) { - assetCAM.PositionX = Program.MainForm.renderer.Camera.Position.X; - assetCAM.PositionY = Program.MainForm.renderer.Camera.Position.Y; - assetCAM.PositionZ = Program.MainForm.renderer.Camera.Position.Z; + asset.PositionX = Program.MainForm.renderer.Camera.Position.X; + asset.PositionY = Program.MainForm.renderer.Camera.Position.Y; + asset.PositionZ = Program.MainForm.renderer.Camera.Position.Z; } private void buttonGetDir_Click(object sender, System.EventArgs e) { - assetCAM.NormalizedForwardX = Program.MainForm.renderer.Camera.GetForward().X; - assetCAM.NormalizedForwardY = Program.MainForm.renderer.Camera.GetForward().Y; - assetCAM.NormalizedForwardZ = Program.MainForm.renderer.Camera.GetForward().Z; - assetCAM.NormalizedUpX = Program.MainForm.renderer.Camera.GetUp().X; - assetCAM.NormalizedUpY = Program.MainForm.renderer.Camera.GetUp().Y; - assetCAM.NormalizedUpZ = Program.MainForm.renderer.Camera.GetUp().Z; + asset.NormalizedForwardX = Program.MainForm.renderer.Camera.GetForward().X; + asset.NormalizedForwardY = Program.MainForm.renderer.Camera.GetForward().Y; + asset.NormalizedForwardZ = Program.MainForm.renderer.Camera.GetForward().Z; + asset.NormalizedUpX = Program.MainForm.renderer.Camera.GetUp().X; + asset.NormalizedUpY = Program.MainForm.renderer.Camera.GetUp().Y; + asset.NormalizedUpZ = Program.MainForm.renderer.Camera.GetUp().Z; } public uint GetAssetID() { - return assetCAM.AHDR.assetID; + return asset.AHDR.assetID; } } } diff --git a/IndustrialPark/ArchiveEditor/AssetEditor/InternalDynaEditor.cs b/IndustrialPark/ArchiveEditor/AssetEditor/InternalDynaEditor.cs index 60241cde..e60a29ab 100644 --- a/IndustrialPark/ArchiveEditor/AssetEditor/InternalDynaEditor.cs +++ b/IndustrialPark/ArchiveEditor/AssetEditor/InternalDynaEditor.cs @@ -4,13 +4,13 @@ namespace IndustrialPark { public partial class InternalDynaEditor : Form, IInternalEditor { - public InternalDynaEditor(AssetDYNA asset, ArchiveEditor archiveEditor) + public InternalDynaEditor(AssetDYNA asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; - assetDYNA = asset; - this.archiveEditor = archiveEditor; + this.asset = asset; + this.archive = archive; propertyGridAsset.SelectedObject = asset; propertyGridDynaType.SelectedObject = asset.DynaBase; @@ -19,25 +19,25 @@ public InternalDynaEditor(AssetDYNA asset, ArchiveEditor archiveEditor) private void InternalDynaEditor_FormClosing(object sender, FormClosingEventArgs e) { - archiveEditor.RemoveInternalEditor(this); + archive.CloseInternalEditor(this); } - private AssetDYNA assetDYNA; - private ArchiveEditor archiveEditor; + private AssetDYNA asset; + private ArchiveEditorFunctions archive; public uint GetAssetID() { - return assetDYNA.AHDR.assetID; + return asset.AHDR.assetID; } private void propertyGridAsset_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { - propertyGridDynaType.SelectedObject = assetDYNA.DynaBase; + propertyGridDynaType.SelectedObject = asset.DynaBase; } private void propertyGridDynaType_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { - assetDYNA.DynaBase = (DynaBase)propertyGridDynaType.SelectedObject; + asset.DynaBase = (DynaBase)propertyGridDynaType.SelectedObject; } } } diff --git a/IndustrialPark/ArchiveEditor/AssetEditor/InternalSoundEditor.cs b/IndustrialPark/ArchiveEditor/AssetEditor/InternalSoundEditor.cs index b19476dc..f0e9f077 100644 --- a/IndustrialPark/ArchiveEditor/AssetEditor/InternalSoundEditor.cs +++ b/IndustrialPark/ArchiveEditor/AssetEditor/InternalSoundEditor.cs @@ -7,24 +7,24 @@ namespace IndustrialPark { public partial class InternalSoundEditor : Form, IInternalEditor { - public InternalSoundEditor(Asset asset, ArchiveEditor archiveEditor) + public InternalSoundEditor(Asset asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; this.asset = asset; - this.archiveEditor = archiveEditor; + this.archive = archive; labelAssetName.Text = $"[{asset.AHDR.assetType.ToString()}] {asset.ToString()}"; } private void InternalAssetEditor_FormClosing(object sender, FormClosingEventArgs e) { - archiveEditor.RemoveInternalEditor(this); + archive.CloseInternalEditor(this); } private Asset asset; - private ArchiveEditor archiveEditor; + private ArchiveEditorFunctions archive; public uint GetAssetID() { @@ -43,7 +43,7 @@ private void button1_Click(object sender, System.EventArgs e) byte[] file = File.ReadAllBytes(openFileDialog.FileName); if (checkBoxSendToSNDI.Checked) { - archiveEditor.AddSoundToSNDI(file.Take(0x60).ToArray(), asset.AHDR.assetID); + archive.AddSoundToSNDI(file.Take(0x60).ToArray(), asset.AHDR.assetID); asset.AHDR.data = file.Skip(0x60).ToArray(); } else @@ -64,7 +64,7 @@ private void button2_Click(object sender, System.EventArgs e) if (saveFileDialog.ShowDialog() == DialogResult.OK) { List file = new List(); - file.AddRange(archiveEditor.GetHeaderFromSNDI(asset.AHDR.assetID)); + file.AddRange(archive.GetHeaderFromSNDI(asset.AHDR.assetID)); file.AddRange(asset.AHDR.data); File.WriteAllBytes(saveFileDialog.FileName, file.ToArray()); diff --git a/IndustrialPark/ArchiveEditor/AssetEditor/InternalTextEditor.cs b/IndustrialPark/ArchiveEditor/AssetEditor/InternalTextEditor.cs index 583c7e5e..bdc4620b 100644 --- a/IndustrialPark/ArchiveEditor/AssetEditor/InternalTextEditor.cs +++ b/IndustrialPark/ArchiveEditor/AssetEditor/InternalTextEditor.cs @@ -4,34 +4,34 @@ namespace IndustrialPark { public partial class InternalTextEditor : Form, IInternalEditor { - public InternalTextEditor(AssetTEXT asset, ArchiveEditor archiveEditor) + public InternalTextEditor(AssetTEXT asset, ArchiveEditorFunctions archive) { InitializeComponent(); TopMost = true; - assetTEXT = asset; - this.archiveEditor = archiveEditor; + this.asset = asset; + this.archive = archive; - labelAssetName.Text = $"[{assetTEXT.AHDR.assetType.ToString()}] {assetTEXT.ToString()}"; - richTextBoxAssetText.Text = assetTEXT.Text; + labelAssetName.Text = $"[{this.asset.AHDR.assetType.ToString()}] {this.asset.ToString()}"; + richTextBoxAssetText.Text = this.asset.Text; } private void InternalTextEditor_FormClosing(object sender, FormClosingEventArgs e) { - archiveEditor.RemoveInternalEditor(this); + archive.CloseInternalEditor(this); } - private AssetTEXT assetTEXT; - private ArchiveEditor archiveEditor; + private AssetTEXT asset; + private ArchiveEditorFunctions archive; private void richTextBoxAssetText_TextChanged(object sender, System.EventArgs e) { - assetTEXT.Text = richTextBoxAssetText.Text; + asset.Text = richTextBoxAssetText.Text; } public uint GetAssetID() { - return assetTEXT.AHDR.assetID; + return asset.AHDR.assetID; } } } diff --git a/IndustrialPark/Assets/Binary/AssetMAPR.cs b/IndustrialPark/Assets/Binary/AssetMAPR.cs index 57d0bc0b..d0c44531 100644 --- a/IndustrialPark/Assets/Binary/AssetMAPR.cs +++ b/IndustrialPark/Assets/Binary/AssetMAPR.cs @@ -41,8 +41,8 @@ public EntryMAPR[] Entries { entries.Add(new EntryMAPR() { - AssetID_SURF = ReadUInt(4 + i * 0x8), - Unknown = ReadInt(8 + i * 0x8) + AssetID_SURF = ReadUInt(8 + i * 8), + Unknown = ReadInt(12 + i * 8) }); } diff --git a/IndustrialPark/Assets/Binary/AssetPICK.cs b/IndustrialPark/Assets/Binary/AssetPICK.cs index 3f165d8a..72e1e25c 100644 --- a/IndustrialPark/Assets/Binary/AssetPICK.cs +++ b/IndustrialPark/Assets/Binary/AssetPICK.cs @@ -39,6 +39,8 @@ public AssetPICK(Section_AHDR AHDR) : base(AHDR) public void Setup() { pickEntries = new Dictionary(); + foreach (EntryPICK entryPICK in PICKentries) + pickEntries.Add(entryPICK.ReferenceID, entryPICK.ModelAssetID); } public EntryPICK[] PICKentries diff --git a/IndustrialPark/Assets/ObjectAssets/AssetENV.cs b/IndustrialPark/Assets/ObjectAssets/AssetENV.cs new file mode 100644 index 00000000..e823d680 --- /dev/null +++ b/IndustrialPark/Assets/ObjectAssets/AssetENV.cs @@ -0,0 +1,109 @@ +using HipHopFile; +using System; + +namespace IndustrialPark +{ + public class AssetENV : ObjectAsset + { + public AssetENV(Section_AHDR AHDR) : base(AHDR) { } + + protected override int EventStartOffset + { + get => 0x44; + } + + public AssetID JSP_AssetID + { + get => ReadUInt(0x8); + set => Write(0x8, value); + } + + public AssetID CAM_AssetID + { + get => ReadUInt(0xC); + set => Write(0xC, value); + } + + public int Unknown10 + { + get => ReadInt(0x10); + set => Write(0x10, value); + } + + public int Unknown14 + { + get => ReadInt(0x14); + set => Write(0x14, value); + } + + public int Unknown18 + { + get => ReadInt(0x18); + set => Write(0x18, value); + } + + public AssetID LKIT_AssetID_0 + { + get => ReadUInt(0x1C); + set => Write(0x1C, value); + } + + public AssetID LKIT_AssetID_1 + { + get => ReadUInt(0x20); + set => Write(0x20, value); + } + + public int Unknown24 + { + get => ReadInt(0x24); + set => Write(0x24, value); + } + + public int Unknown28 + { + get => ReadInt(0x28); + set => Write(0x28, value); + } + + public int Unknown2C + { + get => ReadInt(0x2C); + set => Write(0x2C, value); + } + + public int Unknown30 + { + get => ReadInt(0x30); + set => Write(0x30, value); + } + + public AssetID MAPR_AssetID + { + get => ReadUInt(0x34); + set => Write(0x34, value); + } + + public int Unknown38 + { + get => ReadInt(0x38); + set => Write(0x38, value); + } + + public int Unknown3C + { + get => ReadInt(0x3C); + set => Write(0x3C, value); + } + + public float UnknownFloat40 + { + get => BitConverter.ToSingle(AHDR.data, 0x40); + set + { + for (int i = 0; i < 4; i++) + AHDR.data[0x40 + i] = BitConverter.GetBytes(value)[i]; + } + } + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs index 5924ea1b..8b503121 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetCAM.cs @@ -29,8 +29,8 @@ public void Setup(SharpRenderer renderer) CreateTransformMatrix(); - if (!ArchiveEditorFunctions.renderableAssetSet.Contains(this)) - ArchiveEditorFunctions.renderableAssetSet.Add(this); + if (!ArchiveEditorFunctions.renderableAssetSetTrans.Contains(this)) + ArchiveEditorFunctions.renderableAssetSetTrans.Add(this); } public void CreateTransformMatrix() @@ -101,6 +101,11 @@ public BoundingBox GetBoundingBox() return boundingBox; } + public float GetDistance(Vector3 cameraPosition) + { + return Vector3.Distance(cameraPosition, _position); + } + private Vector3 _position; [TypeConverter(typeof(FloatTypeConverter))] public float PositionX diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs index 53ae759a..4d9e7e56 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMRKR.cs @@ -24,8 +24,8 @@ public void Setup() CreateTransformMatrix(); - if (!ArchiveEditorFunctions.renderableAssetSet.Contains(this)) - ArchiveEditorFunctions.renderableAssetSet.Add(this); + if (!ArchiveEditorFunctions.renderableAssetSetTrans.Contains(this)) + ArchiveEditorFunctions.renderableAssetSetTrans.Add(this); } public void CreateTransformMatrix() @@ -96,6 +96,11 @@ public BoundingBox GetBoundingBox() return boundingBox; } + public float GetDistance(Vector3 cameraPosition) + { + return Vector3.Distance(cameraPosition, _position); + } + private Vector3 _position; public float PositionX { diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs index 3ecda2a6..b95a2603 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/AssetMVPT.cs @@ -32,8 +32,8 @@ public void Setup(SharpRenderer renderer) CreateTransformMatrix(); - if (!ArchiveEditorFunctions.renderableAssetSet.Contains(this)) - ArchiveEditorFunctions.renderableAssetSet.Add(this); + if (!ArchiveEditorFunctions.renderableAssetSetTrans.Contains(this)) + ArchiveEditorFunctions.renderableAssetSetTrans.Add(this); } public void CreateTransformMatrix() @@ -124,6 +124,11 @@ public BoundingBox GetBoundingBox() return boundingBox; } + public float GetDistance(Vector3 cameraPosition) + { + return Vector3.Distance(cameraPosition, _position) - (_distanceICanSeeYou == -1f ? 0 : _distanceICanSeeYou); + } + private Vector3 _position; public float PositionX { diff --git a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs index 3c9934e7..9216d2bf 100644 --- a/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs +++ b/IndustrialPark/Assets/ObjectAssets/ClickableAssets/PlaceableAssets/AssetTRIG.cs @@ -38,7 +38,16 @@ public override void Setup() _trigPos2 = new Vector3(ReadFloat(0x6C + Offset), ReadFloat(0x70 + Offset), ReadFloat(0x74 + Offset)); _trigPos3 = new Vector3(ReadFloat(0x78 + Offset), ReadFloat(0x7C + Offset), ReadFloat(0x80 + Offset)); - base.Setup(); + _rotation = new Vector3(ReadFloat(0x18 + Offset), ReadFloat(0x14 + Offset), ReadFloat(0x1C + Offset)); + _position = new Vector3(ReadFloat(0x20 + Offset), ReadFloat(0x24 + Offset), ReadFloat(0x28 + Offset)); + _scale = new Vector3(ReadFloat(0x2C + Offset), ReadFloat(0x30 + Offset), ReadFloat(0x34 + Offset)); + _color = new Vector4(ReadFloat(0x38 + Offset), ReadFloat(0x3c + Offset), ReadFloat(0x40 + Offset), ReadFloat(0x44 + Offset)); + + _modelAssetID = ReadUInt(0x4C + Offset); + + CreateTransformMatrix(); + if (!ArchiveEditorFunctions.renderableAssetSetTrans.Contains(this)) + ArchiveEditorFunctions.renderableAssetSetTrans.Add(this); } public override void CreateTransformMatrix() @@ -148,6 +157,13 @@ public override float GetGizmoRadius() return boundingSphere.Radius; } + public override float GetDistance(Vector3 cameraPosition) + { + if (Shape == TriggerShape.Sphere) + return Vector3.Distance(cameraPosition, boundingSphere.Center) - boundingSphere.Radius; + return Vector3.Distance(cameraPosition, boundingBox.Center) - boundingSphere.Radius; + } + private byte _shape; public TriggerShape Shape { diff --git a/IndustrialPark/Assets/Renderable/AssetJSP.cs b/IndustrialPark/Assets/Renderable/AssetJSP.cs index f9152559..c8391340 100644 --- a/IndustrialPark/Assets/Renderable/AssetJSP.cs +++ b/IndustrialPark/Assets/Renderable/AssetJSP.cs @@ -19,7 +19,7 @@ public void Setup(SharpRenderer renderer) model = new RenderWareModelFile(AHDR.ADBG.assetName); model.SetForRendering(renderer.device, RenderWareFile.ReadFileMethods.ReadRenderWareFile(AHDR.data), AHDR.data); - ArchiveEditorFunctions.renderableAssetSet.Add(this); + ArchiveEditorFunctions.renderableAssetSetJSP.Add(this); } public void CreateTransformMatrix() @@ -32,6 +32,11 @@ public BoundingBox GetBoundingBox() return boundingBox; } + public float GetDistance(Vector3 cameraPosition) + { + return 0f; + } + public void Draw(SharpRenderer renderer) { if (dontRender) return; diff --git a/IndustrialPark/Assets/Shared/Asset.cs b/IndustrialPark/Assets/Shared/Asset.cs index c9fe3ad0..956cd5e4 100644 --- a/IndustrialPark/Assets/Shared/Asset.cs +++ b/IndustrialPark/Assets/Shared/Asset.cs @@ -1,6 +1,5 @@ using HipHopFile; using System; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; using static HipHopFile.Functions; @@ -153,40 +152,5 @@ protected void Write(int j, uint value) for (int i = 0; i < 4; i++) AHDR.data[j + i] = split[i]; } - - protected AssetEvent[] ReadEvents(int eventsStart) - { - byte amount = ReadByte(0x05); - AssetEvent[] events = new AssetEvent[amount]; - for (int i = 0; i < amount; i++) - events[i] = AssetEvent.FromByteArray(Data, eventsStart + i * AssetEvent.sizeOfStruct); - return events; - } - - protected void WriteEvents(int eventsStart, AssetEvent[] value) - { - List newData = Data.Take(eventsStart).ToList(); - List bytesAfterEvents = Data.Skip(eventsStart + ReadByte(0x05) * AssetEvent.sizeOfStruct).ToList(); - - for (int i = 0; i < value.Length; i++) - newData.AddRange(value[i].ToByteArray()); - - newData.AddRange(bytesAfterEvents); - newData[0x05] = (byte)value.Length; - - Data = newData.ToArray(); - } - - public override bool Equals(object obj) - { - if (obj is Asset a) - return a.GetHashCode() == GetHashCode(); - return false; - } - - public override int GetHashCode() - { - return -1452371666 + AHDR.assetID.GetHashCode(); - } } } \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/AssetEvent.cs b/IndustrialPark/Assets/Shared/AssetEvent.cs index 83e2cab4..7dddee1a 100644 --- a/IndustrialPark/Assets/Shared/AssetEvent.cs +++ b/IndustrialPark/Assets/Shared/AssetEvent.cs @@ -5,17 +5,34 @@ namespace IndustrialPark { - public class AssetEvent + public abstract class AssetEvent { public static readonly int sizeOfStruct = 32; - [DisplayName("Receive Event")] - public EventType EventReceiveID { get; set; } - [DisplayName("Send Event")] - public EventType EventSendID { get; set; } [DisplayName("Target Asset")] public AssetID TargetAssetID { get; set; } - private byte[] arguments; + protected ushort _eventReceiveID; + protected ushort _eventSendID; + protected byte[] arguments; + + protected AssetEvent() + { + _eventReceiveID = 0; + _eventSendID = 0; + TargetAssetID = 0; + arguments = new byte[24]; + } + + protected AssetEvent(byte[] data, int offset) + { + _eventReceiveID = Switch(BitConverter.ToUInt16(data, offset)); + _eventSendID = Switch(BitConverter.ToUInt16(data, offset + 2)); + TargetAssetID = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 4)); + + arguments = new byte[24]; + for (int i = 0; i < 24; i++) + arguments[i] = data[offset + 8 + i]; + } public float[] Arguments_Float { @@ -31,12 +48,7 @@ public float[] Arguments_Float { float[] result = new float[6]; - for (int i = 0; i < 6; i++) - result[i] = value[i]; - - if (value.Length > 6) - System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be trimmed."); - else if (value.Length < 6) + if (value.Length < 6) { System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be padded."); for (int i = 0; i < value.Length; i++) @@ -44,10 +56,16 @@ public float[] Arguments_Float for (int i = value.Length; i < 6; i++) result[i] = 0f; } + else + for (int i = 0; i < 6; i++) + result[i] = value[i]; + + if (value.Length > 6) + System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be trimmed."); for (int i = 0; i < 6; i++) { - byte[] r = BitConverter.GetBytes(ConverterFunctions.Switch(value[i])); + byte[] r = BitConverter.GetBytes(ConverterFunctions.Switch(result[i])); arguments[i * 4 + 0] = r[0]; arguments[i * 4 + 1] = r[1]; @@ -71,12 +89,7 @@ public AssetID[] Arguments_Hex { AssetID[] result = new AssetID[6]; - for (int i = 0; i < 6; i++) - result[i] = value[i]; - - if (value.Length > 6) - System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be trimmed."); - else if (value.Length < 6) + if (value.Length < 6) { System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be padded."); for (int i = 0; i < value.Length; i++) @@ -84,10 +97,16 @@ public AssetID[] Arguments_Hex for (int i = value.Length; i < 6; i++) result[i] = 0; } + else + for (int i = 0; i < 6; i++) + result[i] = value[i]; + + if (value.Length > 6) + System.Windows.Forms.MessageBox.Show("Arguments must have an exact length of 6. Your values will be trimmed."); for (int i = 0; i < 6; i++) { - byte[] r = BitConverter.GetBytes(ConverterFunctions.Switch(value[i])); + byte[] r = BitConverter.GetBytes(ConverterFunctions.Switch(result[i])); arguments[i * 4 + 0] = r[0]; arguments[i * 4 + 1] = r[1]; @@ -97,28 +116,6 @@ public AssetID[] Arguments_Hex } } - public AssetEvent() - { - EventReceiveID = 0; - EventSendID = 0; - TargetAssetID = 0; - arguments = new byte[24]; - } - - public static AssetEvent FromByteArray(byte[] data, int offset) - { - AssetEvent newEvent = new AssetEvent() - { - EventReceiveID = (EventType)Switch(BitConverter.ToUInt16(data, offset)), - EventSendID = (EventType)Switch(BitConverter.ToUInt16(data, offset + 2)), - TargetAssetID = ConverterFunctions.Switch(BitConverter.ToUInt32(data, offset + 4)) - }; - for (int i = 0; i < 24; i++) - newEvent.arguments[i] = data[offset + 8 + i]; - - return newEvent; - } - public byte[] ToByteArray() { byte[] data = new byte[sizeOfStruct]; @@ -126,35 +123,30 @@ public byte[] ToByteArray() for (int i = 0; i < arguments.Length; i++) data[i + 8] = arguments[i]; - if (currentPlatform != HipHopFile.Platform.GameCube) + if (currentPlatform == HipHopFile.Platform.GameCube) { - data[0] = BitConverter.GetBytes((ushort)EventReceiveID)[0]; - data[1] = BitConverter.GetBytes((ushort)EventReceiveID)[1]; - data[2] = BitConverter.GetBytes((ushort)EventSendID)[0]; - data[3] = BitConverter.GetBytes((ushort)EventSendID)[1]; - data[4] = BitConverter.GetBytes(TargetAssetID)[0]; - data[5] = BitConverter.GetBytes(TargetAssetID)[1]; - data[6] = BitConverter.GetBytes(TargetAssetID)[2]; - data[7] = BitConverter.GetBytes(TargetAssetID)[3]; - } - else - { - data[0] = BitConverter.GetBytes((ushort)EventReceiveID)[1]; - data[1] = BitConverter.GetBytes((ushort)EventReceiveID)[0]; - data[2] = BitConverter.GetBytes((ushort)EventSendID)[1]; - data[3] = BitConverter.GetBytes((ushort)EventSendID)[0]; + data[0] = BitConverter.GetBytes(_eventReceiveID)[1]; + data[1] = BitConverter.GetBytes(_eventReceiveID)[0]; + data[2] = BitConverter.GetBytes(_eventSendID)[1]; + data[3] = BitConverter.GetBytes(_eventSendID)[0]; data[4] = BitConverter.GetBytes(TargetAssetID)[3]; data[5] = BitConverter.GetBytes(TargetAssetID)[2]; data[6] = BitConverter.GetBytes(TargetAssetID)[1]; data[7] = BitConverter.GetBytes(TargetAssetID)[0]; } + else + { + data[0] = BitConverter.GetBytes(_eventReceiveID)[0]; + data[1] = BitConverter.GetBytes(_eventReceiveID)[1]; + data[2] = BitConverter.GetBytes(_eventSendID)[0]; + data[3] = BitConverter.GetBytes(_eventSendID)[1]; + data[4] = BitConverter.GetBytes(TargetAssetID)[0]; + data[5] = BitConverter.GetBytes(TargetAssetID)[1]; + data[6] = BitConverter.GetBytes(TargetAssetID)[2]; + data[7] = BitConverter.GetBytes(TargetAssetID)[3]; + } return data; } - - public override string ToString() - { - return $"{EventReceiveID.ToString()} => {EventSendID.ToString()} => {Program.MainForm.GetAssetNameFromID(TargetAssetID)}"; - } } } \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/AssetEventBFBB.cs b/IndustrialPark/Assets/Shared/AssetEventBFBB.cs new file mode 100644 index 00000000..a6008707 --- /dev/null +++ b/IndustrialPark/Assets/Shared/AssetEventBFBB.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; + +namespace IndustrialPark +{ + public class AssetEventBFBB : AssetEvent + { + [DisplayName("Receive Event")] + public EventTypeBFBB EventReceiveID { get => (EventTypeBFBB)_eventReceiveID; set => _eventReceiveID = (ushort)value; } + [DisplayName("Send Event")] + public EventTypeBFBB EventSendID { get => (EventTypeBFBB)_eventSendID; set => _eventSendID = (ushort)value; } + + public AssetEventBFBB() : base() { } + + public AssetEventBFBB(byte[] data, int offset) : base(data, offset) { } + + public override string ToString() + { + return $"{EventReceiveID.ToString()} => {EventSendID.ToString()} => {Program.MainForm.GetAssetNameFromID(TargetAssetID)}"; + } + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/AssetEventTSSM.cs b/IndustrialPark/Assets/Shared/AssetEventTSSM.cs new file mode 100644 index 00000000..0645ea8d --- /dev/null +++ b/IndustrialPark/Assets/Shared/AssetEventTSSM.cs @@ -0,0 +1,21 @@ +using System.ComponentModel; + +namespace IndustrialPark +{ + public class AssetEventTSSM : AssetEvent + { + [DisplayName("Receive Event")] + public EventTypeTSSM EventReceiveID { get => (EventTypeTSSM)_eventReceiveID; set => _eventReceiveID = (ushort)value; } + [DisplayName("Send Event")] + public EventTypeTSSM EventSendID { get => (EventTypeTSSM)_eventSendID; set => _eventSendID = (ushort)value; } + + public AssetEventTSSM() : base() { } + + public AssetEventTSSM(byte[] data, int offset) : base(data, offset) { } + + public override string ToString() + { + return $"{EventReceiveID.ToString()} => {EventSendID.ToString()} => {Program.MainForm.GetAssetNameFromID(TargetAssetID)}"; + } + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/Enums/EventType.cs b/IndustrialPark/Assets/Shared/Enums/EventType.cs index c382d356..fd36612c 100644 --- a/IndustrialPark/Assets/Shared/Enums/EventType.cs +++ b/IndustrialPark/Assets/Shared/Enums/EventType.cs @@ -1,6 +1,6 @@ namespace IndustrialPark { - public enum EventType : ushort + public enum EventTypeBFBB : ushort { Unknown = 0x0000, Enable = 0x0001, diff --git a/IndustrialPark/Assets/Shared/Enums/EventTypeTSSM.cs b/IndustrialPark/Assets/Shared/Enums/EventTypeTSSM.cs new file mode 100644 index 00000000..d6c74ec6 --- /dev/null +++ b/IndustrialPark/Assets/Shared/Enums/EventTypeTSSM.cs @@ -0,0 +1,809 @@ +namespace IndustrialPark +{ + public enum EventTypeTSSM : ushort + { + Unknown = 0x0000, + Enable = 0x0001, + Disable = 0x0002, + Visible = 0x0003, + Invisible = 0x0004, + EnterPlayer = 0x0005, + ExitPlayer = 0x0006, + TouchPlayer = 0x0007, + ControlOff = 0x0008, + ControlOn = 0x0009, + Reset = 0x000A, + Increment = 0x000B, + Decrement = 0x000C, + Open = 0x000D, + Close = 0x000E, + Toggle = 0x000F, + TeleportPlayer = 0x0010, + OutOfBounds = 0x0011, + Run = 0x0012, + Stop = 0x0013, + Expired = 0x0014, + Move = 0x0015, + Destroy = 0x0016, + Pause = 0x0017, + Play = 0x0018, + PlayOne = 0x0019, + PlayMaybe = 0x001A, + RoomStart = 0x001B, + Invalidate = 0x001C, + Tilt = 0x001D, + Untilt = 0x001E, + Arrive = 0x001F, + Mount = 0x0020, + Dismount = 0x0021, + Break = 0x0022, + Pickup = 0x0023, + Death = 0x0024, + Kill = 0x0025, + On = 0x0026, + Off = 0x0027, + PatrolOn = 0x0028, + PatrolOff = 0x0029, + WanderOn = 0x002A, + WanderOff = 0x002B, + DetectPlayerOn = 0x002C, + DetectPlayerOff = 0x002D, + ChasePlayerOn = 0x002E, + ChasePlayerOff = 0x002F, + GoToSleep = 0x0030, + WakeUpVillain = 0x0031, + Respawn = 0x0032, + PlayerDeath = 0x0033, + GiveChance = 0x0034, + GiveShinyObjects = 0x0035, + GiveHealth = 0x0036, + ButtonPress = 0x0037, + ButtonUnpress = 0x0038, + ArriveHalfway = 0x0039, + Hit = 0x003A, + ButtonPressAction = 0x003B, + Evaluate = 0x003C, + True = 0x003D, + False = 0x003E, + PadPressX = 0x003F, + PadPressSquare = 0x0040, + PadPressO = 0x0041, + PadPressTriangle = 0x0042, + PadPressL1 = 0x0043, + PadPressL2 = 0x0044, + PadPressR1 = 0x0045, + PadPressR2 = 0x0046, + PadPressStart = 0x0047, + PadPressSelect = 0x0048, + PadPressUp = 0x0049, + PadPressDown = 0x004A, + PadPressRight = 0x004B, + PadPressLeft = 0x004C, + FontBackdropOn = 0x004D, + FontBackdropOff = 0x004E, + UISelect = 0x004F, + UIUnselect = 0x0050, + UIFocusOn = 0x0051, + UIFocusOff = 0x0052, + CollisionOn = 0x0053, + CollisionOff = 0x0054, + CollisionVisibleOn = 0x0055, + CollisionVisibleOff = 0x0056, + ScenePrepare = 0x0057, + SceneFinish = 0x0058, + RoomPrepare = 0x0059, + RoomFinish = 0x005A, + LobMasterShoot = 0x005B, + LobMasterReset = 0x005C, + FallToDeath = 0x005D, + UIFocusOnSelect = 0x005E, + UIFocusOffUnselect = 0x005F, + SetPadConfigtoPresetA = 0x0060, + SetPadConfigtoPresetB = 0x0061, + SetPadConfigtoPresetC = 0x0062, + SetPadConfigtoPresetD = 0x0063, + PadVibrateOn = 0x0064, + PadVibrateOff = 0x0065, + MonoSound = 0x0066, + StereoSound = 0x0067, + IncreaseMasterVolume = 0x0068, + DecreaseMasterVolume = 0x0069, + IncreaseMusicVolume = 0x006A, + DecreaseMusicVolume = 0x006B, + IncreaseSFXVolume = 0x006C, + DecreaseSFXVolume = 0x006D, + IntroState_Sony = 0x006E, + IntroState_Publisher = 0x006F, + IntroState_Developer = 0x0070, + IntroState_License = 0x0071, + IntroState_Count = 0x0072, + TitleState_Start = 0x0073, + TitleState_Attract = 0x0074, + TitleState_Count = 0x0075, + LoadState_SelectMemCard = 0x0076, + LoadState_SelectSlot = 0x0077, + LoadState_Loading = 0x0078, + LoadState_Count = 0x0079, + OptionsState_Options = 0x007A, + OptionsState_Count = 0x007B, + SaveState_SelectMemCard = 0x007C, + SaveState_SelectSlot = 0x007D, + SaveState_Saving = 0x007E, + SaveState_Count = 0x007F, + PauseState_Pause = 0x0080, + PauseState_Options = 0x0081, + PauseState_Count = 0x0082, + GameState_FirstTime = 0x0083, + GameState_Play = 0x0084, + GameState_LoseChance = 0x0085, + GameState_GameOver = 0x0086, + GameState_SceneSwitch = 0x0087, + GameState_Dead = 0x0088, + SetIntroState_Sony = 0x0089, + SetIntroState_Publisher = 0x008A, + SetIntroState_Developer = 0x008B, + SetIntroState_License = 0x008C, + SetIntroState_Count = 0x008D, + SetTitleState_Start = 0x008E, + SetTitleState_Attract = 0x008F, + SetTitleState_Count = 0x0090, + SetLoadState_SelectMemCard = 0x0091, + SetLoadState_SelectSlot = 0x0092, + SetLoadState_Loading = 0x0093, + SetLoadState_Count = 0x0094, + SetOptionsState_Options = 0x0095, + SetOptionsState_Count = 0x0096, + SetSaveState_SelectMemCard = 0x0097, + SetSaveState_SelectSlot = 0x0098, + SetSaveState_Saving = 0x0099, + SetSaveState_Count = 0x009A, + SetPauseState_Pause = 0x009B, + SetPauseState_Options = 0x009C, + SetPauseState_Count = 0x009D, + SetGameState_FirstTime = 0x009E, + SetGameState_Play = 0x009F, + SetGameState_LoseChance = 0x00A0, + SetGameState_GameOver = 0x00A1, + SetGameState_SceneSwitch = 0x00A2, + SetGameState_Dead = 0x00A3, + Digup = 0x00A4, + GameState_Exit = 0x00A5, + SetGameState_Exit = 0x00A6, + LobMasterShootFromWidget = 0x00A7, + Back = 0x00A8, + Cancel = 0x00A9, + Retry = 0x00AA, + SelectCard = 0x00AB, + SelectSlot = 0x00AC, + OK = 0x00AD, + VilHurtBoss = 0x00AE, + Attack = 0x00AF, + AttackOn = 0x00B0, + AttackOff = 0x00B1, + Droppickup = 0x00B2, + UIAddChar = 0x00B3, + UIDelChar = 0x00B4, + UIStringEmpty = 0x00B5, + UIStringFull = 0x00B6, + UIStringSendAsCheat = 0x00B7, + UISetMaxChars = 0x00B8, + UICheatOK = 0x00B9, + UICheatBad = 0x00BA, + VilReport_StartingChase = 0x00BB, + VilReport_StartingAttack = 0x00BC, + VilReport_StartingRetreat = 0x00BD, + Preload = 0x00BE, + Done = 0x00BF, + Arcto = 0x00C0, + DigupReaction = 0x00C1, + SetCheckPoint = 0x00C2, + AnimPlay = 0x00C3, + AnimPlayLoop = 0x00C4, + AnimStop = 0x00C5, + AnimPause = 0x00C6, + AnimResume = 0x00C7, + AnimTogglePause = 0x00C8, + AnimPlayRandom = 0x00C9, + AnimPlayMaybe = 0x00CA, + SetSpeed = 0x00CB, + Accelerate = 0x00CC, + MoveToTarget = 0x00CD, + SwingerFollow = 0x00CE, + Impact = 0x00CF, + StartTimer = 0x00D0, + FinishedTimer = 0x00D1, + UIReset = 0x00D2, + SetScaleFactor = 0x00D3, + EnterEntity = 0x00D4, + ExitEntity = 0x00D5, + ENTERFLAGGED_DONOTUSE = 0x00D6, + EXITFLAGGED_DONOTUSE = 0x00D7, + Drivenby = 0x00D8, + FollowTarget = 0x00D9, + FaceTarget = 0x00DA, + WatchTarget = 0x00DB, + CarChangeLaneRight = 0x00DC, + CarChangeLaneLeft = 0x00DD, + CarStart = 0x00DE, + CarSetSwerveMode = 0x00DF, + IncreaseSpeed = 0x00E0, + DecreaseSpeed = 0x00E1, + StartMoving = 0x00E2, + StopMoving = 0x00E3, + Swoosh = 0x00E4, + TurretDestroyed = 0x00E5, + NPCSpeakStop = 0x00E6, + StartRumbleEffect = 0x00E7, + NavigateTo = 0x00E8, + NPCSpeakStart = 0x00E9, + NPCAlert = 0x00EA, + NPCPatrolDelay = 0x00EB, + NPCScrambleActionEnd = 0x00EC, + VilFakeChaseOff = 0x00ED, + BossMMPushButton = 0x00EE, + VilReport_DecayComplete = 0x00EF, + VilGuardWidget = 0x00F0, + TextureAnimateOn = 0x00F1, + TextureAnimateOff = 0x00F2, + TextureAnimateToggle = 0x00F3, + ColorEffectOn = 0x00F4, + ColorEffectOff = 0x00F5, + ColorEffectToggle = 0x00F6, + SetTextureAnimGroup = 0x00F7, + SetTextureAnimSpeed = 0x00F8, + TextureAnimateStep = 0x00F9, + Emit = 0x00FA, + Emitted = 0x00FB, + TranslucentOn = 0x00FC, + TranslucentOff = 0x00FD, + TranslucentToggle = 0x00FE, + ZipLineEnvDamage = 0x00FF, + VilGangTalkOff = 0x0100, + GivePowerUp = 0x0101, + RaceTimerReset = 0x0102, + FireCruiseBubble = 0x0103, + CarSuccessAnimPlay = 0x0104, + CarFailureAnimPlay = 0x0105, + DisableGroupContents = 0x0106, + NPCCharge = 0x0107, + OccludeOn = 0x0108, + OccludeOff = 0x0109, + RaceTimerPause = 0x010A, + RaceTimerResume = 0x010B, + RaceTimerSetBestTime = 0x010C, + RaceTimerWarning1 = 0x010D, + RaceTimerWarning2 = 0x010E, + RaceTimerWarning3 = 0x010F, + RingChallengeStart = 0x0110, + CarStop = 0x0111, + RingChallengeRun = 0x0112, + RingChallengeReset = 0x0113, + RingChallengeSuccess = 0x0114, + RingChallengeFailed = 0x0115, + FormationChanged = 0x0116, + ChargeResume = 0x0117, + ChargePause = 0x0118, + NPCChargeStop = 0x0119, + NPCChargeCompleted = 0x011A, + FormationChargeStart = 0x011B, + SituationPlayerSuccess = 0x011C, + SituationPlayerFailure = 0x011D, + ShowHud = 0x011E, + HideHud = 0x011F, + FADEOUT = 0x0120, + SetRain = 0x0121, + SetSnow = 0x0122, + ScriptNoOp = 0x0123, + ScriptReset = 0x0124, + WaitForInput = 0x0125, + PlayMovie = 0x0126, + CelebrationAnimPlay = 0x0127, + None = 0x0128, + MusicTrackReplace = 0x0129, + Forward = 0x012A, + Reverse = 0x012B, + RumbleTest_OBSOLETE = 0x012C, + RumbleLight_OBSOLETE = 0x012D, + RumbleMedium_OBSOLETE = 0x012E, + RumbleHeavy_OBSOLETE = 0x012F, + ScreenAdjustmentON = 0x0130, + ScreenAdjustmentOFF = 0x0131, + SetasSkydome = 0x0132, + Connect_IOwnYou = 0x0133, + Duplotron_WaveBegin = 0x0134, + Duplotron_WaveComplete = 0x0135, + Duplotron_NPCBorn = 0x0136, + Duplotron_NPCKilled = 0x0137, + Duplotron_MaxNPCExpired = 0x0138, + Duplotron_Pause = 0x0139, + Duplotron_Resume = 0x013A, + SetasGoo = 0x013B, + NPCScript_ScriptBegin = 0x013C, + NPCScript_ScriptEnd = 0x013D, + NPCScript_ScriptReady = 0x013E, + NPCScript_Halt = 0x013F, + NPCScript_SetPos = 0x0140, + NPCScript_SetDir = 0x0141, + NPCScript_LookNormal = 0x0142, + NPCScript_LookAlert = 0x0143, + NPCScript_FaceWidget = 0x0144, + NPCScript_FaceWidgetDone = 0x0145, + NPCScript_GotoWidget = 0x0146, + NPCScript_GotoWidgetDone = 0x0147, + NPCScript_AttackWidget = 0x0148, + NPCScript_AttackWidgetDone = 0x0149, + NPCScript_FollowWidget = 0x014A, + NPCScript_PlayAnim = 0x014B, + NPCScript_PlayAnimDone = 0x014C, + NPCScript_LeadPlayer = 0x014D, + SetText = 0x014E, + StartConversation = 0x014F, + EndConversation = 0x0150, + Switch = 0x0151, + AddText = 0x0152, + ClearText = 0x0153, + OpenTeleportBox = 0x0154, + CloseTeleportBox = 0x0155, + OnSignal0 = 0x0156, + OnSignal1 = 0x0157, + OnSignal2 = 0x0158, + OnSignal3 = 0x0159, + OnSignal4 = 0x015A, + OnSignal5 = 0x015B, + OnSignal6 = 0x015C, + OnSignal7 = 0x015D, + OnSignal8 = 0x015E, + OnSignal9 = 0x015F, + StopWait = 0x0160, + OnConversationStart = 0x0161, + OnConversationEnd = 0x0162, + HitMelee = 0x0163, + HitBubbleBounce = 0x0164, + HitBubbleBash = 0x0165, + HitBubbleBowl = 0x0166, + HitPatrickSlam = 0x0167, + HitByThrowable = 0x0168, + PaddleHitLeft = 0x0169, + PaddleHitRight = 0x016A, + InitiateTask = 0x016B, + SetSuccess = 0x016C, + SetFailure = 0x016D, + OnAccept = 0x016E, + OnDecline = 0x016F, + OnComplete = 0x0170, + GenerateBoulder = 0x0171, + LaunchBoulderAtWidget = 0x0172, + LaunchBoulderAtPoint = 0x0173, + LaunchBoulderAtPlayer = 0x0174, + Duplotron_SuperDuperDone = 0x0175, + Duplotron_DuperIsDoner = 0x0176, + BusSwitchCharacter = 0x0177, + GroupUpdateTogether = 0x0178, + SetUpdateDistance = 0x0179, + TranslateLocalX = 0x017A, + TranslateLocalY = 0x017B, + TranslateLocalZ = 0x017C, + TranslateWorldX = 0x017D, + TranslateWorldY = 0x017E, + TranslateWorldZ = 0x017F, + RotateLocalX = 0x0180, + RotateLocalY = 0x0181, + RotateLocalZ = 0x0182, + RotateWorldX = 0x0183, + RotateWorldY = 0x0184, + RotateWorldZ = 0x0185, + TranslateLocalXDone = 0x0186, + TranslateLocalYDone = 0x0187, + TranslateLocalZDone = 0x0188, + TranslateWorldXDone = 0x0189, + TranslateWorldYDone = 0x018A, + TranslateWorldZDone = 0x018B, + RotateLocalXDone = 0x018C, + RotateLocalYDone = 0x018D, + RotateLocalZDone = 0x018E, + RotateWorldXDone = 0x018F, + RotateWorldYDone = 0x0190, + RotateWorldZDone = 0x0191, + Count1 = 0x0192, + Count2 = 0x0193, + Count3 = 0x0194, + Count4 = 0x0195, + Count5 = 0x0196, + Count6 = 0x0197, + Count7 = 0x0198, + Count8 = 0x0199, + Count9 = 0x019A, + Count10 = 0x019B, + Count11 = 0x019C, + Count12 = 0x019D, + Count13 = 0x019E, + Count14 = 0x019F, + Count15 = 0x01A0, + Count16 = 0x01A1, + Count17 = 0x01A2, + Count18 = 0x01A3, + Count19 = 0x01A4, + Count20 = 0x01A5, + SetState = 0x01A6, + EnterSpongeBob = 0x01A7, + EnterPatrick = 0x01A8, + EnterSandy = 0x01A9, + ExitSpongeBob = 0x01AA, + ExitPatrick = 0x01AB, + ExitSandy = 0x01AC, + NPCSpecial_PlatformSnap = 0x01AD, + NPCSpecial_PlatformFall = 0x01AE, + Goosetwarbcoeffs = 0x01AF, + Goosetfreezeduration = 0x01B0, + Goomelt = 0x01B1, + SetStateRange = 0x01B2, + SetStateDelay = 0x01B3, + SetTransitionDelay = 0x01B4, + NPCFightOn = 0x01B5, + NPCFightOff = 0x01B6, + NPCPatrolSplineOn = 0x01B7, + NPCPatrolSplineOff = 0x01B8, + NPCKillQuietly = 0x01B9, + HitGeneral = 0x01BA, + HitHead = 0x01BB, + HitLeftArm = 0x01BC, + HitRightArm = 0x01BD, + HitLeftLeg = 0x01BE, + HitRightLeg = 0x01BF, + HitLowerBody = 0x01C0, + GiveSocks = 0x01C1, + GiveCollectables = 0x01C2, + SetSocks = 0x01C3, + SetCollectables = 0x01C4, + OnAnswerYes = 0x01C5, + OnAnswerNo = 0x01C6, + HitCruiseBubble = 0x01C7, + Duplotron_KillKids = 0x01C8, + OnSignal10 = 0x01C9, + OnSignal11 = 0x01CA, + OnSignal12 = 0x01CB, + OnSignal13 = 0x01CC, + OnSignal14 = 0x01CD, + OnSignal15 = 0x01CE, + OnSignal16 = 0x01CF, + OnSignal17 = 0x01D0, + OnSignal18 = 0x01D1, + OnSignal19 = 0x01D2, + SpongeballOn = 0x01D3, + SpongeballOff = 0x01D4, + LaunchShrapnel = 0x01D5, + NPCHPIncremented = 0x01D6, + NPCHPDecremented = 0x01D7, + NPCSetActiveOn = 0x01D8, + NPCSetActiveOff = 0x01D9, + SwitchPlayerCharacter = 0x01DA, + LevelBegin = 0x01DB, + SceneReset = 0x01DC, + SceneEnter = 0x01DD, + DestroyedTiki = 0x01DE, + DestroyedRobot = 0x01DF, + SeeWoodTiki = 0x01E0, + SeeLoveyTiki = 0x01E1, + SeeShhhTiki = 0x01E2, + SeeThunderTiki = 0x01E3, + SeeStoneTiki = 0x01E4, + SeeFodder = 0x01E5, + SeeHammer = 0x01E6, + SeeTarTar = 0x01E7, + SeeGLove = 0x01E8, + SeeMonsoon = 0x01E9, + SeeSleepyTime = 0x01EA, + SeeArf = 0x01EB, + SeeTubelets = 0x01EC, + SeeSlick = 0x01ED, + SeeKingJellyfish = 0x01EE, + SeePrawn = 0x01EF, + SeeDutchman = 0x01F0, + SeeSandyBoss = 0x01F1, + SeePatrickBoss = 0x01F2, + SeeSpongeBobBoss = 0x01F3, + SeeRobotPlankton = 0x01F4, + ChangeTextureofUI = 0x01F5, + NPCCheerForMe = 0x01F6, + FastVisible = 0x01F7, + FastInvisible = 0x01F8, + ZipLineMount = 0x01F9, + ZipLineDismount = 0x01FA, + Target = 0x01FB, + Fire = 0x01FC, + CameraFXShake = 0x01FD, + BulletTime = 0x01FE, + Thrown = 0x01FF, + NPCPatrol = 0x0200, + EnterCruise = 0x0201, + ExitCruise = 0x0202, + CruiseFired = 0x0203, + CruiseDied = 0x0204, + CruiseAddLife = 0x0205, + CruiseSetLife = 0x0206, + CruiseResetLife = 0x0207, + CameraCollideOff = 0x0208, + CameraCollideOn = 0x0209, + SlideOn = 0x020A, + SlideOff = 0x020B, + TimerSet = 0x020C, + TimerAdd = 0x020D, + NPCForceConversation = 0x020E, + MakeASplash = 0x020F, + Creditsstart = 0x0210, + Creditsstop = 0x0211, + Creditsended = 0x0212, + BubbleWipe = 0x0213, + SetLightkit = 0x0214, + SetOpacity = 0x0215, + SetSoundEffect = 0x0216, + Scale = 0x0217, + SetReference = 0x0218, + WarpSetWorld = 0x0219, + WarpSetTask = 0x021A, + WarpGo = 0x021B, + SetCount = 0x021C, + GetDashSpeed = 0x021D, + DashTrip = 0x021E, + DashBurst = 0x021F, + DashFast = 0x0220, + DashNormal = 0x0221, + DashSlow = 0x0222, + TakeSocks = 0x0223, + DebugBREAK = 0x0224, + Born = 0x0225, + PlatformPause = 0x0226, + PlatformUnpause = 0x0227, + StoreOptions = 0x0228, + RestoreOptions = 0x0229, + UISetMotion = 0x022A, + UIMotionFinished = 0x022B, + UIMotionLoop = 0x022C, + Destructiblelaunch = 0x022D, + Destructiblerespawn = 0x022E, + KaboomStart = 0x022F, + KaboomStop = 0x0230, + NPCAttack = 0x0231, + NPCDefend = 0x0232, + TrainSetSpeed = 0x0233, + TrainJunctOut1 = 0x0234, + TrainJunctOut2 = 0x0235, + TrainJunctToggle = 0x0236, + TrainJunctPassed = 0x0237, + TrainCarDetach = 0x0238, + TrainCarExplode = 0x0239, + XboxInitializeNETAPI = 0x023A, + XboxUpdateConnection = 0x023B, + XboxUpdateOnlineTask = 0x023C, + XboxUpdateAccountList = 0x023D, + XboxCheckfornewcontent = 0x023E, + XboxSelectDevice = 0x023F, + XboxSelectContent = 0x0240, + XboxVerifyContent = 0x0241, + XboxRemoveContent = 0x0242, + XboxSelectDeviceafterremove = 0x0243, + XboxConfirmusecontentidx = 0x0244, + XboxConfirmnousecontentidx = 0x0245, + XboxNocontentisinstalled = 0x0246, + XboxNonewcontentisavailable = 0x0247, + XboxNewcontentisavailable = 0x0248, + EnableSceneDrawing = 0x0249, + DisableSceneDrawing = 0x024A, + LightningStart = 0x024B, + LightningStop = 0x024C, + ChangeBossUIStage = 0x024D, + Startstaticcamera = 0x024E, + Endstaticcamera = 0x024F, + SetCameraStartOrientation = 0x0250, + NPCSetMovepointPath = 0x0251, + NPCScareBegin = 0x0252, + NPCScareSkip = 0x0253, + NPCSetMovepointGroup = 0x0254, + VentSetStateIdle = 0x0255, + VentSetStateWarn = 0x0256, + VentSetStateDamage = 0x0257, + VentSetStateOff = 0x0258, + WaterhoseStart = 0x0259, + WaterhoseStop = 0x025A, + WaterhoseSetLength = 0x025B, + Carried = 0x025C, + Explode = 0x025D, + JumpTo = 0x025E, + JumponSpawn = 0x025F, + PlayerHit = 0x0260, + StartFade = 0x0261, + FadeDownDone = 0x0262, + FadeUpDone = 0x0263, + Bounce = 0x0264, + LaunchNPC = 0x0265, + UpgradePowerUp = 0x0266, + BulletStreak = 0x0267, + SetFollowCameraOrientation = 0x0268, + HighDynamicRangeFade = 0x0269, + Start = 0x026A, + Success = 0x026B, + Failure = 0x026C, + EnableRestore = 0x026D, + DisableRestore = 0x026E, + NPCSpawn = 0x026F, + NPCSpawnDone = 0x0270, + SpawnedNPCKilled = 0x0271, + SpawnedNPCNoHealth = 0x0272, + SpawnedNPCsAllKilled = 0x0273, + SpawnedNPCsAllNoHealth = 0x0274, + SetDashTimer = 0x0275, + DashNotOutofTime = 0x0276, + DashOutofTime = 0x0277, + ForceSceneReset = 0x0278, + NPCActive = 0x0279, + NPCInactive = 0x027A, + DuplicatorActivate = 0x027B, + DuplicatorDeactivate = 0x027C, + DashEnterTunnel = 0x027D, + DashExitTunnel = 0x027E, + StopRumbleEffect = 0x027F, + DashChaseLasersOn = 0x0280, + DashChaseLasersOff = 0x0281, + RandomJumponSpawn = 0x0282, + HitPatrickCartwheel = 0x0283, + UIVisibleFocusOnSelect = 0x0284, + UIFocusOffUnselectInvisible = 0x0285, + CopyReference = 0x0286, + UIMotionInFinished = 0x0287, + UIMotionOutFinished = 0x0288, + UISignalActivateScreen = 0x0289, + UISignalDeactivateScreen = 0x028A, + UISignalActivatedScreen = 0x028B, + UISignalSwitchScreens = 0x028C, + UISignalStartFadeOut = 0x028D, + UISignalStartFadeIn = 0x028E, + UISignalScreenMotionInDone = 0x028F, + UISignalScreenMotionOutDone = 0x0290, + UISignalMainBoxInDone = 0x0291, + UISignalMainBoxOutDone = 0x0292, + UIResetMotion = 0x0293, + UIEnableHDR = 0x0294, + UIDisableHDR = 0x0295, + UIBrighten = 0x0296, + UIUnbrighten = 0x0297, + UISignalDeactivatedScreen = 0x0298, + NPCDetectAlways = 0x0299, + NPCDetectNever = 0x029A, + NPCDetectNormal = 0x029B, + NPCFightDefault = 0x029C, + CameraCollidePartial = 0x029D, + MusicTrackPlayTemporary = 0x029E, + EvaluateCounterValue = 0x029F, + Count0 = 0x02A0, + RotatetoAbsoluteX = 0x02A1, + RotatetoAbsoluteY = 0x02A2, + RotatetoAbsoluteZ = 0x02A3, + PlayTriggerAnimation = 0x02A4, + TriggeredAnimationDone = 0x02A5, + UISignalMore = 0x02A6, + UISignalNoMore = 0x02A7, + UISignalLess = 0x02A8, + UISignalNoLess = 0x02A9, + UISignalUp = 0x02AA, + UISignalDown = 0x02AB, + UISignalSyncToCurrent = 0x02AC, + UISignalEffect = 0x02AD, + FreezePlayer = 0x02AE, + UnfreezePlayer = 0x02AF, + UISignalMapStart = 0x02B0, + UISignalMapEnd = 0x02B1, + TranslatetoAbsoluteX = 0x02B2, + TranslatetoAbsoluteY = 0x02B3, + TranslatetoAbsoluteZ = 0x02B4, + JSPVisibilityIncrement = 0x02B5, + JSPVisibilityDecrement = 0x02B6, + EnterCamera = 0x02B7, + ExitCamera = 0x02B8, + PadPressEGCZorXBOXBlack = 0x02B9, + DashSetJumpParamters = 0x02BA, + ViperFacePlayer = 0x02BB, + ViperFaceMovement = 0x02BC, + RequestStart = 0x02BD, + UIAutoMenuRun = 0x02BE, + UIAutoMenuRunUp = 0x02BF, + UIAutoMenuRunDown = 0x02C0, + UIAutoMenuRunLeft = 0x02C1, + UIAutoMenuRunRight = 0x02C2, + IncrementSuccess = 0x02C3, + DecrementSuccess = 0x02C4, + IncrementFailed = 0x02C5, + DecrementFailed = 0x02C6, + MusicTrackStopTemporaryMusic = 0x02C7, + NPCScrambleActionBegin = 0x02C8, + NPCScrambleAlert = 0x02C9, + NPCTurretSetAttackRadius = 0x02CA, + GooFreezeStart = 0x02CB, + GooMeltStart = 0x02CC, + NPCNotice = 0x02CD, + BossStageSet = 0x02CE, + BossStageBegan = 0x02CF, + BossStageEnded = 0x02D0, + BossStageABegan = 0x02D1, + BossStageAEnded = 0x02D2, + BossStageBBegan = 0x02D3, + BossStageBEnded = 0x02D4, + BossStageCBegan = 0x02D5, + BossStageCEnded = 0x02D6, + VisibilityCullOn = 0x02D7, + VisibilityCullOff = 0x02D8, + Startrbandcamera = 0x02D9, + Endrbandcamera = 0x02DA, + MindyStart = 0x02DB, + MindyEnd = 0x02DC, + FlamethrowerStart = 0x02DD, + FlamethrowerStop = 0x02DE, + FlamethrowerSetLength = 0x02DF, + NPCTakeNoDamageOn = 0x02E0, + NPCTakeNoDamageOff = 0x02E1, + StartStaticCAMFOVfilter = 0x02E2, + RestoreStaticCAMFOV = 0x02E3, + XBOXDEMOexittolauncher = 0x02E4, + Spawn = 0x02E5, + Spawned = 0x02E6, + Creditssetdest = 0x02E7, + AllowAttractMode = 0x02E8, + DisallowAttractMode = 0x02E9, + RocketAttack = 0x02EA, + CollisionReset = 0x02EB, + AutoSave = 0x02EC, + OpenBonus = 0x02ED, + FlagLevel = 0x02EE, + LevelEnd = 0x02EF, + GetLocalContent = 0x02F0, + PauseGameSafe = 0x02F1, + OverrideFrequency = 0x02F2, + ResetFrequency = 0x02F3, + SetShotDelay = 0x02F4, + SetShotsInGroup = 0x02F5, + UserSelectYes = 0x02F6, + UserSelectNo = 0x02F7, + UserSelectBack = 0x02F8, + LaunchFireWorks = 0x02F9, + Resetsuserselection = 0x02FA, + SetasBounceBack = 0x02FB, + ResetUnlockables = 0x02FC, + UISysMsgWaitResponse = 0x02FD, + UISysMsgWaitConfirm = 0x02FE, + UISysMsgConfirm = 0x02FF, + UISysMsgAccept = 0x0300, + UISysMsgDecline = 0x0301, + SetasNOTBounceBack = 0x0302, + PauseGameNow = 0x0303, + PattyWagonStartEngine = 0x0304, + PattyWagonStopEngine = 0x0305, + BubbleSpawnOn = 0x0306, + BubbleSpawnOff = 0x0307, + XBLiveToggleSignIn = 0x0308, + XBLiveManageFriends = 0x0309, + ApplyOnResetOn = 0x030A, + ApplyOnResetOff = 0x030B, + SnapTo = 0x030C, + Throw = 0x030D, + FirstZipLine = 0x030E, + FirstLedgeGrab = 0x030F, + FirstIncredimeterPickup = 0x0310, + UISparkTrail = 0x0311, + UIGetBattleScenes = 0x0312, + UIBattleScenesAvailable = 0x0313, + UIBattleScenesNotAvailable = 0x0314, + XBLiveToggleAppearOnline = 0x0315, + UIReturntopreviousscreen = 0x0316, + UIEmptyEvent = 0x0317, + SubtitlesEnabled = 0x0318, + SubtitlesDisabled = 0x0319, + UISetBoxMappingforUVs = 0x031A, + PlayerEjected = 0x031B, + DamagePlayer = 0x031C, + FirstHealthPickup = 0x031D, + TokenPickupComplete = 0x031E, + Promptisdead = 0x031F, + UIFlipVisibility = 0x0320, + XBLiveRebootToDashboard = 0x0321, + FirstPowerupPoint = 0x0322 + } +} \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/Interfaces/IRenderableAsset.cs b/IndustrialPark/Assets/Shared/Interfaces/IRenderableAsset.cs index aff39ddd..21d4b2d8 100644 --- a/IndustrialPark/Assets/Shared/Interfaces/IRenderableAsset.cs +++ b/IndustrialPark/Assets/Shared/Interfaces/IRenderableAsset.cs @@ -9,5 +9,7 @@ public interface IRenderableAsset void Draw(SharpRenderer renderer); BoundingBox GetBoundingBox(); + + float GetDistance(Vector3 cameraPosition); } } \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/ObjectAsset.cs b/IndustrialPark/Assets/Shared/ObjectAsset.cs index ec27e6fd..8cf8c3a1 100644 --- a/IndustrialPark/Assets/Shared/ObjectAsset.cs +++ b/IndustrialPark/Assets/Shared/ObjectAsset.cs @@ -1,5 +1,8 @@ using HipHopFile; +using System.Collections.Generic; using System.ComponentModel; +using System.Linq; +using static HipHopFile.Functions; namespace IndustrialPark { @@ -41,10 +44,43 @@ public short UnknownFlag [Category("Object")] public AssetEvent[] Events { - get => ReadEvents(EventStartOffset); - set => WriteEvents(EventStartOffset, value); + get => ReadEvents(); + set => WriteEvents(value); } protected virtual int EventStartOffset { get => Data.Length - AmountOfEvents * AssetEvent.sizeOfStruct; } + + protected AssetEvent[] ReadEvents() + { + byte amount = ReadByte(0x05); + AssetEvent[] events = new AssetEvent[amount]; + + if (currentGame == Game.BFBB | currentGame == Game.Scooby) + { + for (int i = 0; i < amount; i++) + events[i] = new AssetEventBFBB(Data, EventStartOffset + i * AssetEvent.sizeOfStruct); + } + else if (currentGame == Game.Incredibles) + { + for (int i = 0; i < amount; i++) + events[i] = new AssetEventTSSM(Data, EventStartOffset + i * AssetEvent.sizeOfStruct); + } + + return events; + } + + protected void WriteEvents(AssetEvent[] value) + { + List newData = Data.Take(EventStartOffset).ToList(); + List bytesAfterEvents = Data.Skip(EventStartOffset + ReadByte(0x05) * AssetEvent.sizeOfStruct).ToList(); + + for (int i = 0; i < value.Length; i++) + newData.AddRange(value[i].ToByteArray()); + + newData.AddRange(bytesAfterEvents); + newData[0x05] = (byte)value.Length; + + Data = newData.ToArray(); + } } } \ No newline at end of file diff --git a/IndustrialPark/Assets/Shared/PlaceableAsset.cs b/IndustrialPark/Assets/Shared/PlaceableAsset.cs index c92658f6..1e91df5f 100644 --- a/IndustrialPark/Assets/Shared/PlaceableAsset.cs +++ b/IndustrialPark/Assets/Shared/PlaceableAsset.cs @@ -22,8 +22,8 @@ public virtual void Setup() _modelAssetID = ReadUInt(0x4C + Offset); CreateTransformMatrix(); - if (!ArchiveEditorFunctions.renderableAssetSet.Contains(this)) - ArchiveEditorFunctions.renderableAssetSet.Add(this); + if (!ArchiveEditorFunctions.renderableAssetSetCommon.Contains(this)) + ArchiveEditorFunctions.renderableAssetSetCommon.Add(this); } public virtual void CreateTransformMatrix() @@ -127,6 +127,11 @@ public BoundingBox GetBoundingBox() return boundingBox; } + public virtual float GetDistance(Vector3 cameraPosition) + { + return Vector3.Distance(cameraPosition, _position); + } + [Category("Flags"), TypeConverter(typeof(HexByteTypeConverter))] public byte VisibilityFlag { diff --git a/IndustrialPark/IndustrialPark.csproj b/IndustrialPark/IndustrialPark.csproj index 9527571c..afcaa479 100644 --- a/IndustrialPark/IndustrialPark.csproj +++ b/IndustrialPark/IndustrialPark.csproj @@ -125,6 +125,7 @@ + @@ -133,6 +134,9 @@ + + + diff --git a/IndustrialPark/MainForm/AboutBox.Designer.cs b/IndustrialPark/MainForm/AboutBox.Designer.cs index 70524430..4f656b30 100644 --- a/IndustrialPark/MainForm/AboutBox.Designer.cs +++ b/IndustrialPark/MainForm/AboutBox.Designer.cs @@ -103,7 +103,7 @@ private void InitializeComponent() this.labelVersion.Name = "labelVersion"; this.labelVersion.Size = new System.Drawing.Size(271, 17); this.labelVersion.TabIndex = 0; - this.labelVersion.Text = "Preview 8"; + this.labelVersion.Text = "Preview 10"; this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // labelCopyright diff --git a/IndustrialPark/MainForm/MainForm.cs b/IndustrialPark/MainForm/MainForm.cs index 8599459f..be36fd9c 100644 --- a/IndustrialPark/MainForm/MainForm.cs +++ b/IndustrialPark/MainForm/MainForm.cs @@ -188,9 +188,16 @@ public void CloseAssetEditor(ArchiveEditor sender) { int index = archiveEditors.IndexOf(sender); archiveEditorToolStripMenuItem.DropDownItems.RemoveAt(index + 2); + archiveEditors[index].DisposeAll(); archiveEditors.RemoveAt(index); } + public void DisposeAllArchiveEditors() + { + foreach (ArchiveEditor ae in archiveEditors) + ae.DisposeAll(); + } + private void noCullingCToolStripMenuItem_Click(object sender, EventArgs e) { ToggleCulling(); @@ -289,20 +296,27 @@ private void renderPanel_MouseDown(object sender, MouseEventArgs e) public void ScreenClicked(Rectangle viewRectangle, int X, int Y, bool isMouseDown = false) { Ray ray = Ray.GetPickRay(X, Y, new Viewport(viewRectangle), renderer.viewProjection); - foreach (ArchiveEditor ae in archiveEditors) - ae.ScreenClicked(ray, isMouseDown); + + if (ArchiveEditorFunctions.FinishedMovingGizmo) + ArchiveEditorFunctions.FinishedMovingGizmo = false; + else + ArchiveEditor.ScreenClicked(ray, isMouseDown); } private void renderPanel_MouseUp(object sender, MouseEventArgs e) { - foreach (ArchiveEditor ae in archiveEditors) - ae.ScreenUnclicked(); + ArchiveEditor.ScreenUnclicked(); } private void renderPanel_MouseLeave(object sender, EventArgs e) + { + ArchiveEditor.ScreenUnclicked(); + } + + public void SetSelectedIndex(uint assetID) { foreach (ArchiveEditor ae in archiveEditors) - ae.ScreenUnclicked(); + ae.SetSelectedIndex(assetID); } private void addTextureFolderToolStripMenuItem_Click(object sender, EventArgs e) diff --git a/IndustrialPark/SharpDX/RenderWareModelFile.cs b/IndustrialPark/SharpDX/RenderWareModelFile.cs index 7f7a213d..077f04b8 100644 --- a/IndustrialPark/SharpDX/RenderWareModelFile.cs +++ b/IndustrialPark/SharpDX/RenderWareModelFile.cs @@ -464,7 +464,7 @@ public void Render(SharpRenderer renderer, Matrix world, Vector4 color) renderer.device.UpdateData(renderer.tintedBuffer, renderData); renderer.device.DeviceContext.VertexShader.SetConstantBuffer(0, renderer.tintedBuffer); renderer.tintedShader.Apply(); - + foreach (SharpMesh mesh in meshList) { if (mesh == null) continue; diff --git a/IndustrialPark/SharpDX/SharpRenderer.cs b/IndustrialPark/SharpDX/SharpRenderer.cs index 82afda73..4425b8ec 100644 --- a/IndustrialPark/SharpDX/SharpRenderer.cs +++ b/IndustrialPark/SharpDX/SharpRenderer.cs @@ -5,6 +5,7 @@ using SharpDX.Windows; using System.Collections.Generic; using static IndustrialPark.Models.OBJFunctions; +using System.Linq; namespace IndustrialPark { @@ -172,18 +173,19 @@ public void SetWidgetColor(System.Drawing.Color color) public void ResetSelectionColor() { - normalColor = new Vector4(0.2f, 0.6f, 0.8f, 0.8f); - selectedColor = new Vector4(1f, 0.5f, 0.1f, 0.8f); + normalColor = new Vector4(0.2f, 0.6f, 0.8f, 0.55f); + selectedColor = new Vector4(1f, 0.5f, 0.1f, 0.55f); selectedObjectColor = new Vector4(1f, 0f, 0f, 1f); } - public Vector4 normalColor = new Vector4(0.2f, 0.6f, 0.8f, 0.8f); - public Vector4 selectedColor = new Vector4(1f, 0.5f, 0.1f, 0.8f); - public Vector4 selectedObjectColor = new Vector4(1f, 0f, 0f, 1f); - DefaultRenderData renderData; + public Vector4 normalColor; + public Vector4 selectedColor; + public Vector4 selectedObjectColor; public void DrawCube(Matrix world, bool isSelected, float multiplier = 0.5f) { + DefaultRenderData renderData; + renderData.worldViewProjection = Matrix.Scaling(multiplier) * world * viewProjection; if (isSelected) @@ -191,12 +193,6 @@ public void DrawCube(Matrix world, bool isSelected, float multiplier = 0.5f) else renderData.Color = normalColor; - device.SetFillModeDefault(); - device.SetCullModeNone(); - device.SetBlendStateAlphaBlend(); - device.ApplyRasterState(); - device.UpdateAllStates(); - device.UpdateData(basicBuffer, renderData); device.DeviceContext.VertexShader.SetConstantBuffer(0, basicBuffer); basicShader.Apply(); @@ -206,19 +202,15 @@ public void DrawCube(Matrix world, bool isSelected, float multiplier = 0.5f) public void DrawPyramid(Matrix world, bool isSelected, float multiplier = 0.5f) { + DefaultRenderData renderData; + renderData.worldViewProjection = Matrix.Scaling(multiplier) * world * viewProjection; if (isSelected) renderData.Color = selectedColor; else renderData.Color = normalColor; - - device.SetFillModeDefault(); - device.SetCullModeNone(); - device.SetBlendStateAlphaBlend(); - device.ApplyRasterState(); - device.UpdateAllStates(); - + device.UpdateData(basicBuffer, renderData); device.DeviceContext.VertexShader.SetConstantBuffer(0, basicBuffer); basicShader.Apply(); @@ -228,6 +220,8 @@ public void DrawPyramid(Matrix world, bool isSelected, float multiplier = 0.5f) public void DrawSphere(Matrix world, bool isSelected) { + DefaultRenderData renderData; + renderData.worldViewProjection = world * viewProjection; if (isSelected) @@ -235,12 +229,6 @@ public void DrawSphere(Matrix world, bool isSelected) else renderData.Color = normalColor; - device.SetFillModeDefault(); - device.SetCullModeNone(); - device.SetBlendStateAlphaBlend(); - device.ApplyRasterState(); - device.UpdateAllStates(); - device.UpdateData(basicBuffer, renderData); device.DeviceContext.VertexShader.SetConstantBuffer(0, basicBuffer); basicShader.Apply(); @@ -277,34 +265,61 @@ public void RunMainLoop(Panel Panel) device.SetFillModeDefault(); device.SetCullModeDefault(); + device.ApplyRasterState(); device.SetBlendStateAlphaBlend(); device.SetDefaultDepthState(); - device.ApplyRasterState(); device.UpdateAllStates(); - List renderableAssetSet = new List(); - try - { - renderableAssetSet.AddRange(ArchiveEditorFunctions.renderableAssetSet); - } - catch + List renderJSP = new List(); + List renderCommon = new List(); + List renderTrans = new List(); + List renderLarge = new List(); + + renderJSP.AddRange(ArchiveEditorFunctions.renderableAssetSetJSP); + renderCommon.AddRange(ArchiveEditorFunctions.renderableAssetSetCommon); + renderTrans.AddRange(ArchiveEditorFunctions.renderableAssetSetTrans); + + renderCommon = renderCommon.OrderBy(f => f.GetDistance(Camera.Position)).Reverse().ToList(); + renderTrans = renderTrans.OrderBy(f => f.GetDistance(Camera.Position)).Reverse().ToList(); + + foreach (IRenderableAsset a in renderJSP) + a.Draw(this); + + foreach (IRenderableAsset a in renderCommon) { - return; + BoundingBox bb = a.GetBoundingBox(); + if (bb.Width > 100) + renderLarge.Add(a); + else if (a is AssetPKUP assetPKUP && AssetPICK.pickEntries.Count == 0) + renderTrans.Add(a); + else if (frustum.Intersects(ref bb)) + a.Draw(this); } - foreach (IRenderableAsset a in renderableAssetSet) + device.SetFillModeSolid(); + device.SetCullModeNone(); + device.ApplyRasterState(); + device.SetBlendStateAlphaBlend(); + device.SetDefaultDepthState(); + device.UpdateAllStates(); + + foreach (IRenderableAsset a in renderTrans) { - if (a is AssetJSP) - (a as AssetJSP).Draw(this); + BoundingBox bb = a.GetBoundingBox(); + if (frustum.Intersects(ref bb)) + a.Draw(this); } - foreach (IRenderableAsset a in renderableAssetSet) + + device.SetFillModeDefault(); + device.SetCullModeDefault(); + device.ApplyRasterState(); + device.SetBlendStateAlphaBlend(); + device.SetDefaultDepthState(); + device.UpdateAllStates(); + + foreach (IRenderableAsset a in renderLarge) { - if (!(a is AssetJSP)) - { - BoundingBox bb = a.GetBoundingBox(); - if (frustum.Intersects(ref bb)) - a.Draw(this); - } + a.Draw(this); } ArchiveEditorFunctions.RenderGizmos(this); @@ -312,6 +327,8 @@ public void RunMainLoop(Panel Panel) device.Present(); }); + Program.MainForm.DisposeAllArchiveEditors(); + //release resources whiteDefault.Dispose(); TextureManager.DisposeTextures(); diff --git a/IndustrialPark/SharpDX/TextureManager.cs b/IndustrialPark/SharpDX/TextureManager.cs index 2be5b697..e1d74479 100644 --- a/IndustrialPark/SharpDX/TextureManager.cs +++ b/IndustrialPark/SharpDX/TextureManager.cs @@ -119,7 +119,7 @@ public static void ReapplyTextures() models.Add(awm.GetRenderWareModelFile()); } catch { } - foreach (IRenderableAsset awm in ArchiveEditorFunctions.renderableAssetSet) + foreach (IRenderableAsset awm in ArchiveEditorFunctions.renderableAssetSetJSP) if (awm is AssetJSP alm) try {