Skip to content

Commit

Permalink
feat: add entry gate scene and items (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
aarthificial authored Sep 24, 2023
1 parent e961b81 commit 3f35c03
Show file tree
Hide file tree
Showing 62 changed files with 17,889 additions and 9,759 deletions.
9 changes: 8 additions & 1 deletion Assets/DevTools/CSV/CsvConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ Object context
_lookup.Add("is_LT_present", InteractionContext.IsLTPresent);
_lookup.Add("is_RT_present", InteractionContext.IsRTPresent);
_lookup.Add("call_other", InteractionContext.CallOther);
_lookup.Add("pick_up", InteractionContext.PickUp);
_lookup.Add("enter", InteractionContext.Enter);
_lookup.Add("available_item", InteractionContext.AvailableItem);
_lookup.Add("LT_item", InteractionContext.LTItem);
_lookup.Add("RT_item", InteractionContext.RTItem);

BaseEntry previous = null;
for (var i = 1; i < rows.Count; i++) {
Expand All @@ -105,6 +108,9 @@ Object context
case "fact":
type = typeof(FactEntry);
break;
case "item":
type = typeof(ItemEntry);
break;
default:
Debug.LogError(
$"Row {i + 1} ({cells.Key()}): Unknown type {cells.Type()}",
Expand Down Expand Up @@ -149,6 +155,7 @@ Object context
try {
switch (cells.Type()) {
case "fact":
case "item":
CreateFactEntry(cells, previous);
break;
case "event":
Expand Down
64 changes: 36 additions & 28 deletions Assets/DevTools/GoogleSheetLoaderDev.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,39 +163,47 @@ private void BlackboardGUI(Rect rect) {
_scrollPosition = GUILayout.BeginScrollView(_scrollPosition);

var context = _players.Manager.DialogueState.Context;
if (context.TryGetBlackboard(
InteractionContext.InteractionScope,
out var blackboard
)) {
foreach (var pair in blackboard) {
var entry = pair.Key.GetEntry();
if ((_onlyFacts && entry is not FactEntry)
|| (_hideEmpty && pair.Value == 0)) {
continue;
}

if (!string.IsNullOrEmpty(_searchText)
&& !entry.Key.Contains(_searchText)) {
continue;
}

var stringValue =
((EntryReference)pair.Value).TryGetEntry(out var reference)
? $"{reference.Key} ({pair.Value})"
: pair.Value.ToString();

GUILayout.BeginHorizontal();
GUILayout.Label(entry.Key);
GUILayout.FlexibleSpace();
GUILayout.Label(stringValue);
GUILayout.EndHorizontal();
}
}
BlackboardEntriesGUI(context, InteractionContext.GlobalScope);
BlackboardEntriesGUI(context, InteractionContext.InteractionScope);
BlackboardEntriesGUI(context, InteractionContext.ContextScope);

GUILayout.EndScrollView();
GUILayout.EndArea();
}

private void BlackboardEntriesGUI(ITypewriterContext context, int scope) {
if (!context.TryGetBlackboard(scope, out var blackboard)) {
return;
}

foreach (var pair in blackboard) {
if (!pair.Key.TryGetEntry(out var entry)) {
continue;
}

if ((_onlyFacts && entry is not FactEntry)
|| (_hideEmpty && pair.Value == 0)) {
continue;
}

if (!string.IsNullOrEmpty(_searchText)
&& !entry.Key.Contains(_searchText)) {
continue;
}

var stringValue =
((EntryReference)pair.Value).TryGetEntry(out var reference)
? $"{reference.Key} ({pair.Value})"
: pair.Value.ToString();

GUILayout.BeginHorizontal();
GUILayout.Label(entry.Key);
GUILayout.FlexibleSpace();
GUILayout.Label(stringValue);
GUILayout.EndHorizontal();
}
}

private IEnumerator Reload() {
using UnityWebRequest www = UnityWebRequest.Get(
$"https://docs.google.com/spreadsheets/d/{UnityWebRequest.EscapeURL(_customDocumentId)}/gviz/tq?tqx=out:csv&sheet={UnityWebRequest.EscapeURL(_customSheetName)}"
Expand Down
25 changes: 25 additions & 0 deletions Assets/Editor/Utils/ScenePathPropertyDrawer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEditor;
using UnityEngine;
using Utils;

namespace Editor.Utils
{
[CustomPropertyDrawer(typeof(ScenePathAttribute))]
public class ScenePathPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);

var oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(property.stringValue);
EditorGUI.BeginChangeCheck();
var newScene = EditorGUI.ObjectField(position, label, oldScene, typeof(SceneAsset), false) as SceneAsset;
if (EditorGUI.EndChangeCheck()) {
var newPath = AssetDatabase.GetAssetPath(newScene);
property.stringValue = newPath;
}

EditorGUI.EndProperty();
}
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/Utils/ScenePathPropertyDrawer.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Environment/Models/Chair.fbx
Git LFS file not shown
109 changes: 109 additions & 0 deletions Assets/Environment/Models/Chair.fbx.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 132 additions & 0 deletions Assets/Environment/Prefabs/Chair.prefab

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions Assets/Environment/Prefabs/Chair.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3f35c03

Please sign in to comment.