Skip to content

Commit

Permalink
Merge branch 'main' into edf
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Apr 23, 2024
2 parents 504aded + 2854ae7 commit e0c7ff6
Show file tree
Hide file tree
Showing 57 changed files with 6,416 additions and 72 deletions.
27 changes: 27 additions & 0 deletions SCHIZO/Items/Components/SeaMonkeyHeldItemOverrides.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;

namespace SCHIZO.Items.Components;

partial class SeaMonkeyHeldItemOverrides
{
private Vector3 _savedLocalPos;
private Quaternion _savedLocalRot;
public void OnPickedUp()
{
if (!enabled) return;

_savedLocalPos = overrideTransform.localPosition;
_savedLocalRot = overrideTransform.localRotation;

overrideTransform.localPosition = localPosition;
overrideTransform.localEulerAngles = localRotation;
}

public void OnDropped()
{
if (!enabled) return;

overrideTransform.localPosition = _savedLocalPos;
overrideTransform.localRotation = _savedLocalRot;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using HarmonyLib;

namespace SCHIZO.Items.Components;
[HarmonyPatch]
public static class SeaMonkeyHeldItemOverridesPatches
{
[HarmonyPatch(typeof(SeaMonkeyHeldItem), nameof(SeaMonkeyHeldItem.Hold), [typeof(Pickupable), typeof(bool)])]
[HarmonyPostfix]
public static void OnHold(Pickupable pickupable)
{
if (!pickupable) return;
SeaMonkeyHeldItemOverrides overrideComponent = pickupable.GetComponent<SeaMonkeyHeldItemOverrides>();
if (!overrideComponent) return;

overrideComponent.OnPickedUp();
}

[HarmonyPatch(typeof(SeaMonkeyHeldItem), nameof(SeaMonkeyHeldItem.Drop))]
[HarmonyPrefix]
public static void OnDrop(SeaMonkeyHeldItem __instance)
{
if (!__instance.item) return;
SeaMonkeyHeldItemOverrides overrideComponent = __instance.item.GetComponent<SeaMonkeyHeldItemOverrides>();
if (!overrideComponent) return;

overrideComponent.OnDropped();
}
}
15 changes: 14 additions & 1 deletion SCHIZO/Items/FumoItem/FumoItemLoader.BelowZero.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
using Nautilus.Assets;
using Nautilus.Utility;
using UnityEngine;

namespace SCHIZO.Items.FumoItem;

partial class FumoItemLoader
{
public override void Load(ModItem modItem)
{
base.Load(modItem);
FumoItemPatches.Register(modItem, spawn);
CustomPrefab prefab = new(spawnerClassId, null, null);
prefab.SetGameObject(() =>
{
GameObject instance = GameObject.Instantiate(spawnerPrefab);
PrefabUtils.AddBasicComponents(instance, spawnerClassId, TechType.None, LargeWorldEntity.CellLevel.Global);
instance.SetActive(false); // why do we have to do this manually again
return instance;
});
prefab.Register();
FumoItemPatches.Register(spawnerClassId);
}
}
42 changes: 15 additions & 27 deletions SCHIZO/Items/FumoItem/FumoItemPatches.BelowZero.cs
Original file line number Diff line number Diff line change
@@ -1,64 +1,52 @@
using System.Collections;
using HarmonyLib;
using SCHIZO.Spawns;
using UnityEngine;
using UWE;

namespace SCHIZO.Items.FumoItem;
[HarmonyPatch]
partial class FumoItemPatches
{
private static bool _registered;
private static ModItem fumoItem;
private static SpawnLocation spawnLoc; // local to lifepod
private static string _spawnerClassId;

public static void Register(ModItem modItem, SpawnLocation loc)
public static void Register(string spawnerClassId)
{
if (_registered) LOGGER.LogWarning("Fumo item spawns already registered - overriding previous");
_registered = true;

fumoItem = modItem;
spawnLoc = loc;
if (_spawnerClassId is { })
LOGGER.LogWarning("Fumo item spawns already registered - overriding previous");
_spawnerClassId = spawnerClassId;
}

[HarmonyPatch(typeof(LifepodDrop), nameof(LifepodDrop.OnSettled))]
[HarmonyPostfix]
public static void SpawnFumoInLifepodDrop(LifepodDrop __instance)
{
if (!_registered) return;
if (_spawnerClassId is null) return;

CoroutineHost.StartCoroutine(SpawnFumoCoro(__instance));
}

// code "adapted" from nautilus's EntitySpawner
private static IEnumerator SpawnFumoCoro(LifepodDrop pod)
{
string fumoItemClassId = fumoItem.PrefabInfo.ClassID;

IPrefabRequest request = PrefabDatabase.GetPrefabAsync(fumoItemClassId);
IPrefabRequest request = PrefabDatabase.GetPrefabAsync(_spawnerClassId);
yield return request;
if (!request.TryGetPrefab(out GameObject prefab))
{
LOGGER.LogWarning("Could not get prefab for fumo item, will not spawn in lifepod - unlocking automatically");
KnownTech.Add(fumoItem, false, false);
}

// shouldn't spawn twice anymore w/ new code but shrug
if (Object.FindObjectOfType<FumoItemTool>())
if (!request.TryGetPrefab(out GameObject spawnerPrefab))
{
LOGGER.LogWarning("Attempted to spawn fumo in lifepod twice");
LOGGER.LogError("Could not get prefab for fumo spawner, will not spawn in lifepod");
yield break;
}
yield return new WaitUntil(() => LargeWorldStreamer.main && LargeWorldStreamer.main.IsReady());
LargeWorldStreamer lws = LargeWorldStreamer.main;

Int3 batch = lws.GetContainingBatch(pod.transform.localToWorldMatrix.MultiplyPoint(spawnLoc.position));
Int3 batch = lws.GetContainingBatch(pod.transform.TransformPoint(spawnerPrefab.transform.position));
yield return new WaitUntil(() => lws.IsBatchReadyToCompile(batch));

yield return new WaitUntil(() => LargeWorld.main && LargeWorld.main.streamer.globalRoot != null);

LOGGER.LogMessage("Spawning fumo in lifepod drop");
GameObject obj = UWE.Utils.InstantiateDeactivated(prefab, pod.transform, spawnLoc.position, Quaternion.Euler(spawnLoc.rotation));
obj.SetActive(true);
LOGGER.LogMessage("Spawning fumo spawner in lifepod drop");
GameObject obj = GameObject.Instantiate(spawnerPrefab, pod.transform, false);
LargeWorldEntity lwe = obj.EnsureComponent<LargeWorldEntity>();
lwe.cellLevel = LargeWorldEntity.CellLevel.Global; // do not unload under any circumstances

LargeWorldEntity.Register(obj);
}
Expand Down
72 changes: 72 additions & 0 deletions SCHIZO/Items/FumoItem/SneakyFumoSpawner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System.Collections;
using SCHIZO.Helpers;
using UnityEngine;
using UWE;

namespace SCHIZO.Items.FumoItem;

partial class SneakyFumoSpawner
{
// prevent dupes or whatever
private const string _storyGoal = "SneakyFumo";
private GameObject _prefab;

private IEnumerator Start()
{
if (StoryGoalHelpers.IsCompleted(_storyGoal))
yield return TheFumoAppears();
else
yield return NeuroFumoIs100mFromYourLocationAndRapidlyApproaching();
}

private IEnumerator NeuroFumoIs100mFromYourLocationAndRapidlyApproaching()
{
// Log("starting");
// player enters drop pod for the first time, no fumo is present
while (!StoryGoalHelpers.IsCompleted("OnEnterLifepod"))
yield return new WaitForSecondsRealtime(5);
// Log("entered");

// player leaves for a while
while (!StoryGoalHelpers.IsCompleted("OnExitLifepod"))
yield return new WaitForSecondsRealtime(5);
// Log("exited");

yield return new WaitForSeconds(minAwayTime); // probably completely useless
// Log("waited for time, waiting for distance");
while ((Player.main.transform.position - transform.position).magnitude < minAwayDistance)
yield return new WaitForSecondsRealtime(1);
// Log("spawning");

yield return TheFumoAppears();
}
// private void Log(string msg) => LOGGER.LogDebug($"{name}: {msg}");

private IEnumerator GetPrefab()
{
IPrefabRequest request = PrefabDatabase.GetPrefabAsync(spawnData.classId);
yield return request;
if (!request.TryGetPrefab(out _prefab))
{
LOGGER.LogError("Could not get prefab for fumo item, will not spawn in lifepod");
// if there's no prefab, unlocking it is probably not a good idea
// KnownTech.Add(_fumoItem, false, false);
Destroy(this);
yield break;
}
}

private IEnumerator TheFumoAppears()
{
StoryGoalHelpers.Trigger(_storyGoal);

yield return GetPrefab();
if (!_prefab) yield break;

GameObject fumo = GameObject.Instantiate(_prefab, transform);
fumo.transform.parent = transform.parent; // reparent to drop pod (keeping the spawner's local pos/rot)
LargeWorldEntity.Register(fumo);

Destroy(this);
}
}
8 changes: 7 additions & 1 deletion SCHIZO/Items/PDAJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ partial class PDAJournal
{
protected override void Register()
{
if (!encyData)
{
LOGGER.LogWarning($"{nameof(PDAJournal)} has no encyData, skipping registration");
return;
}
encyData.Register(key);
Subtitles.SubtitlesHandler.RegisterMetadata(subtitles, encyData.description.text);
if (subtitles)
Subtitles.SubtitlesHandler.RegisterMetadata(subtitles, encyData.description.text);
PDAJournalPrefab.Register(this);
}

Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Resources/AssetBundles/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SCHIZO.Resources;

public static class Assets
{
private const int _rnd = 488613676;
private const int _rnd = 1026605148;

private static readonly UnityEngine.AssetBundle _a = ResourceManager.GetAssetBundle("assets");

Expand Down
Binary file modified SCHIZO/Resources/AssetBundles/assets
Binary file not shown.
47 changes: 34 additions & 13 deletions Unity/Assets/Mod/Evil Fumo/Evil Fumo item.prefab
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!65 &4332142020512149085
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3050323588128677620}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.0000005, y: 4.3434496, z: 3.2994847}
m_Center: {x: -0, y: 2.1420708, z: -0.17539322}
--- !u!1 &4427810026626581335
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -177,6 +164,21 @@ MonoBehaviour:
m_EditorClassIdentifier:
propModel: {fileID: 853428788585080163}
viewModel: {fileID: 7656616662938203038}
--- !u!114 &7732719034029743030
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5958827312421353464}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: def191360849e4c4eb0083d03d029b81, type: 3}
m_Name:
m_EditorClassIdentifier:
overrideTransform: {fileID: 4242091266149702868}
localPosition: {x: 0, y: 0, z: 0}
localRotation: {x: -40, y: 0, z: 30}
--- !u!114 &5518736193718426385
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -197,6 +199,19 @@ MonoBehaviour:
_fabricatorMesh: {fileID: 4300000, guid: f02dbf41adbb6c14c8b2eb4704e4fd18, type: 2}
_fabricatorPrefab: {fileID: 4931248133309480, guid: 18b270460e531e34ca5ebc989dccd026,
type: 3}
--- !u!65 &4332142020512149085
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3050323588128677620}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.0000005, y: 4.3434496, z: 3.2994847}
m_Center: {x: -0, y: 2.1420708, z: -0.17539322}
--- !u!1001 &8219148621552729296
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -339,6 +354,12 @@ GameObject:
type: 3}
m_PrefabInstance: {fileID: 8219148621552729296}
m_PrefabAsset: {fileID: 0}
--- !u!4 &4242091266149702868 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 5246314888156504068, guid: 494d51939a4d56f47a65310c2d52e286,
type: 3}
m_PrefabInstance: {fileID: 8219148621552729296}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2059160104811668376 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7963440748852813640, guid: 494d51939a4d56f47a65310c2d52e286,
Expand Down
5 changes: 3 additions & 2 deletions Unity/Assets/Mod/Jukebox/Creep (evil).asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MonoBehaviour:
overrideTrackLabel: 0
trackLabel: Evil Neuro - Creep (cover)
unlockedOnStart: 0
diskPrefab: {fileID: 0}
diskPrefab: {fileID: 6492233284419335816, guid: d22ec62c611ee7545b0126d2a612b118,
type: 3}
diskSpawnLocation:
position: {x: -206.1, y: -274.68, z: -740.5}
rotation: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 90, z: 0}
unlockFmodEvent:
5 changes: 3 additions & 2 deletions Unity/Assets/Mod/Jukebox/Death of the Law (evil).asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MonoBehaviour:
overrideTrackLabel: 0
trackLabel: Evil Neuro - Death of the Law (cover)
unlockedOnStart: 0
diskPrefab: {fileID: 0}
diskPrefab: {fileID: 6492233284419335816, guid: d22ec62c611ee7545b0126d2a612b118,
type: 3}
diskSpawnLocation:
position: {x: -59.4, y: 28.69, z: 545.45}
rotation: {x: 0, y: 0, z: 0}
rotation: {x: 0, y: 180, z: 0}
unlockFmodEvent:
5 changes: 3 additions & 2 deletions Unity/Assets/Mod/Jukebox/Francium.asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MonoBehaviour:
overrideTrackLabel: 0
trackLabel: Neuro-sama - Francium (cover)
unlockedOnStart: 0
diskPrefab: {fileID: 0}
diskPrefab: {fileID: 6492233284419335816, guid: d22ec62c611ee7545b0126d2a612b118,
type: 3}
diskSpawnLocation:
position: {x: -251.636, y: 41.455, z: -790.693}
rotation: {x: 44, y: 0, z: 75}
rotation: {x: -4, y: 20, z: 80}
unlockFmodEvent:
5 changes: 3 additions & 2 deletions Unity/Assets/Mod/Jukebox/Mechanical Heartbeat.asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MonoBehaviour:
overrideTrackLabel: 0
trackLabel: Neuro & Evil - Mechanical Heartbeat (cover)
unlockedOnStart: 0
diskPrefab: {fileID: 0}
diskPrefab: {fileID: 6492233284419335816, guid: d22ec62c611ee7545b0126d2a612b118,
type: 3}
diskSpawnLocation:
position: {x: -1185, y: 18.19, z: -713}
rotation: {x: 342, y: 329, z: 355}
rotation: {x: -15, y: -65, z: 9}
unlockFmodEvent:
5 changes: 3 additions & 2 deletions Unity/Assets/Mod/Jukebox/Neuro Neuro.asset
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ MonoBehaviour:
overrideTrackLabel: 0
trackLabel: Neuro-sama - Miku (cover)
unlockedOnStart: 0
diskPrefab: {fileID: 0}
diskPrefab: {fileID: 6492233284419335816, guid: d22ec62c611ee7545b0126d2a612b118,
type: 3}
diskSpawnLocation:
position: {x: 77.49, y: -377.09, z: -914.05}
rotation: {x: 2, y: 231, z: 332}
rotation: {x: 0, y: 50, z: 20}
unlockFmodEvent:
Loading

0 comments on commit e0c7ff6

Please sign in to comment.