Skip to content

Commit

Permalink
rename a couple of things
Browse files Browse the repository at this point in the history
  • Loading branch information
iamteapot422 committed Aug 18, 2024
1 parent 1a26a10 commit ddd842f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
22 changes: 14 additions & 8 deletions Assets/Scripts/SS3D/Systems/Examine/ExamineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ public class ExamineSystem : NetworkSystem
public event ExaminableChangedHandler OnExaminableChanged;

public delegate void ExaminableChangedHandler(IExaminable examinable);

private SelectionSystem _selectionSystem;




protected override void OnAwake()
{
base.OnAwake();
Expand All @@ -34,20 +32,28 @@ protected override void OnAwake()
protected override void OnEnabled()
{
base.OnEnabled();
if(_selectionSystem) _selectionSystem.OnSelectableChanged += UpdateExaminable;

if (_selectionSystem)
{
_selectionSystem.OnSelectableChanged += UpdateExaminable;
}
}

protected override void OnDisabled()
{
base.OnDisabled();
if (_selectionSystem) _selectionSystem.OnSelectableChanged -= UpdateExaminable;

if (_selectionSystem)
{
_selectionSystem.OnSelectableChanged -= UpdateExaminable;
}
}

private void UpdateExaminable()
{
// Get the examinable under the cursor
IExaminable _current = _selectionSystem.GetCurrentSelectable<IExaminable>();
OnExaminableChanged?.Invoke(_current);
IExaminable current = _selectionSystem.GetCurrentSelectable<IExaminable>();
OnExaminableChanged?.Invoke(current);
}
}
}
10 changes: 5 additions & 5 deletions Assets/Scripts/SS3D/Systems/Examine/ExamineUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected override void OnDisabled()
/// <param name="examinable">The object that is being examined</param>
private void UpdateHoverText(IExaminable examinable)
{
string _hoverTextToDisplay = string.Empty;
string hoverTextToDisplay = string.Empty;

if (examinable?.GetData() != null)
if (examinable?.GetData())
{
ExamineData data = examinable.GetData();

Expand All @@ -43,16 +43,16 @@ private void UpdateHoverText(IExaminable examinable)
_currentStringTable = data.LocalizationTable?.GetTable();
if (_currentStringTable[data.NameKey]?.LocalizedValue is null)
{
_hoverTextToDisplay = data.NameKey + " *[to be localized]*";
hoverTextToDisplay = data.NameKey + " *[to be localized]*";
}
else
{
_hoverTextToDisplay = _currentStringTable[data.NameKey]?.LocalizedValue;
hoverTextToDisplay = _currentStringTable[data.NameKey]?.LocalizedValue;
}
}
}

HoverName.text = _hoverTextToDisplay;
HoverName.text = hoverTextToDisplay;
}
}
}
4 changes: 1 addition & 3 deletions Assets/Scripts/SS3D/Systems/Examine/SimpleExaminable.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using SS3D.Core.Behaviours;
using SS3D.Systems.Selection;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace SS3D.Systems.Examine

namespace SS3D.Systems.Examine
{
[RequireComponent(typeof(Selectable))]
public class SimpleExaminable : Actor, IExaminable
Expand Down

0 comments on commit ddd842f

Please sign in to comment.