Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Build Mode Test Scene #57

Draft
wants to merge 149 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
13e9af6
Build Mode initial push
JDrocks450 Dec 19, 2023
c773657
Update Foundation Tool to have Wallpaper and Floor Patterning
JDrocks450 Jan 22, 2024
e753e06
Fix wall facade performance issue when dragging out unplaced walls.
JDrocks450 Jan 22, 2024
58d1baf
Remove comment.
JDrocks450 Jan 22, 2024
feac9ba
Fix bug with detecting floors and implemented feature into terrain le…
JDrocks450 Jan 22, 2024
60a398c
Merge pull request #1 from LazyDuchess/master
JDrocks450 Jun 16, 2024
45d62d3
Organization, don't ship editor-only code.
LazyDuchess Jun 21, 2024
5cfa4de
Add decals to always included shaders
LazyDuchess Jun 21, 2024
4c4a365
Automatically ship shaders on build
LazyDuchess Jun 21, 2024
78dea09
Update BuildPreProcessor.cs
LazyDuchess Jun 21, 2024
c30f7af
BuildPreProcessor -> ShaderBuildPreProcessor
LazyDuchess Jun 21, 2024
3bce65e
Fix compile warnings, remove unused stuff
LazyDuchess Jun 21, 2024
17a96b2
Add notes about music categories
LazyDuchess Jun 22, 2024
e022430
expand notes, how radio stations work
LazyDuchess Jun 22, 2024
2885a5f
Notes on localization of music
LazyDuchess Jun 22, 2024
81c54d2
Small refactor, log music categories
LazyDuchess Jun 22, 2024
c3fca97
add musiccategory class, clean up singletons
LazyDuchess Jun 22, 2024
9ee5408
Singleton -> Instance
LazyDuchess Jun 22, 2024
09fb6a8
Implement music playlists
LazyDuchess Jun 23, 2024
ab86193
Lazy music implementation
LazyDuchess Jun 23, 2024
500844a
make a wrapper for audio source that can handle mp3 and wav
LazyDuchess Jun 23, 2024
f718a75
handle single song playlists
LazyDuchess Jun 23, 2024
3440e9d
improve audio source end detection a bit
LazyDuchess Jun 23, 2024
dc715ff
Fix looping stuff, remove unused things
LazyDuchess Jun 23, 2024
a8e9631
small refactoring
LazyDuchess Jun 23, 2024
6781cbc
support wav audio, add cheat to play music categories
LazyDuchess Jun 23, 2024
762661c
Add support for Speex audio
LazyDuchess Jun 23, 2024
d7f5dd9
Add acknowledgments to NAudio and NSpeex
LazyDuchess Jun 23, 2024
7a62d1a
add note for text alignment
LazyDuchess Jun 23, 2024
4a9c7bd
notes on sounds
LazyDuchess Jun 24, 2024
b833b56
refactor audio type stuff
LazyDuchess Jun 24, 2024
3ced755
Add AudioManager
LazyDuchess Jun 24, 2024
600b9c9
Implement UI sound references
LazyDuchess Jun 24, 2024
b6853eb
Implement hitlist audio
LazyDuchess Jun 24, 2024
67f5a08
Fix musicmanager possible null ref
LazyDuchess Jun 24, 2024
71e55b7
Add state transitions for audio and music
LazyDuchess Jun 24, 2024
7197402
Load rest of music categories from ini files
LazyDuchess Jun 24, 2024
51c4634
Fix MP3 volume
LazyDuchess Jun 24, 2024
5da0d55
Audio mixers
LazyDuchess Jun 24, 2024
5dc979f
Fix UILayoutTest
LazyDuchess Jun 24, 2024
8e8ed73
ui notes
LazyDuchess Jun 24, 2024
c37190e
remove enableDecals property
LazyDuchess Jun 24, 2024
e951228
refactor console props a bit
LazyDuchess Jun 24, 2024
46ff93a
Add props for volumes
LazyDuchess Jun 24, 2024
a477999
Update GamePropertyAttribute.cs
LazyDuchess Jun 24, 2024
02b1afe
add option to mute audio on focus loss
LazyDuchess Jun 25, 2024
bf63822
custom music, ability to map files to resource keys
LazyDuchess Jun 25, 2024
c012057
dont save onapplicationquit
LazyDuchess Jun 25, 2024
7ea1777
use 1 tuple key dictionary for audio assets
LazyDuchess Jun 26, 2024
e21c81b
Refactor startup and main menu into their own scenes
LazyDuchess Jun 26, 2024
4aa1bac
ObjectManager refactor
LazyDuchess Jun 26, 2024
ebc7b18
ContentProvider -> ContentManager, refactor
LazyDuchess Jun 26, 2024
bcad5fe
Move Main to Core, TestMain -> TestCore
LazyDuchess Jun 26, 2024
1ef54c0
Settings.Get() -> Settings.Instance, resourcekey fixes
LazyDuchess Jun 26, 2024
fe475bc
CatalogManager refactor
LazyDuchess Jun 26, 2024
8b0deba
EPManager Refactor
LazyDuchess Jun 26, 2024
131a801
Refactor singleton naming
LazyDuchess Jun 26, 2024
1b3f5af
Refactor EffectsManager
LazyDuchess Jun 26, 2024
b4dfc18
Refactor LuaManager
LazyDuchess Jun 26, 2024
37ae8dc
Clean up AudioManager and ObjectManager a bit
LazyDuchess Jun 26, 2024
517e05b
neighborhoodmanager, effectsmanager
LazyDuchess Jun 26, 2024
fe9f033
fix startup prefab
LazyDuchess Jun 26, 2024
cf37cc2
Move PluginSupport to Core
LazyDuchess Jun 26, 2024
1797a71
Refactor some static stuff into singletons
LazyDuchess Jun 26, 2024
5ef6e6f
Include all shaders on build
LazyDuchess Jun 26, 2024
b943ef5
ScriptsAssembly -> OpenTS2, fix references
LazyDuchess Jun 26, 2024
8d7124f
Fix unit test ContentManager state carrying over... whoops.
LazyDuchess Jun 26, 2024
6fa5e21
Update README.md
LazyDuchess Jun 26, 2024
55e033b
remove useless debug log in stringset test
LazyDuchess Jun 27, 2024
fefd745
add codec for lot package lot info asset
LazyDuchess Jun 28, 2024
614fac4
get base lot info working, extremely early cas/lot logic
LazyDuchess Jun 28, 2024
6dd578b
remove test stuff from core
LazyDuchess Jun 28, 2024
553d229
invoke onlotloaded
LazyDuchess Jun 28, 2024
11b4521
Manage simulator via script
LazyDuchess Jun 28, 2024
aa50501
implement simulator loop
LazyDuchess Jun 28, 2024
f9ac5cb
Fix simantics infinite loop unit test
LazyDuchess Jun 28, 2024
f749586
set music volume to 1
LazyDuchess Jun 28, 2024
5396d7e
async content loader, load music async
LazyDuchess Jun 28, 2024
b82da1c
small refactoring
LazyDuchess Jun 28, 2024
a655e26
replace naudio with nlayer
LazyDuchess Jun 28, 2024
e83c34b
remove naudio
LazyDuchess Jun 28, 2024
02ff168
fix tgi on file mapped resources
LazyDuchess Jun 28, 2024
c02845f
Update README.md
LazyDuchess Jun 28, 2024
4798f3e
Update NLayer.dll
LazyDuchess Jun 28, 2024
4353a8d
Bring back NAudio - NLayer was kinda buggy.
LazyDuchess Jun 29, 2024
d52604f
fix build errors
LazyDuchess Jun 29, 2024
56fa955
interrupt asynccontentmanager
LazyDuchess Jun 29, 2024
913a87d
use delegates in asynccontentmanager
LazyDuchess Jun 29, 2024
8f28284
Don't add packages in main thread on finish load
LazyDuchess Jun 29, 2024
0574df3
fix duplicated shaders
LazyDuchess Jun 29, 2024
e4a72d3
Make DBPF File reading thread safe
LazyDuchess Jun 30, 2024
98f1dbe
Add test tool to convert all speech to wav
LazyDuchess Jun 30, 2024
8c80e79
SpeechEnhancer -> SPXConverter
LazyDuchess Jun 30, 2024
6120156
Fix sharing violation when writing packages
LazyDuchess Jun 30, 2024
e19875e
add particle shader to included shaders
LazyDuchess Jun 30, 2024
4ebbff1
bye bye asynccontentmanager
LazyDuchess Jun 30, 2024
974f794
Handle failure to compress resources
LazyDuchess Jun 30, 2024
5c8e7a2
fix writing invalid packages
LazyDuchess Jun 30, 2024
7574a9b
convert simulator tickrate to seconds
LazyDuchess Jul 6, 2024
2df0533
Fix simulator running every frame
LazyDuchess Jul 6, 2024
5eb08fe
Fix mp3 audio not restarting playback
LazyDuchess Jul 6, 2024
bf96ca2
fix typo
LazyDuchess Jul 6, 2024
aa98a6f
okay actually fix mp3 restarting now
LazyDuchess Jul 6, 2024
241ea9e
Set company name to OpenTS2
LazyDuchess Jul 7, 2024
790a64d
Refactor Filesystem, get rid of JSONPathProvider
LazyDuchess Jul 8, 2024
561917e
UI Button: Play sound on button down
LazyDuchess Jul 9, 2024
dab570a
SimAntics: Implement Semi-Attributes, fix Attribute count
LazyDuchess Jul 9, 2024
844bb34
SimAntics: Implement Semi-Attribute set
LazyDuchess Jul 9, 2024
9a9cb8d
Argumentoutofrange -> indexoutofrange
LazyDuchess Jul 9, 2024
25763a9
Fix wrong semiglobal type ID....
LazyDuchess Jul 9, 2024
406c3f2
Allow viewing/editing VM globals in Unity Editor
LazyDuchess Jul 10, 2024
6ee3464
Add VM Entity inspector
LazyDuchess Jul 10, 2024
30e5a17
Optimize ContentManager.GetEntriesOfType
LazyDuchess Jul 10, 2024
4d2c017
Add Neighbor asset and NeighborManager
LazyDuchess Jul 10, 2024
0b13887
Load neighbors and associated object ids
LazyDuchess Jul 10, 2024
fb19042
Add inspector for NeighborManager
LazyDuchess Jul 10, 2024
dc3c2da
Use transform.SetParent instead of transform.parent on UI
LazyDuchess Jul 19, 2024
66dbd77
Optimize neighborhood rendering a bunch
LazyDuchess Aug 4, 2024
10d4ad5
Update TagManager.asset
LazyDuchess Aug 4, 2024
ca6f51c
Set road normals
LazyDuchess Aug 4, 2024
925ef2d
Optimize decal rendering
LazyDuchess Aug 4, 2024
6713ef4
Fix build error cause of UnityEditor using
LazyDuchess Aug 4, 2024
c7748c7
Fix decal rotation
LazyDuchess Aug 4, 2024
52aef0d
Update GraphicsSettings.asset
LazyDuchess Aug 4, 2024
71c4e36
Disable batching by default
LazyDuchess Aug 5, 2024
8b5a27f
add extension to set layers for whole hierarchy
LazyDuchess Aug 5, 2024
3f309c8
Fix SimAnimationTest
LazyDuchess Sep 4, 2024
53bfe6f
Add Codec for ObjectSaveTypeTable (OBJT in SimsPE)
ammaraskar Oct 4, 2024
a21b12f
Start adding codecs for OBJM and XOBJ files
ammaraskar Oct 4, 2024
205ef1f
Fix compilation errors from test code changes
ammaraskar Oct 4, 2024
3bcb9bc
Fix reading of XOBJ files
ammaraskar Oct 9, 2024
e5fa723
Make OBJX decoding version dependent
ammaraskar Oct 12, 2024
f912b8d
Add missing InitializeCore calls in test scenes
ammaraskar Oct 13, 2024
6c5f6d2
Add scene for testing loading objects and simulator from lot
ammaraskar Oct 14, 2024
1eef063
Add data to SimsObjectAsset and start simulation ticking
ammaraskar Oct 14, 2024
e91e799
Fix Ini reading end of file too early
LazyDuchess Oct 17, 2024
3086b58
Load BHAV from the actual entity that pushed it onto the stack
ammaraskar Oct 18, 2024
5611766
Deserialize XOBJ with correct version from OBJM file
ammaraskar Oct 18, 2024
cabc1f1
Fix SimAntics unit test
ammaraskar Oct 18, 2024
265662f
Fix object state codec for latest game version
ammaraskar Oct 20, 2024
4e6596a
Try to fix which object state we load
ammaraskar Oct 20, 2024
67006aa
Add build tools enum for ease of use and start on Runtime Wall Contro…
JDrocks450 Dec 9, 2024
29a9c91
Build Mode initial push
JDrocks450 Dec 19, 2023
47c6875
Update Foundation Tool to have Wallpaper and Floor Patterning
JDrocks450 Jan 22, 2024
f509364
Fix wall facade performance issue when dragging out unplaced walls.
JDrocks450 Jan 22, 2024
7d76abd
Remove comment.
JDrocks450 Jan 22, 2024
9ee2fad
Fix bug with detecting floors and implemented feature into terrain le…
JDrocks450 Jan 22, 2024
d5788dd
Add build tools enum for ease of use and start on Runtime Wall Contro…
JDrocks450 Dec 9, 2024
05f15f7
Git Rebase to latest
JDrocks450 Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions Assets/Editor/OpenTS2.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Editor/OpenTS2/Engine.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Editor/OpenTS2/Engine/Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 110 additions & 0 deletions Assets/Editor/OpenTS2/Engine/Tests/LotLoadingTestEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
using OpenTS2.Engine.Tests;
using OpenTS2.Engine;
using OpenTS2.Files;
using OpenTS2.Scenes.Lot.State;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;

namespace OpenTS2.Engine.Tests
{
[CustomEditor(typeof(LotLoadingTest))]
public class LotLoadingTestEditor : Editor
{
private string _cachedNhood = "";
private List<string> NhoodNames = new List<string>() { "N001" };
private List<int> LotIds = new List<int>() { 82 };

public LotLoadingTestEditor()
{
PopulateNhoodList();
}

private void PopulateNhoodList()
{
NhoodNames.Clear();

var nhoodFolderPath = Path.Combine(Filesystem.UserDataDirectory, $"Neighborhoods");

foreach (var nhood in Directory.GetDirectories(nhoodFolderPath))
{
string filename = Path.GetFileName(nhood);

if (filename.Length == 4)
{
NhoodNames.Add(filename);
}
}
}

private void PopulateLotList(string nhood)
{
_cachedNhood = nhood;
var lotsFolderPath = Path.Combine(Filesystem.UserDataDirectory, $"Neighborhoods/{nhood}/Lots");

LotIds.Clear();

try
{
foreach (string file in Directory.GetFiles(lotsFolderPath))
{
if (file.EndsWith(".package"))
{
int tIndex = file.LastIndexOf('t');
int end = file.Length - ".package".Length;
string lotIdProbably = file.Substring(tIndex + 1, end - (tIndex + 1));

if (int.TryParse(lotIdProbably, out int lotId))
{
LotIds.Add(lotId);
}
}
}
}
catch
{

}

LotIds.Sort();
}

public override void OnInspectorGUI()
{
var test = target as LotLoadingTest;

Core.InitializeCore();

string[] noptions = NhoodNames.ToArray();
int nindex = EditorGUILayout.Popup("Neighborhood", NhoodNames.IndexOf(test.NeighborhoodPrefix), noptions);
if (nindex > -1)
{
test.NeighborhoodPrefix = NhoodNames[nindex];
}

if (test.NeighborhoodPrefix != _cachedNhood)
{
PopulateLotList(test.NeighborhoodPrefix);
}

string[] options = LotIds.Select(x => "Lot " + x.ToString()).ToArray();
int index = EditorGUILayout.Popup("Lot ID", LotIds.IndexOf(test.LotID), options);
if (index > -1)
{
test.LotID = LotIds[index];
}

WallsMode walls = (WallsMode)EditorGUILayout.EnumPopup("Walls", test.Mode);
test.Mode = walls;

int floor = EditorGUILayout.IntSlider(test.Floor, 1, test.MaxFloor + test.BaseFloor);
test.Floor = floor;

test.Changed();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEditor;
using OpenTS2.Common;

namespace OpenTS2.Editor
namespace OpenTS2
{
class IDGenerator : EditorWindow
{
Expand Down
40 changes: 40 additions & 0 deletions Assets/Editor/OpenTS2/NeighborManagerEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using OpenTS2.Content;
using OpenTS2.Game;
using OpenTS2.SimAntics;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

namespace OpenTS2
{
[CustomEditor(typeof(NeighborManager))]
public class NeighborManagerEditor : Editor
{
private bool _showNeighbors = false;
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var neighborManager = target as NeighborManager;
_showNeighbors = EditorGUILayout.Foldout(_showNeighbors, "Neighbors");
if (_showNeighbors)
{
var neighbors = neighborManager.Neighbors;
EditorGUI.indentLevel++;
foreach(var neighbor in neighbors)
{
GUILayout.BeginVertical("box");
GUILayout.Label($"{neighbor.ObjectDefinition.FileName}");
GUILayout.Label($"Neighbor ID {neighbor.Id}");
GUILayout.Label($"Object GUID 0x{neighbor.GUID:X8}");
GUILayout.EndVertical();
}
EditorGUI.indentLevel--;
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

139 changes: 139 additions & 0 deletions Assets/Editor/OpenTS2/SPXConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
using OpenTS2.Common;
using OpenTS2.Content;
using OpenTS2.Content.DBPF;
using OpenTS2.Engine;
using OpenTS2.Files;
using OpenTS2.Files.Formats.DBPF;
using OpenTS2.Files.Formats.SPX;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

namespace OpenTS2
{
public class SPXConverter
{
[MenuItem("OpenTS2/Experiments/Convert all SPX to WAV")]
private static void ConvertSPX()
{
var baseGameOnly = false;
var compressed = false;
if (!EditorUtility.DisplayDialog("SPX to WAV", "This operation will convert ALL SPX resources to WAV. This will take a while and use a lot of resources. Proceed?", "Yes", "No"))
return;
baseGameOnly = EditorUtility.DisplayDialog("SPX to WAV", "Which products do you want to convert?", "Base-Game only", "All products");
compressed = EditorUtility.DisplayDialog("SPX to WAV", "Do you want to compress the resulting packages?", "Yes", "No");
Core.CoreInitialized = false;
Core.InitializeCore();
if (baseGameOnly)
EPManager.Instance.InstalledProducts = (int)ProductFlags.BaseGame;
var epManager = EPManager.Instance;
var products = Filesystem.GetProductDirectories();
var contentManager = ContentManager.Instance;

foreach (var product in products)
{
var packages = Filesystem.GetPackagesInDirectory(Path.Combine(product, "TSData/Res/Sound"));
contentManager.AddPackages(packages);
}

var audioResources = contentManager.ResourceMap.Where(x => x.Key.TypeID == TypeIDs.AUDIO);
var speechResources = new List<DBPFEntry>();
var speechPackages = new HashSet<string>();
Debug.Log($"Found {audioResources.Count()} Audio Resources.");
Debug.Log($"Looking for speech resources...");

new Thread(async () =>
{
foreach (var audioResource in audioResources)
{
try
{
var audioData = audioResource.Value.GetBytes();
var magic = Encoding.UTF8.GetString(audioData, 0, 2);
if (magic == "SP")
{
speechResources.Add(audioResource.Value);
var packageFileName = Path.GetFileName(audioResource.Value.Package.FilePath);
speechPackages.Add(packageFileName);
}
}
catch (Exception) { }
}

Debug.Log($"Found {speechResources.Count} SPX audio resources, in {speechPackages.Count} packages.");
var packagesStr = "Packages:";
foreach (var package in speechPackages)
{
packagesStr += $"\n{package}";
}
Debug.Log(packagesStr);

GC.Collect();
foreach (var package in speechPackages)
{
Debug.Log($"Starting work on {package}");
var newPackage = new DBPFFile();
newPackage.FilePath = Path.Combine("SPX to WAV", package);
var entriesToDoForThisPackage = new List<DBPFEntry>();
foreach (var spx in speechResources)
{
try
{
if (spx.Package == null) continue;
if (Path.GetFileName(spx.Package.FilePath) != package) continue;
entriesToDoForThisPackage.Add(spx);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
Debug.Log($"Will convert {entriesToDoForThisPackage.Count} Entries");
var tasks = new List<Task>();
var centry = 0;
foreach (var entry in entriesToDoForThisPackage)
{
centry += 1;
var capturedEntry = centry;
tasks.Add(Task.Run(() =>
{
if (capturedEntry % 500 == 0)
Debug.Log($"Progress: {capturedEntry}/{entriesToDoForThisPackage.Count}");
try
{
var spxFile = new SPXFile(entry.GetBytes());
if (spxFile != null && spxFile.DecompressedData != null && spxFile.DecompressedData.Length > 0)
newPackage.Changes.Set(spxFile.DecompressedData, entry.TGI, compressed);
}
catch (Exception e)
{
Debug.LogError(e);
}
}));
}
await Task.WhenAll(tasks).ContinueWith((task) =>
{
try
{
Debug.Log("Writing to disk...");
newPackage.WriteToFile();
Debug.Log($"Completed {package}!");
GC.Collect();
}
catch (Exception e)
{
Debug.LogError(e);
}
}, TaskScheduler.Default);
}
Debug.Log("All SPX has been converted to WAV! Resulting packages have been written to the SPX to WAV folder.");
}).Start();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading