Skip to content

Commit 3f35c03

Browse files
authored
feat: add entry gate scene and items (#39)
1 parent e961b81 commit 3f35c03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+17889
-9759
lines changed

Assets/DevTools/CSV/CsvConverter.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ Object context
7979
_lookup.Add("is_LT_present", InteractionContext.IsLTPresent);
8080
_lookup.Add("is_RT_present", InteractionContext.IsRTPresent);
8181
_lookup.Add("call_other", InteractionContext.CallOther);
82-
_lookup.Add("pick_up", InteractionContext.PickUp);
82+
_lookup.Add("enter", InteractionContext.Enter);
83+
_lookup.Add("available_item", InteractionContext.AvailableItem);
84+
_lookup.Add("LT_item", InteractionContext.LTItem);
85+
_lookup.Add("RT_item", InteractionContext.RTItem);
8386

8487
BaseEntry previous = null;
8588
for (var i = 1; i < rows.Count; i++) {
@@ -105,6 +108,9 @@ Object context
105108
case "fact":
106109
type = typeof(FactEntry);
107110
break;
111+
case "item":
112+
type = typeof(ItemEntry);
113+
break;
108114
default:
109115
Debug.LogError(
110116
$"Row {i + 1} ({cells.Key()}): Unknown type {cells.Type()}",
@@ -149,6 +155,7 @@ Object context
149155
try {
150156
switch (cells.Type()) {
151157
case "fact":
158+
case "item":
152159
CreateFactEntry(cells, previous);
153160
break;
154161
case "event":

Assets/DevTools/GoogleSheetLoaderDev.cs

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -163,39 +163,47 @@ private void BlackboardGUI(Rect rect) {
163163
_scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
164164

165165
var context = _players.Manager.DialogueState.Context;
166-
if (context.TryGetBlackboard(
167-
InteractionContext.InteractionScope,
168-
out var blackboard
169-
)) {
170-
foreach (var pair in blackboard) {
171-
var entry = pair.Key.GetEntry();
172-
if ((_onlyFacts && entry is not FactEntry)
173-
|| (_hideEmpty && pair.Value == 0)) {
174-
continue;
175-
}
176-
177-
if (!string.IsNullOrEmpty(_searchText)
178-
&& !entry.Key.Contains(_searchText)) {
179-
continue;
180-
}
181-
182-
var stringValue =
183-
((EntryReference)pair.Value).TryGetEntry(out var reference)
184-
? $"{reference.Key} ({pair.Value})"
185-
: pair.Value.ToString();
186-
187-
GUILayout.BeginHorizontal();
188-
GUILayout.Label(entry.Key);
189-
GUILayout.FlexibleSpace();
190-
GUILayout.Label(stringValue);
191-
GUILayout.EndHorizontal();
192-
}
193-
}
166+
BlackboardEntriesGUI(context, InteractionContext.GlobalScope);
167+
BlackboardEntriesGUI(context, InteractionContext.InteractionScope);
168+
BlackboardEntriesGUI(context, InteractionContext.ContextScope);
194169

195170
GUILayout.EndScrollView();
196171
GUILayout.EndArea();
197172
}
198173

174+
private void BlackboardEntriesGUI(ITypewriterContext context, int scope) {
175+
if (!context.TryGetBlackboard(scope, out var blackboard)) {
176+
return;
177+
}
178+
179+
foreach (var pair in blackboard) {
180+
if (!pair.Key.TryGetEntry(out var entry)) {
181+
continue;
182+
}
183+
184+
if ((_onlyFacts && entry is not FactEntry)
185+
|| (_hideEmpty && pair.Value == 0)) {
186+
continue;
187+
}
188+
189+
if (!string.IsNullOrEmpty(_searchText)
190+
&& !entry.Key.Contains(_searchText)) {
191+
continue;
192+
}
193+
194+
var stringValue =
195+
((EntryReference)pair.Value).TryGetEntry(out var reference)
196+
? $"{reference.Key} ({pair.Value})"
197+
: pair.Value.ToString();
198+
199+
GUILayout.BeginHorizontal();
200+
GUILayout.Label(entry.Key);
201+
GUILayout.FlexibleSpace();
202+
GUILayout.Label(stringValue);
203+
GUILayout.EndHorizontal();
204+
}
205+
}
206+
199207
private IEnumerator Reload() {
200208
using UnityWebRequest www = UnityWebRequest.Get(
201209
$"https://docs.google.com/spreadsheets/d/{UnityWebRequest.EscapeURL(_customDocumentId)}/gviz/tq?tqx=out:csv&sheet={UnityWebRequest.EscapeURL(_customSheetName)}"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using Utils;
4+
5+
namespace Editor.Utils
6+
{
7+
[CustomPropertyDrawer(typeof(ScenePathAttribute))]
8+
public class ScenePathPropertyDrawer : PropertyDrawer
9+
{
10+
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
11+
{
12+
EditorGUI.BeginProperty(position, label, property);
13+
14+
var oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(property.stringValue);
15+
EditorGUI.BeginChangeCheck();
16+
var newScene = EditorGUI.ObjectField(position, label, oldScene, typeof(SceneAsset), false) as SceneAsset;
17+
if (EditorGUI.EndChangeCheck()) {
18+
var newPath = AssetDatabase.GetAssetPath(newScene);
19+
property.stringValue = newPath;
20+
}
21+
22+
EditorGUI.EndProperty();
23+
}
24+
}
25+
}

Assets/Editor/Utils/ScenePathPropertyDrawer.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:c9227456305f003fe67bd76fb3515243cb30f7ec816a52f3ad8b572d148ea90d
3+
size 20636

Assets/Environment/Models/Chair.fbx.meta

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Prefabs/Chair.prefab

Lines changed: 132 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Environment/Prefabs/Chair.prefab.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)