mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
443086c4e4
@ -48,6 +48,18 @@
|
||||
"NH_VESSEL_WARP": {
|
||||
"Name": "Lore Accurate",
|
||||
"Description": "Warp to a star system using the Vessel."
|
||||
},
|
||||
"NH_RAFTING": {
|
||||
"Name": "The Raft and the Furious",
|
||||
"Description": "Go rafting."
|
||||
},
|
||||
"NH_SUCKED_INTO_LAVA_BY_TORNADO": {
|
||||
"Name": "Dieclone",
|
||||
"Description": "Get sucked into lava by a tornado."
|
||||
},
|
||||
"NH_TALK_TO_FIVE_CHARACTERS": {
|
||||
"Name": "Society",
|
||||
"Description": "Talk to 5 characters."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ using System.Xml;
|
||||
using UnityEngine;
|
||||
using NewHorizons.Utility;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using NewHorizons.Components;
|
||||
|
||||
namespace NewHorizons.Builder.Props
|
||||
{
|
||||
@ -114,7 +115,7 @@ namespace NewHorizons.Builder.Props
|
||||
interact.enabled = false;
|
||||
}
|
||||
|
||||
var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>();
|
||||
var dialogueTree = conversationZone.AddComponent<NHCharacterDialogueTree>();
|
||||
|
||||
var xml = File.ReadAllText(Path.Combine(mod.Manifest.ModFolderPath, info.xmlFile));
|
||||
var text = new TextAsset(xml)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.Components.Achievement;
|
||||
using NewHorizons.Components.Volumes;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
@ -78,6 +79,16 @@ namespace NewHorizons.Builder.Props
|
||||
sector.OnSectorOccupantsUpdated += lightSensor.OnSectorOccupantsUpdated;
|
||||
}
|
||||
|
||||
var achievementObject = new GameObject("AchievementVolume");
|
||||
achievementObject.transform.SetParent(raftObject.transform, false);
|
||||
|
||||
var shape = achievementObject.AddComponent<SphereShape>();
|
||||
shape.radius = 3;
|
||||
shape.SetCollisionMode(Shape.CollisionMode.Volume);
|
||||
|
||||
achievementObject.AddComponent<OWTriggerVolume>()._shape = shape;
|
||||
achievementObject.AddComponent<OtherMods.AchievementsPlus.NH.RaftingAchievement>();
|
||||
|
||||
raftObject.SetActive(true);
|
||||
|
||||
return raftObject;
|
||||
|
||||
6
NewHorizons/Components/NHCharacterDialogueTree.cs
Normal file
6
NewHorizons/Components/NHCharacterDialogueTree.cs
Normal file
@ -0,0 +1,6 @@
|
||||
namespace NewHorizons.Components
|
||||
{
|
||||
public class NHCharacterDialogueTree : CharacterDialogueTree
|
||||
{
|
||||
}
|
||||
}
|
||||
25
NewHorizons/External/NewHorizonsData.cs
vendored
25
NewHorizons/External/NewHorizonsData.cs
vendored
@ -83,12 +83,14 @@ namespace NewHorizons.External
|
||||
KnownSignals = new List<string>();
|
||||
NewlyRevealedFactIDs = new List<string>();
|
||||
PopupsRead = new List<string>();
|
||||
CharactersTalkedTo = new List<string>();
|
||||
}
|
||||
|
||||
public List<string> KnownFrequencies { get; }
|
||||
public List<string> KnownSignals { get; }
|
||||
public List<string> NewlyRevealedFactIDs { get; }
|
||||
public List<string> PopupsRead { get; }
|
||||
public List<string> CharactersTalkedTo { get; }
|
||||
}
|
||||
|
||||
#region Frequencies
|
||||
@ -172,5 +174,28 @@ namespace NewHorizons.External
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Characters talked to
|
||||
|
||||
public static void OnTalkedToCharacter(string name)
|
||||
{
|
||||
if (name == CharacterDialogueTree.RECORDING_NAME || name == CharacterDialogueTree.SIGN_NAME) return;
|
||||
_activeProfile?.CharactersTalkedTo.SafeAdd(name);
|
||||
Save();
|
||||
}
|
||||
|
||||
public static bool HasTalkedToFiveCharacters()
|
||||
{
|
||||
if (_activeProfile == null) return false;
|
||||
return _activeProfile.CharactersTalkedTo.Count >= 5;
|
||||
}
|
||||
|
||||
public static int GetCharactersTalkedTo()
|
||||
{
|
||||
if (_activeProfile == null) return 0;
|
||||
return _activeProfile.CharactersTalkedTo.Count;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -39,6 +39,9 @@ namespace NewHorizons.OtherMods.AchievementsPlus
|
||||
NH.EatenOutsideBrambleAchievement.Init();
|
||||
NH.NewFrequencyAchievement.Init();
|
||||
NH.ProbeLostAchievement.Init();
|
||||
NH.RaftingAchievement.Init();
|
||||
NH.TalkToFiveCharactersAchievement.Init();
|
||||
NH.SuckedIntoLavaByTornadoAchievement.Init();
|
||||
|
||||
API.RegisterTranslationsFromFiles(Main.Instance, "Assets/translations");
|
||||
|
||||
@ -87,6 +90,27 @@ namespace NewHorizons.OtherMods.AchievementsPlus
|
||||
API.RegisterAchievement(unique_id, secret, mod);
|
||||
}
|
||||
|
||||
public static bool HasAchievement(string unique_id)
|
||||
{
|
||||
if (!Enabled) return false;
|
||||
|
||||
return API.HasAchievement(unique_id);
|
||||
}
|
||||
|
||||
public static void UpdateProgess(string unique_id, int current, int final, bool showPopup)
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
API.UpdateProgress(unique_id, current, final, showPopup);
|
||||
}
|
||||
|
||||
public static int GetProgress(string unique_id)
|
||||
{
|
||||
if (!Enabled) return 0;
|
||||
|
||||
return API.GetProgress(unique_id);
|
||||
}
|
||||
|
||||
public static void OnLearnSignal()
|
||||
{
|
||||
if (!Enabled) return;
|
||||
|
||||
@ -9,5 +9,7 @@ namespace NewHorizons.OtherMods.AchievementsPlus
|
||||
void RegisterTranslationsFromFiles(ModBehaviour mod, string folderPath);
|
||||
void EarnAchievement(string uniqueID);
|
||||
bool HasAchievement(string uniqueID);
|
||||
void UpdateProgress(string uniqueID, int current, int final, bool showPopup);
|
||||
int GetProgress(string uniqueID);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
using NewHorizons.Components.Achievement;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.OtherMods.AchievementsPlus.NH
|
||||
{
|
||||
public class RaftingAchievement : AchievementVolume
|
||||
{
|
||||
public static readonly string UNIQUE_ID = "NH_RAFTING";
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
achievementID = UNIQUE_ID;
|
||||
}
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
AchievementHandler.Register(UNIQUE_ID, false, Main.Instance);
|
||||
}
|
||||
|
||||
public static void Earn()
|
||||
{
|
||||
AchievementHandler.Earn(UNIQUE_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.OtherMods.AchievementsPlus.NH
|
||||
{
|
||||
public static class SuckedIntoLavaByTornadoAchievement
|
||||
{
|
||||
public static readonly string UNIQUE_ID = "NH_SUCKED_INTO_LAVA_BY_TORNADO";
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
AchievementHandler.Register(UNIQUE_ID, false, Main.Instance);
|
||||
GlobalMessenger<DeathType>.AddListener("PlayerDeath", OnPlayerDeath);
|
||||
}
|
||||
|
||||
public static void OnPlayerDeath(DeathType deathType)
|
||||
{
|
||||
if (deathType == DeathType.Lava && Locator.GetPlayerDetector().GetComponent<FluidDetector>()._activeVolumes.Any(fluidVolume => fluidVolume is TornadoFluidVolume or TornadoBaseFluidVolume or HurricaneFluidVolume))
|
||||
{
|
||||
AchievementHandler.Earn(UNIQUE_ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
using NewHorizons.External;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.OtherMods.AchievementsPlus.NH
|
||||
{
|
||||
public static class TalkToFiveCharactersAchievement
|
||||
{
|
||||
public static readonly string UNIQUE_ID = "NH_TALK_TO_FIVE_CHARACTERS";
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
AchievementHandler.Register(UNIQUE_ID, false, Main.Instance);
|
||||
UpdateProgress(false);
|
||||
if (NewHorizonsData.HasTalkedToFiveCharacters()) Earn();
|
||||
}
|
||||
|
||||
public static void OnTalkedToCharacter(string name)
|
||||
{
|
||||
NewHorizonsData.OnTalkedToCharacter(name);
|
||||
if (NewHorizonsData.HasTalkedToFiveCharacters())
|
||||
{
|
||||
UpdateProgress(false);
|
||||
Earn();
|
||||
}
|
||||
else
|
||||
UpdateProgress(true);
|
||||
}
|
||||
|
||||
public static void Earn()
|
||||
{
|
||||
AchievementHandler.Earn(UNIQUE_ID);
|
||||
}
|
||||
|
||||
public static void UpdateProgress(bool showPopup)
|
||||
{
|
||||
AchievementHandler.UpdateProgess(UNIQUE_ID, NewHorizonsData.GetCharactersTalkedTo(), 5, showPopup);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
NewHorizons/Patches/AchievementPatches.cs
Normal file
43
NewHorizons/Patches/AchievementPatches.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Components;
|
||||
using NewHorizons.OtherMods.AchievementsPlus.NH;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class AchievementPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(ProbeDestructionDetector), nameof(ProbeDestructionDetector.FixedUpdate))]
|
||||
public static bool ProbeDestructionDetector_FixedUpdate(ProbeDestructionDetector __instance)
|
||||
{
|
||||
if (__instance._activeVolumes.Count > 0 && __instance._safetyVolumes.Count == 0)
|
||||
{
|
||||
if (LoadManager.GetCurrentScene() == OWScene.EyeOfTheUniverse)
|
||||
{
|
||||
DialogueConditionManager.SharedInstance.SetConditionState("PROBE_ENTERED_EYE", conditionState: true);
|
||||
Debug.Log("PROBE DESTROYED (ENTERED THE EYE)");
|
||||
}
|
||||
else
|
||||
Debug.Log("PROBE DESTROYED");
|
||||
|
||||
ProbeLostAchievement.Earn();
|
||||
Object.Destroy(__instance._probe.gameObject);
|
||||
}
|
||||
__instance.enabled = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CharacterDialogueTree), nameof(CharacterDialogueTree.StartConversation))]
|
||||
public static void CharacterDialogueTree_StartConversation(CharacterDialogueTree __instance)
|
||||
{
|
||||
if (__instance is NHCharacterDialogueTree)
|
||||
{
|
||||
TalkToFiveCharactersAchievement.OnTalkedToCharacter(__instance._characterName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user