diff --git a/Assets/Code/Scripting/TabletTriggers.cs b/Assets/Code/Scripting/TabletTriggers.cs index 69b11b4a..26940eb7 100644 --- a/Assets/Code/Scripting/TabletTriggers.cs +++ b/Assets/Code/Scripting/TabletTriggers.cs @@ -15,6 +15,8 @@ static public class TabletTriggers { static public readonly StringHash32 TabletInteracted = "TabletInteracted"; static public readonly StringHash32 TabletIdentified = "TabletIdentified"; + static public readonly StringHash32 TabletCounted = "TabletCounted"; + static public readonly StringHash32 ObjectHighlighted = "TabletHighlighted"; static public readonly StringHash32 ObjectUnhighlighted = "TabletUnhighlighted"; @@ -24,18 +26,18 @@ static private void Initialize() { .Register(GameEvents.ObjectUnhighlighted, OnObjectUnhighlight); } - static private void OnObjectHighlight(TabletHighlightable highlightable) { - using(var table = TempVarTable.Alloc()) { - table.ActorInfo(ScriptUtility.Actor(highlightable)); - ScriptUtility.Trigger(ObjectHighlighted, table); - } + static private void OnObjectHighlight(TabletHighlightable highlightable) { + using(var table = TempVarTable.Alloc()) { + table.ActorInfo(ScriptUtility.Actor(highlightable)); + ScriptUtility.Trigger(ObjectHighlighted, table); + } } - static private void OnObjectUnhighlight(TabletHighlightable highlightable) { - using (var table = TempVarTable.Alloc()) { - table.ActorInfo(ScriptUtility.Actor(highlightable)); - ScriptUtility.Trigger(ObjectUnhighlighted, table); - } + static private void OnObjectUnhighlight(TabletHighlightable highlightable) { + using (var table = TempVarTable.Alloc()) { + table.ActorInfo(ScriptUtility.Actor(highlightable)); + ScriptUtility.Trigger(ObjectUnhighlighted, table); + } } } } \ No newline at end of file diff --git a/Assets/Code/Tablet/Count/TabletCountable.cs b/Assets/Code/Tablet/Count/TabletCountable.cs index e122fd2c..11986274 100644 --- a/Assets/Code/Tablet/Count/TabletCountable.cs +++ b/Assets/Code/Tablet/Count/TabletCountable.cs @@ -1,6 +1,8 @@ -using System; +using BeauRoutine; using BeauUtil; +using FieldDay; using FieldDay.Components; +using FieldDay.Scripting; using UnityEngine; namespace Pennycook.Tablet { @@ -22,5 +24,27 @@ static public bool IsCountable(TabletCountable countable) { } return true; } + + static public bool TryCount(TabletHighlightable highlightable, TabletCountable countable, double currentTime) { + if (IsCountable(countable)) { + /*interactable.CooldownTimestamp = currentTime + interactable.InteractionCooldown; + interactable.OnInteract.Invoke(new TabletInteractionArgs() { + Interactable = interactable + });*/ + + countable.Group.CurrentlyCounted.Add(countable); + + //bool identified = Ref.Replace(ref highlightable.Identified, true); + //if (identified) { + TabletUtility.UpdateHighlightLabels(Find.State(), TabletUtility.GetLabelsForHighlightable(highlightable)); + TabletUtility.PlayHaptics(0.3f, 0.08f); + TabletUtility.PlaySfx("Tablet.Identified"); + //} + + return true; + } + + return false; + } } } \ No newline at end of file diff --git a/Assets/Code/Tablet/Count/TabletCountingGroup.cs b/Assets/Code/Tablet/Count/TabletCountingGroup.cs index f0951232..3ec0be2c 100644 --- a/Assets/Code/Tablet/Count/TabletCountingGroup.cs +++ b/Assets/Code/Tablet/Count/TabletCountingGroup.cs @@ -1,6 +1,15 @@ using System; +using System.Collections; using System.Collections.Generic; +using BeauUtil; +using BeauUtil.Variants; +using FieldDay; +using FieldDay.Components; +using FieldDay.Scenes; using FieldDay.Scripting; +using Leaf.Runtime; +using UnityEngine; +using UnityEngine.Scripting; namespace Pennycook.Tablet { public sealed class TabletCountingGroup : ScriptActorComponent { @@ -13,6 +22,37 @@ public override void OnScriptRegister(ScriptActor actor) { CurrentlyCounted = new HashSet(64); } + + [LeafMember("ActivateCount"), Preserve] + private void ActivateCount(int totalInGroup) + { + State = TabletCountingGroupState.InProgress; + TotalInGroup = totalInGroup; + } + + [LeafMember("CountInProgress"), Preserve] + private bool CountInProgress() + { + return State == (TabletCountingGroupState.InProgress) && (CurrentlyCounted.Count < TotalInGroup); + } + + [LeafMember("IsCountFinished"), Preserve] + private bool CountFinished() + { + if(CurrentlyCounted.Count < TotalInGroup) + { + return false; + } + + State = TabletCountingGroupState.Completed; + + using (var table = TempVarTable.Alloc()) { + table.ActorInfo(Actor); + ScriptUtility.Trigger(TabletTriggers.TabletCounted, table); + } + + return true; + } } public enum TabletCountingGroupState { diff --git a/Assets/Scenes/ExteriorScene.unity b/Assets/Scenes/ExteriorScene.unity index bc29d0a7..ef444aa7 100644 --- a/Assets/Scenes/ExteriorScene.unity +++ b/Assets/Scenes/ExteriorScene.unity @@ -184,6 +184,69 @@ Transform: m_CorrespondingSourceObject: {fileID: 6641921480938123477, guid: f0610d234ddcaf2468023786b349feb7, type: 3} m_PrefabInstance: {fileID: 1061830} m_PrefabAsset: {fileID: 0} +--- !u!1 &2270887 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2270890} + - component: {fileID: 2270889} + - component: {fileID: 2270888} + m_Layer: 0 + m_Name: PenguinCount + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &2270888 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2270887} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b67704b20760f0b40bc14e98ed8a37d3, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2270889 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2270887} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 808d7706b9890e74cb5c1f86dc9f8b53, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Id: + m_Source: PenguinCount + m_HashValue: 1549634694 + m_ClassName: + m_Source: + m_HashValue: 0 +--- !u!4 &2270890 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2270887} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &9552462 stripped Transform: m_CorrespondingSourceObject: {fileID: 2713642945527085514, guid: e65df6d63f66e904da7748a9ecf18aa8, type: 3} @@ -27674,6 +27737,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 1890498671876380642, guid: 6e919503cfc8ac640bf61796ee8be69b, type: 3} insertIndex: -1 addedObject: {fileID: 3090829779633900016} + - targetCorrespondingSourceObject: {fileID: 1890498671876380642, guid: 6e919503cfc8ac640bf61796ee8be69b, type: 3} + insertIndex: -1 + addedObject: {fileID: 3090829779633900017} m_SourcePrefab: {fileID: 100100000, guid: 6e919503cfc8ac640bf61796ee8be69b, type: 3} --- !u!1 &3090829779633900015 stripped GameObject: @@ -27692,6 +27758,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b6ff410ae1af9f4db705e308b9d6fbc, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &3090829779633900017 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3090829779633900015} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c3e0a99e46b1243a25c3f9e38c52ed, type: 3} + m_Name: + m_EditorClassIdentifier: + Group: {fileID: 2270888} --- !u!1 &3149765727875096222 GameObject: m_ObjectHideFlags: 0 @@ -28999,6 +29078,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 853218977606860600, guid: a89c8dfdd21a94344ae5eb6f314a1685, type: 3} insertIndex: -1 addedObject: {fileID: 4415494273475617495} + - targetCorrespondingSourceObject: {fileID: 853218977606860600, guid: a89c8dfdd21a94344ae5eb6f314a1685, type: 3} + insertIndex: -1 + addedObject: {fileID: 4415494273475617496} m_SourcePrefab: {fileID: 100100000, guid: a89c8dfdd21a94344ae5eb6f314a1685, type: 3} --- !u!1 &4415494273475617494 stripped GameObject: @@ -29017,6 +29099,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b6ff410ae1af9f4db705e308b9d6fbc, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &4415494273475617496 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4415494273475617494} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c3e0a99e46b1243a25c3f9e38c52ed, type: 3} + m_Name: + m_EditorClassIdentifier: + Group: {fileID: 2270888} --- !u!4 &4418254002022567666 Transform: m_ObjectHideFlags: 0 @@ -32333,6 +32428,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 5254005776085208528, guid: a6f24c04e572af542ad0e8ff5723fce3, type: 3} insertIndex: -1 addedObject: {fileID: 8002252649650677434} + - targetCorrespondingSourceObject: {fileID: 5254005776085208528, guid: a6f24c04e572af542ad0e8ff5723fce3, type: 3} + insertIndex: -1 + addedObject: {fileID: 8002252649650677435} m_SourcePrefab: {fileID: 100100000, guid: a6f24c04e572af542ad0e8ff5723fce3, type: 3} --- !u!1 &8002252649650677433 stripped GameObject: @@ -32351,6 +32449,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b6ff410ae1af9f4db705e308b9d6fbc, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8002252649650677435 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8002252649650677433} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c3e0a99e46b1243a25c3f9e38c52ed, type: 3} + m_Name: + m_EditorClassIdentifier: + Group: {fileID: 2270888} --- !u!4 &8023032858341792978 stripped Transform: m_CorrespondingSourceObject: {fileID: 673518832018063872, guid: acffdbf524335934ba97cad77c4567f9, type: 3} @@ -32471,6 +32582,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 3312231690625234630, guid: acdc837baafe7fe43b724a46199e72dd, type: 3} insertIndex: -1 addedObject: {fileID: 8067085178127760674} + - targetCorrespondingSourceObject: {fileID: 3312231690625234630, guid: acdc837baafe7fe43b724a46199e72dd, type: 3} + insertIndex: -1 + addedObject: {fileID: 8067085178127760675} m_SourcePrefab: {fileID: 100100000, guid: acdc837baafe7fe43b724a46199e72dd, type: 3} --- !u!1 &8067085178127760673 stripped GameObject: @@ -32489,6 +32603,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b6ff410ae1af9f4db705e308b9d6fbc, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8067085178127760675 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8067085178127760673} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c3e0a99e46b1243a25c3f9e38c52ed, type: 3} + m_Name: + m_EditorClassIdentifier: + Group: {fileID: 2270888} --- !u!23 &8070403123110508181 MeshRenderer: m_ObjectHideFlags: 0 @@ -33695,6 +33822,9 @@ PrefabInstance: - targetCorrespondingSourceObject: {fileID: 176599328931240667, guid: f5dcd8a3a32e6d944aee725f65882c59, type: 3} insertIndex: -1 addedObject: {fileID: 9078056437444807995} + - targetCorrespondingSourceObject: {fileID: 176599328931240667, guid: f5dcd8a3a32e6d944aee725f65882c59, type: 3} + insertIndex: -1 + addedObject: {fileID: 9078056437444807996} m_SourcePrefab: {fileID: 100100000, guid: f5dcd8a3a32e6d944aee725f65882c59, type: 3} --- !u!1 &9078056437444807994 stripped GameObject: @@ -33713,6 +33843,19 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 9b6ff410ae1af9f4db705e308b9d6fbc, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &9078056437444807996 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9078056437444807994} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e3c3e0a99e46b1243a25c3f9e38c52ed, type: 3} + m_Name: + m_EditorClassIdentifier: + Group: {fileID: 2270888} --- !u!1 &9129407470692689910 GameObject: m_ObjectHideFlags: 0 @@ -33912,3 +34055,4 @@ SceneRoots: - {fileID: 130447496} - {fileID: 4437052948603429530} - {fileID: 5960458480535546385} + - {fileID: 2270890}