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

1.14.0 #684

Merged
merged 55 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f7b59cf
Add shuttle handler
MegaPiggy Nov 20, 2022
9d4dd66
Add shuttle builder
MegaPiggy Nov 21, 2022
32378ce
Updated Schemas
Bwc9876 Nov 21, 2022
d133cd4
Merge branch 'dev' into shuttle
MegaPiggy Nov 24, 2022
53474c6
check for NomaiObject
MegaPiggy Nov 24, 2022
4435886
Add gravity cannons
MegaPiggy Nov 24, 2022
a4fdff5
Updated Schemas
Bwc9876 Nov 25, 2022
3bfabad
Merge branch 'dev' into shuttle
xen-42 Jul 22, 2023
ed66cb0
Fix update from dev
xen-42 Jul 22, 2023
e809a7b
Updated Schemas
Bwc9876 Jul 22, 2023
1f68a12
Can't use vessel computers
xen-42 Jul 22, 2023
edd81d0
Merge branch 'shuttle' of https://github.com/Outer-Wilds-New-Horizons…
xen-42 Jul 22, 2023
cd77401
Updated Schemas
Bwc9876 Jul 22, 2023
615fe2f
Keep shuttles/cannons loaded, fix cannon fact NRE
xen-42 Jul 22, 2023
56c463f
Fix gravity cannon orb
xen-42 Jul 22, 2023
b643875
Merge branch 'shuttle' of https://github.com/Outer-Wilds-New-Horizons…
xen-42 Jul 22, 2023
e4c8b14
Add in the platform, allow separately placing the cannon and the cont…
xen-42 Jul 22, 2023
8f394fd
Updated Schemas
Bwc9876 Jul 22, 2023
fc903b4
Make setting default system less garbage
xen-42 Aug 3, 2023
61d9947
Let center of the universe be deactivated when it needs to be
xen-42 Aug 3, 2023
331211c
Remove unnecessary null or empty check
xen-42 Aug 5, 2023
325b93e
Fix stuff (#681)
xen-42 Aug 5, 2023
9becbd8
Merge branch 'dev' into shuttle
xen-42 Aug 5, 2023
fba6b1e
Delete entire solar system using cool EOTS method thanks John
xen-42 Aug 5, 2023
59980f8
Do non detailed
xen-42 Aug 5, 2023
7c745b9
Fix destruction
xen-42 Aug 5, 2023
6c18dd2
Fix undetailed prefab
xen-42 Aug 5, 2023
6de7328
Updated Schemas
Bwc9876 Aug 5, 2023
963c672
Don't replace sectors inside details if the sector is in that detail
xen-42 Aug 5, 2023
37856ca
Merge branch 'shuttle' of https://github.com/Outer-Wilds-New-Horizons…
xen-42 Aug 5, 2023
76705a5
Fix the not detailed prefab
xen-42 Aug 5, 2023
42bbe4b
planet destruction: also exclude probe
JohnCorby Aug 5, 2023
0ce611e
simplify another pattern
JohnCorby Aug 5, 2023
d284380
Gravity cannon computer will write the planet the Shuttle starts on
xen-42 Aug 5, 2023
c1f1859
Merge branch 'shuttle' of https://github.com/Outer-Wilds-New-Horizons…
xen-42 Aug 5, 2023
9bbfb8d
Add translator text to the API
xen-42 Aug 5, 2023
c3feb1e
Shuttle (#667)
MegaPiggy Aug 5, 2023
29fe5a9
Fix typo, include inactive sectors
xen-42 Aug 5, 2023
5a1c2fe
Update manifest.json
xen-42 Aug 5, 2023
1289fec
Delete GravityCannonComputer.xml
xen-42 Aug 5, 2023
5e11e5f
use sphereOfInfluence for ProxyShadowCasterSuperGroup._bounds.radius
JohnCorby Aug 7, 2023
9455c48
use * 2
JohnCorby Aug 7, 2023
01b8ac0
Revert "use * 2"
JohnCorby Aug 7, 2023
789926d
dont use CopyPropertiesFrom for star light stuff
JohnCorby Aug 7, 2023
fb4f425
typo that i didnt catch before i pushed
JohnCorby Aug 7, 2023
b50cc53
force call SunLightEffectsController.Update to make it switch star
JohnCorby Aug 8, 2023
686e239
Fix cloak not being disabled probably
xen-42 Aug 8, 2023
7846ae1
add ProxyShadowCaster to groundsize
JohnCorby Aug 8, 2023
3f3c75d
Merge remote-tracking branch 'origin/fix-proxy-shadows' into fix-prox…
JohnCorby Aug 8, 2023
fea1528
Fix Shadows (#686)
JohnCorby Aug 8, 2023
f765e07
Add another translation dictionary that keeps CDATA
xen-42 Aug 8, 2023
9fe8e31
Updated Schemas
Bwc9876 Aug 8, 2023
894274c
Needed null check for replacing parent sector
xen-42 Aug 8, 2023
69c8bdb
Merge branch 'dev' of https://github.com/Outer-Wilds-New-Horizons/new…
xen-42 Aug 8, 2023
96339c8
Comment
xen-42 Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NewHorizons/Assets/translations/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"DEBUG_REDO": "Redo",
"Vessel": "Vessel"
},
"OtherDictionary": {
"NOMAI_SHUTTLE_COMPUTER": "The <![CDATA[<color=orange>shuttle</color>]]> is currently resting at <![CDATA[<color=lightblue>{0}</color>]]>."
},
"AchievementTranslations": {
"NH_EATEN_OUTSIDE_BRAMBLE": {
"Name": "Containment Breach",
Expand Down
5 changes: 5 additions & 0 deletions NewHorizons/Builder/Body/GeometryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public static GameObject Make(GameObject planetGO, Sector sector, float groundSc
{
groundGO.transform.localScale *= 2; // Multiply by 2 to match top layer
}

var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
// idk if we need to set _superGroup manually since it does that in Awake, but it's done everywhere else so wtv
if (superGroup != null) groundGO.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;

groundGO.SetActive(true);

return groundGO;
Expand Down
7 changes: 2 additions & 5 deletions NewHorizons/Builder/Body/StarBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,11 @@ public static (GameObject, StarController, StarEvolutionController, Light) Make(
light.color = lightColour;
ambientLight.color = new Color(lightColour.r, lightColour.g, lightColour.b, lightColour.a == 0 ? 0.0001f : lightColour.a);

// used to use CopyPropertiesFrom, but that doesnt work here. instead, just copy settings from unity explorer
var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>();
faceActiveCamera.CopyPropertiesFrom(_sunLight.GetComponent<FaceActiveCamera>());
faceActiveCamera._useLookAt = true;
var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>();
csmTextureCacher.CopyPropertiesFrom(_sunLight.GetComponent<CSMTextureCacher>());
csmTextureCacher._light = light;
var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>();
proxyShadowLight.CopyPropertiesFrom(_sunLight.GetComponent<ProxyShadowLight>());
proxyShadowLight._light = light;

sunLight.name = "StarLight";

Expand Down
5 changes: 2 additions & 3 deletions NewHorizons/Builder/General/RigidBodyBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine;
namespace NewHorizons.Builder.General
{
public static class RigidBodyBuilder
{
public static OWRigidbody Make(GameObject body, PlanetConfig config)
public static OWRigidbody Make(GameObject body, float sphereOfInfluence)
{
body.AddComponent<ProxyShadowCasterSuperGroup>();
body.AddComponent<ProxyShadowCasterSuperGroup>()._bounds.radius = sphereOfInfluence;

Rigidbody rigidBody = body.AddComponent<Rigidbody>();
rigidBody.mass = 10000;
Expand Down
22 changes: 14 additions & 8 deletions NewHorizons/Builder/Props/DetailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D
// Could check this in the for loop but I'm not sure what order we need to know about this in
isItem = false;

var existingSectors = new HashSet<Sector>(prop.GetComponentsInChildren<Sector>(true));

foreach (var component in prop.GetComponentsInChildren<Component>(true))
{
// Components can come through as null here (yes, really),
Expand All @@ -127,7 +129,10 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D
{
if (FixUnsectoredComponent(component)) continue;
}
else FixSectoredComponent(component, sector, detail.keepLoaded);
else
{
FixSectoredComponent(component, sector, existingSectors, detail.keepLoaded);
}

FixComponent(component, go, detail.ignoreSun);
}
Expand Down Expand Up @@ -235,7 +240,7 @@ public static GameObject Make(GameObject go, Sector sector, GameObject prefab, D
/// <summary>
/// Fix components that have sectors. Has a specific fix if there is a VisionTorchItem on the object.
/// </summary>
private static void FixSectoredComponent(Component component, Sector sector, bool keepLoaded)
private static void FixSectoredComponent(Component component, Sector sector, HashSet<Sector> existingSectors, bool keepLoaded)
{
// keepLoaded should remove existing groups
// renderers/colliders get enabled later so we dont have to do that here
Expand All @@ -246,14 +251,15 @@ private static void FixSectoredComponent(Component component, Sector sector, boo
}

// fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately)
if (component is ISectorGroup sectorGroup)
if (component is ISectorGroup sectorGroup && !existingSectors.Contains(sectorGroup.GetSector()))
{
sectorGroup.SetSector(sector);
}

// Not doing else if here because idk if any of the classes below implement ISectorGroup

if (component is Sector s)

// Null check else shuttles controls break
if (component is Sector s && s.GetParentSector() != null && !existingSectors.Contains(s.GetParentSector()))
{
s.SetParentSector(sector);
}
Expand All @@ -269,14 +275,14 @@ private static void FixSectoredComponent(Component component, Sector sector, boo
sectorCullGroup.SetVisible(sectorCullGroup.ShouldBeVisible(), true, false);
}

else if(component is SectoredMonoBehaviour behaviour)
else if(component is SectoredMonoBehaviour behaviour && !existingSectors.Contains(behaviour._sector))
{
// not using SetSector here because it registers the events twice
// perhaps this happens with ISectorGroup.SetSector or Sector.SetParentSector too? idk and nothing seems to break because of it yet
behaviour._sector = sector;
}

else if(component is OWItemSocket socket)
else if(component is OWItemSocket socket && !existingSectors.Contains(socket._sector))
{
socket._sector = sector;
}
Expand All @@ -287,7 +293,7 @@ private static void FixSectoredComponent(Component component, Sector sector, boo

}

else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform)
else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform && !existingSectors.Contains(remoteCameraPlatform._visualSector))
{
remoteCameraPlatform._visualSector = sector;
}
Expand Down
188 changes: 188 additions & 0 deletions NewHorizons/Builder/Props/GravityCannonBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
using NewHorizons.Builder.Props.TranslatorText;
using NewHorizons.Components.Orbital;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.Shuttle;
using NewHorizons.External.Modules.TranslatorText;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using Newtonsoft.Json;
using OWML.Common;
using UnityEngine;

namespace NewHorizons.Builder.Props
{
public static class GravityCannonBuilder
{
private static GameObject _interfacePrefab;
private static GameObject _detailedPlatformPrefab, _platformPrefab;
private static GameObject _orbPrefab;

internal static void InitPrefab()
{
if (_interfacePrefab == null)
{
_interfacePrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_GravityCannonInterface")
.InstantiateInactive()
.Rename("Prefab_GravityCannon")
.DontDestroyOnLoad();
}

if (_detailedPlatformPrefab == null)
{
// Creating it in the original position so we can instantiate the other parts in the right relative positions
var original = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Geometry_GravityCannon/ControlledByProxy_OPC/Structure_NOM_GravityCannon_BH");
_detailedPlatformPrefab = original
.InstantiateInactive()
.Rename("Prefab_GravityCannonPlatform_Detailed")
.DontDestroyOnLoad();
_detailedPlatformPrefab.transform.position = original.transform.position;
_detailedPlatformPrefab.transform.rotation = original.transform.rotation;

GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/Prefab_NOM_ShuttleSocket"), _detailedPlatformPrefab.transform, true)
.Rename("ShuttleSocket");
GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Interactables_GravityCannon/CannonForceVolume"), _detailedPlatformPrefab.transform, true)
.Rename("ForceVolume");
GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_GravityCannon/Volumes_GravityCannon/CannonPlatformTrigger"), _detailedPlatformPrefab.transform, true)
.Rename("PlatformTrigger");
}

if (_platformPrefab == null)
{
_platformPrefab = _detailedPlatformPrefab
.InstantiateInactive()
.Rename("Prefab_GravityCannonPlatform")
.DontDestroyOnLoad();
GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Collider"));
GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Crystals"));
GameObject.DestroyImmediate(_platformPrefab.FindChild("Structure_NOM_GravityCannon_Geo"));
}

if (_orbPrefab == null)
{
_orbPrefab = SearchUtilities.Find("Prefab_NOM_InterfaceOrb")
.InstantiateInactive()
.Rename("Prefab_NOM_InterfaceOrb")
.DontDestroyOnLoad();
}
}

public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonInfo info, IModBehaviour mod)
{
InitPrefab();

if (_interfacePrefab == null || planetGO == null || sector == null || _detailedPlatformPrefab == null || _platformPrefab == null || _orbPrefab == null) return null;

var detailInfo = new DetailInfo(info.controls) { keepLoaded = true };
var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _interfacePrefab, detailInfo);
gravityCannonObject.SetActive(false);

var gravityCannonController = gravityCannonObject.GetComponent<GravityCannonController>();
var id = ShuttleHandler.GetShuttleID(info.shuttleID);
gravityCannonController._shuttleID = id;

// Gravity controller checks string length instead of isnullorempty
gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty;
gravityCannonController._launchShipLogFact = info.launchReveal ?? string.Empty;

CreatePlatform(planetGO, sector, gravityCannonController, info);

if (info.computer != null)
{
// Do it next update so that the shuttle has been made
Delay.FireOnNextUpdate(() =>
{
gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer, id);
});
}
else
{
gravityCannonController._nomaiComputer = null;
}

CreateOrb(planetGO, gravityCannonController);

gravityCannonObject.SetActive(true);

return gravityCannonObject;
}

private static void CreateOrb(GameObject planetGO, GravityCannonController gravityCannonController)
{
var orb = _orbPrefab.InstantiateInactive().Rename(_orbPrefab.name);
orb.transform.parent = gravityCannonController.transform;
orb.transform.localPosition = new Vector3(0f, 0.9673f, 0f);
orb.transform.localScale = Vector3.one;
orb.SetActive(true);

var planetBody = planetGO.GetComponent<OWRigidbody>();
var orbBody = orb.GetComponent<OWRigidbody>();

var nomaiInterfaceOrb = orb.GetComponent<NomaiInterfaceOrb>();
nomaiInterfaceOrb._orbBody = orbBody;
nomaiInterfaceOrb._slotRoot = gravityCannonController.gameObject;
orbBody._origParent = planetGO.transform;
orbBody._origParentBody = planetBody;
nomaiInterfaceOrb._slots = nomaiInterfaceOrb._slotRoot.GetComponentsInChildren<NomaiInterfaceSlot>();
nomaiInterfaceOrb.SetParentBody(planetBody);
nomaiInterfaceOrb._safetyRails = new OWRail[0];
nomaiInterfaceOrb.RemoveAllLocks();

var spawnVelocity = planetBody.GetVelocity();
var spawnAngularVelocity = planetBody.GetPointTangentialVelocity(orbBody.transform.position);
var velocity = spawnVelocity + spawnAngularVelocity;

orbBody._lastVelocity = velocity;
orbBody._currentVelocity = velocity;

orb.GetComponent<ConstantForceDetector>()._detectableFields = new ForceVolume[] { planetGO.GetComponentInChildren<GravityVolume>() };

Delay.RunWhenAndInNUpdates(() =>
{
foreach (var component in orb.GetComponents<MonoBehaviour>())
{
component.enabled = true;
}
nomaiInterfaceOrb.RemoveAllLocks();
}, () => Main.IsSystemReady, 10);
}

private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, GeneralPropInfo computerInfo, NomaiShuttleController.ShuttleID id)
{
// Load the position info from the GeneralPropInfo
var translatorTextInfo = new TranslatorTextInfo();
JsonConvert.PopulateObject(JsonConvert.SerializeObject(computerInfo), translatorTextInfo);
translatorTextInfo.type = NomaiTextType.Computer;

var shuttle = ShuttleBuilder.Shuttles[id];
var planet = AstroObjectLocator.GetPlanetName(shuttle.GetComponentInParent<AstroObject>());

var displayText = TranslationHandler.GetTranslation("NOMAI_SHUTTLE_COMPUTER", TranslationHandler.TextType.OTHER).Replace("{0}", planet);
NHLogger.Log(displayText);
var xmlContent = $"<NomaiObject>\r\n <TextBlock>\r\n <ID>1</ID>\r\n <Text>{displayText}</Text>\r\n </TextBlock>\r\n</NomaiObject>";

var computerObject = TranslatorTextBuilder.Make(planetGO, sector, translatorTextInfo, null, xmlContent);

var computer = computerObject.GetComponentInChildren<NomaiComputer>();

computerObject.SetActive(true);

return computer;
}

private static GameObject CreatePlatform(GameObject planetGO, Sector sector, GravityCannonController gravityCannonController, GravityCannonInfo platformInfo)
{
var platform = DetailBuilder.Make(planetGO, sector, platformInfo.detailed ? _detailedPlatformPrefab : _platformPrefab, new DetailInfo(platformInfo) { keepLoaded = true });

gravityCannonController._forceVolume = platform.FindChild("ForceVolume").GetComponent<DirectionalForceVolume>();
gravityCannonController._platformTrigger = platform.FindChild("PlatformTrigger").GetComponent<OWTriggerVolume>();
gravityCannonController._shuttleSocket = platform.FindChild("ShuttleSocket").transform;
gravityCannonController._warpEffect = gravityCannonController._shuttleSocket.GetComponentInChildren<SingularityWarpEffect>();
gravityCannonController._recallProxyGeometry = gravityCannonController._shuttleSocket.gameObject.FindChild("ShuttleRecallProxy");

return platform;
}
}
}
6 changes: 6 additions & 0 deletions NewHorizons/Builder/Props/NomaiTextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,12 @@ internal static GameObject MakeArc(NomaiTextArcInfo arcInfo, GameObject conversa
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xmlPath);
XmlNode rootNode = xmlDocument.SelectSingleNode("NomaiObject");

if (rootNode == null)
{
NHLogger.LogError($"Couldn't find NomaiObject in [{xmlPath}]");
return dict;
}

foreach (object obj in rootNode.SelectNodes("TextBlock"))
{
Expand Down
28 changes: 28 additions & 0 deletions NewHorizons/Builder/Props/PropBuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Ne
PlanetConfig config = nhBody.Config;
IModBehaviour mod = nhBody.Mod;

if (config.Props.gravityCannons != null)
{
foreach (var gravityCannonInfo in config.Props.gravityCannons)
{
try
{
GravityCannonBuilder.Make(go, sector, gravityCannonInfo, mod);
}
catch (Exception ex)
{
NHLogger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}");
}
}
}
if (config.Props.shuttles != null)
{
foreach (var shuttleInfo in config.Props.shuttles)
{
try
{
ShuttleBuilder.Make(go, sector, shuttleInfo);
}
catch (Exception ex)
{
NHLogger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}");
}
}
}
if (config.Props.scatter != null)
{
try
Expand Down
Loading