-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from Alexejhero/sneaky-fumo
fumo spawn thing
- Loading branch information
Showing
12 changed files
with
215 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &1478916698337670458 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 7622607892110866216} | ||
- component: {fileID: 4312043234953409674} | ||
- component: {fileID: 821427263523968193} | ||
- component: {fileID: -5845103137200979273} | ||
m_Layer: 0 | ||
m_Name: Sneaky fumo spawner | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &7622607892110866216 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1478916698337670458} | ||
m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} | ||
m_LocalPosition: {x: 0, y: 1.335, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_Children: [] | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} | ||
--- !u!114 &4312043234953409674 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1478916698337670458} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 9c68da6d9fffcf849a9b674eb8c9dfc9, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
minAwayTime: 60 | ||
minAwayDistance: 100 | ||
spawnData: {fileID: 11400000, guid: b81a466a47b11be4e870eaaa30acf5aa, type: 2} | ||
--- !u!114 &821427263523968193 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1478916698337670458} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 7fb4446287c5460fbe57e2cf1d3c2623, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
--- !u!114 &-5845103137200979273 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1478916698337670458} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: d97a98bece9544178554e9acad0eb069, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
cellLevel: 100 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Unity/Assets/Scripts/SCHIZO/Items/FumoItem/SneakyFumoSpawner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using SCHIZO.Items.Data; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Items.FumoItem | ||
{ | ||
public partial class SneakyFumoSpawner : MonoBehaviour | ||
{ | ||
public float minAwayTime = 60f; | ||
public float minAwayDistance = 100f; | ||
public ItemData spawnData; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Unity/Assets/Scripts/SCHIZO/Items/FumoItem/SneakyFumoSpawner.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.