Skip to content

Commit

Permalink
0.4.1 (#69)
Browse files Browse the repository at this point in the history
- Can navigate from the dock to above deck on the Iron Rig
- Added new "remove smoke" setting (for the chimneys on the ship)
- Changed default camera position to be farther back from the ship
- Fixed the new spiral minigame
- Fixed some buttons on the Iron Rig
- Improved the Iron Rig cutscenes

Remaining issues:
- Spyglass is prone to breaking
- Iron rig cutscenes need more work
  • Loading branch information
xen-42 authored Aug 16, 2024
2 parents 034d756 + 7129019 commit 5587e6f
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 81 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# All files
[*]
indent_style = tab

# Xml files
[*.xml]
indent_size = 2

[*.cs]
csharp_style_namespace_declarations=file_scoped:suggestion
csharp_indent_braces=false
csharp_style_var_elsewhere=true
36 changes: 21 additions & 15 deletions DredgeVR/Ability/Spyglass/SpyglassHarvestPOIUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ public class SpyglassHarvestPOIUI : MonoBehaviour

private AbilityData _spyglassAbilityData;
private bool _usingSpyglass;

private float _updateTimer;
public const float UPDATE_TIME = 1f;

private SpyglassUI _spyglassUI;

private void Awake()
{
GameEvents.Instance.OnPlayerAbilityToggled += this.OnPlayerAbilityToggled;
Expand All @@ -46,12 +48,12 @@ private void OnDestroy()

public void Start()
{
var spyglassUI = GameManager.Instance.UI.spyglassUI;
_spyglassAbilityData = spyglassUI.spyglassAbilityData;
_spyglassUI = GameManager.Instance.UI.spyglassUI;
_spyglassAbilityData = _spyglassUI.spyglassAbilityData;

if (_prefab == null)
{
_prefab = GameObject.Instantiate(spyglassUI.container);
_prefab = GameObject.Instantiate(_spyglassUI.container);
_prefab.SetActive(false);
// Needs to be worldspace
var canvas = _prefab.AddComponent<Canvas>();
Expand All @@ -67,12 +69,12 @@ public void Start()
_container.transform.localScale = Vector3.zero;

// Grab all the components
_itemNameString = _container.transform.Find("Backplate/BackplateInner/NameText").GetComponent<LocalizeStringEvent>();
_itemImage = _container.transform.Find("Backplate/BackplateInner/Image").GetComponent<Image>();
_invalidEquipmentImage = _container.transform.Find("Backplate/BackplateInner/InvalidEquipmentImage").GetComponent<Image>();
_hiddenItemSprite = spyglassUI.hiddenItemSprite;
_itemNameString = _container.transform.Find("Backplate/BasicContainer/NameText").GetComponent<LocalizeStringEvent>();
_itemImage = _container.transform.Find("Backplate/BasicContainer/Image").GetComponent<Image>();
_invalidEquipmentImage = _container.transform.Find("Backplate/BasicContainer/InvalidEquipmentImage").GetComponent<Image>();
_hiddenItemSprite = _spyglassUI.hiddenItemSprite;
_harvestableTypeTagUI = _container.transform.Find("Backplate/HarvestableTypeTag").GetComponent<HarvestableTypeTagUI>();
_obscuredString = spyglassUI.obscuredString;
_obscuredString = _spyglassUI.obscuredString;

_updateTimer = Random.Range(0, UPDATE_TIME);
}
Expand All @@ -93,7 +95,7 @@ public void Update()
}

// Lerp scale based on if active
var targetScale = _shouldShowContainer ? Vector3.one * _containerScale : Vector3.zero;
var targetScale = _shouldShowContainer ? 2f * Vector3.one * _containerScale : Vector3.zero;
if (_container.transform.localScale != targetScale)
{
var t = Mathf.Clamp01(Mathf.InverseLerp(_shouldShowContainer ? 0f : _containerScale, targetScale.x, _container.transform.localScale.x) + Time.deltaTime);
Expand All @@ -104,12 +106,20 @@ public void Update()
_container.SetActive(false);
}
}

if (_container.activeInHierarchy)
{
// LookAt makes them backwards though
_container.transform.LookAt(VRCameraManager.VRPlayer.transform.position);
_container.transform.Rotate(Vector3.up, 180f);
}

}

private void CheckPlayerPosition()
{
// Only show objects within a certain range
if ((GameManager.Instance.Player.transform.position - transform.position).magnitude < 60)
if ((GameManager.Instance.Player.transform.position - transform.position).magnitude < (_spyglassUI.hasAdvancedSpyglass ? 90 : 60))
{
_shouldShowContainer = true;

Expand All @@ -130,10 +140,6 @@ private void CheckPlayerPosition()
// TODO: Ideally we'd also check that you're looking towards it
GameManager.Instance.SaveData.SetHasSpiedHarvestCategory(_firstHarvestableItem.harvestableType, true);
GameManager.Instance.AchievementManager.EvaluateAchievement(DredgeAchievementId.ABILITY_SPYGLASS);

// LookAt makes them backwards though
_container.transform.LookAt(VRCameraManager.VRPlayer.transform.position);
_container.transform.Rotate(Vector3.up, 180f);
}
}
else
Expand Down
34 changes: 34 additions & 0 deletions DredgeVR/DockNavigation/ActionDestination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using HarmonyLib;
using System;

namespace DredgeVR.DockNavigation;

[HarmonyPatch]
public class ActionDestination : BaseDestination
{
private Action _action;

public void SetUp(Action action, string name)
{
this._action = action;
this.id = name;

this.alwaysShow = true;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(DestinationButton), nameof(DestinationButton.OnButtonClicked))]
private static bool DestinationButton_OnButtonClicked(DestinationButton __instance)
{
if (__instance.destination is ActionDestination actionDestination)
{
actionDestination._action?.Invoke();
return false;
}
else
{
return true;
}
}
}

196 changes: 196 additions & 0 deletions DredgeVR/DockNavigation/DockNavigationHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
using DredgeVR.Helpers;
using DredgeVR.VRCamera;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

namespace DredgeVR.DockNavigation;

public class DockNavigationHandler : MonoBehaviour
{
private DockUI _dockUI;
private List<GameObject> _customButtons = new();

public enum DockPosition
{
IronRigDock,
IronRigDeck,
Unknown
}

public DockPosition CurrentDockPosition { get; private set; } = DockPosition.Unknown;

public static DockNavigationHandler Instance { get; private set; }

public void Awake()
{
Instance = this;

_dockUI = GameObject.FindObjectOfType<DockUI>();

GameEvents.Instance.OnPlayerDockedToggled += OnPlayerDockedToggled;
GameEvents.Instance.OnDialogueStarted += RefreshUI;
GameEvents.Instance.OnDialogueCompleted += RefreshUI;
ApplicationEvents.Instance.OnUIWindowToggled += OnUIWindowToggled;
OnPlayerDockedToggled(GameManager.Instance.Player.CurrentDock);
}

public void OnDestroy()
{
GameEvents.Instance.OnPlayerDockedToggled -= OnPlayerDockedToggled;
GameEvents.Instance.OnDialogueStarted -= RefreshUI;
GameEvents.Instance.OnDialogueCompleted -= RefreshUI;
ApplicationEvents.Instance.OnUIWindowToggled -= OnUIWindowToggled;
}


private void OnUIWindowToggled(UIWindowType windowType, bool show)
{
if (windowType == UIWindowType.DOCK && show)
{
Delay.FireOnNextUpdate(RefreshUI);
}
}

private void RefreshUI()
{
switch (CurrentDockPosition)
{
case DockPosition.IronRigDock:
ShowIronRigDockUI();
break;
case DockPosition.IronRigDeck:
ShowIronRigDeckUI();
break;
default:
break;
}

if (GameManager.Instance.DialogueRunner.Dialogue?.IsActive ?? false)
{
foreach (var button in _customButtons) button.SetActive(false);
}
}

public void RefreshPosition()
{
switch (CurrentDockPosition)
{
case DockPosition.IronRigDock:
GoToIronRigDock();
break;
case DockPosition.IronRigDeck:
GoToIronRigDeck();
break;
default:
break;
}

RefreshUI();
}

private GameObject _tirElevatorButton, _tirDockButton;

private void OnPlayerDockedToggled(Dock dock)
{
try
{
if (dock == null)
{
// Reset anchor transform
VRCameraManager.Instance.ResetAnchorToBoat();
CurrentDockPosition = DockPosition.Unknown;
foreach (var button in _customButtons)
{
GameObject.Destroy(button);
}
_customButtons.Clear();
}
if (dock.name.Contains("Iron Rig"))
{
_tirElevatorButton = MakeButton("Go up elevator", GoToIronRigDeck, new Vector2(0, 0));
_tirDockButton = MakeButton("Return to dock", GoToIronRigDock, new Vector2(0, 0));

// Standing on the dock
GoToIronRigDock();
}
}
catch (Exception e)
{
DredgeVRLogger.Error($"Something went wrong when docking/undocking - {e}");
}
}

private void GoToIronRigDock()
{
CurrentDockPosition = DockPosition.IronRigDock;
VRCameraManager.MoveCameraTo(new Vector3(-13.5945f, 1.1673f, 690.1805f), Quaternion.identity);
ShowIronRigDockUI();
}

private void ShowIronRigDockUI()
{
// Hide upper deck buttons, only show elevator and fleet services
foreach (Transform button in _dockUI.destinationButtonContainer.transform)
{
if (button.name.Contains("BoatActionsDestinationUI")) continue;
button.gameObject.SetActive(false);
}

var cargoElevatorButton = _dockUI.destinationButtonContainer?.Find("DestinationButton: RigBase");

_tirElevatorButton?.SetActive(cargoElevatorButton == null);
_dockUI.destinationButtonContainer?.Find("DestinationButton: FleetServices")?.gameObject?.SetActive(true);
_dockUI.destinationButtonContainer?.Find("DestinationButton: StorageOnLowerPlatform")?.gameObject?.SetActive(true);
_dockUI.destinationButtonContainer?.Find("DestinationButton: RigBase")?.gameObject?.SetActive(true);
}

private void GoToIronRigDeck()
{
CurrentDockPosition = DockPosition.IronRigDeck;
VRCameraManager.MoveCameraTo(new Vector3(-5.0297f, 15.2771f, 684.2171f), Quaternion.identity);
ShowIronRigDeckUI();
}

private void ShowIronRigDeckUI()
{
// Show upper deck buttons, only hide elevator and fleet services
foreach (Transform button in _dockUI.destinationButtonContainer.transform)
{
button.gameObject.SetActive(true);
}

_tirElevatorButton?.SetActive(false);
_dockUI.destinationButtonContainer?.Find("DestinationButton: FleetServices")?.gameObject?.SetActive(false);
_dockUI.destinationButtonContainer?.Find("DestinationButton: StorageOnLowerPlatform")?.gameObject?.SetActive(false);
_dockUI.destinationButtonContainer?.Find("DestinationButton: RigBase")?.gameObject?.SetActive(false);
}

private GameObject MakeButton(string text, Action action, Vector2 position)
{
try
{
var gameObject = UnityEngine.Object.Instantiate<GameObject>(_dockUI.destinationButtonPrefab, _dockUI.destinationButtonContainer);
Component.Destroy(gameObject.GetComponent<DestinationButton>());
gameObject.name = text;
gameObject.transform.localPosition = new Vector3(position.x, position.y, 0);
gameObject.transform.Find("AttentionCallout").gameObject.SetActive(false);
var button = gameObject.transform.Find("ButtonWithIcon");
button.transform.Find("Icon").gameObject.SetActive(false);
button.GetComponent<BasicButtonWrapper>().OnClick = action;
button.GetComponentInChildren<TextMeshProUGUI>().text = text;

_customButtons.Add(gameObject);
gameObject.SetActive(false);

return gameObject;
}
catch (Exception e)
{
DredgeVRLogger.Error($"Couldn't make button - {e}");
throw;
}
}

}
2 changes: 1 addition & 1 deletion DredgeVR/DredgeVR.csproj.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<DredgePath>C:\Program Files (x86)\Steam\steamapps\common\DREDGE</DredgePath>
<DredgePath>E:\SteamLibrary\steamapps\common\DREDGE</DredgePath>
<OutputPath>$(DredgePath)\Mods\xen.DredgeVR</OutputPath>
</PropertyGroup>
</Project>
8 changes: 7 additions & 1 deletion DredgeVR/Options/OptionsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ public class OptionsConfig
public float playerScale = 1f;

[JsonProperty]
public float[] playerPosition = new float[] { 0, 1.13f, -1.5f };
public float[] playerPosition = new float[] { 0, 1.5f, -1.8f };

/// <summary>
/// Don't render the smoke columns coming from the ship
/// </summary>
[JsonProperty]
public bool removeSmoke = true;

public Vector3 PlayerPosition => new(playerPosition[0], playerPosition[1], playerPosition[2]);
}
4 changes: 2 additions & 2 deletions DredgeVR/TitleScreen/TitleScreenPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static void TitleScreenView_SetAllDLC(TitleScreenView __instance)
{
DredgeVRLogger.Info("All DLC title screen");

var camLookAt = new Vector3(86.9563f, 1.2f, -119.7114f);
var camPos = new Vector3(80.7999f, 1.2f, -115.8387f);
var camLookAt = new Vector3(86.9563f, 2f, -119.7114f);
var camPos = new Vector3(80.7999f, 2f, -115.8387f);

SetUpTitleScreen(camPos, camLookAt);
}
Expand Down
Loading

0 comments on commit 5587e6f

Please sign in to comment.