Add NamedGrabEvent Handler, modify NamedCollider, add dummy items
This commit is contained in:
		
							parent
							
								
									0a54a65393
								
							
						
					
					
						commit
						bef4508973
					
				@ -4,26 +4,37 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Tree("32_Grotto_Kueche_Intro") {
 | 
					Tree("32_Grotto_Kueche_Intro") {
 | 
				
			||||||
    Composite(Sequence) {
 | 
					    Composite(Sequence) {
 | 
				
			||||||
        BTC.GetKeyDown("Return")
 | 
					        //BTC.GetKeyDown("Return")
 | 
				
			||||||
        BTC.Run("AudioSource.AUDIO.KuecheIntro1F")
 | 
					        BTC.Run("AudioSource.AUDIO.KuecheIntro1F")
 | 
				
			||||||
        // Schuerze greifen - Event Trigger
 | 
					        // Schuerze greifen
 | 
				
			||||||
        BTC.GetKeyDown("Return")
 | 
					        BTC.Run("NamedGrabEvent.INTERACTABLES.Schuerze")
 | 
				
			||||||
 | 
					        //BTC.GetKeyDown("Return")
 | 
				
			||||||
        BTC.Run("AudioSource.AUDIO.KuecheIntro2F")
 | 
					        BTC.Run("AudioSource.AUDIO.KuecheIntro2F")
 | 
				
			||||||
        // Spracheingabe - Button Klick
 | 
					        // Rezept vorlesen: Button Klick, Spracheingabe fehlt noch
 | 
				
			||||||
        BTC.Show("GO.HANDMENU.Option1Button")
 | 
					        BTC.Show("GO.HANDMENU.Option1Button")
 | 
				
			||||||
        BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Rezept vorlesen")
 | 
					        BTC.Set("TextMeshPro.HANDMENU.Option1Button", "text", "Rezept vorlesen")
 | 
				
			||||||
        BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
 | 
					        BTC.Run("NamedEventTrigger.HANDMENU.Option1Button")
 | 
				
			||||||
        //BTC.GetKeyDown("Return")
 | 
					        //BTC.GetKeyDown("Return")
 | 
				
			||||||
        BTC.Run("AudioSource.AUDIO.KuecheIntro3F")
 | 
					        BTC.Run("AudioSource.AUDIO.KuecheIntro3F")
 | 
				
			||||||
        // -- Option 1 -- RACE
 | 
					        // Pilze leuchten
 | 
				
			||||||
        // Pilze leuchten - Pilze ins Glas legen - Event Trigger
 | 
					        // ...
 | 
				
			||||||
        BTC.GetKeyDown("Return")
 | 
					
 | 
				
			||||||
 | 
					        Composite(Race) {
 | 
				
			||||||
 | 
					            Composite(Sequence) {
 | 
				
			||||||
 | 
					                // Pilze ins Wasser Glas legen - Event Trigger
 | 
				
			||||||
 | 
					                BTC.Set("Collider.INTERACTABLES.Wasser", "tag", "Pilz")
 | 
				
			||||||
 | 
					                BTC.Run("Collider.INTERACTABLES.Wasser")
 | 
				
			||||||
                // RunTree("32_Grotto_Kueche_Zwiebeln_schneiden")
 | 
					                // RunTree("32_Grotto_Kueche_Zwiebeln_schneiden")
 | 
				
			||||||
        // -- Option 2
 | 
					            }
 | 
				
			||||||
 | 
					            Composite(Sequence) {
 | 
				
			||||||
 | 
					                // Keine Reaction
 | 
				
			||||||
                // Timer 5 seconds
 | 
					                // Timer 5 seconds
 | 
				
			||||||
 | 
					                // ...
 | 
				
			||||||
                // RunTree("32_Grotto_Kueche_Steinpilze_Hilfe")
 | 
					                // RunTree("32_Grotto_Kueche_Steinpilze_Hilfe")
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Tree("32_Grotto_Kueche_Hide") {
 | 
					Tree("32_Grotto_Kueche_Hide") {
 | 
				
			||||||
    Composite(Sequence) {
 | 
					    Composite(Sequence) {
 | 
				
			||||||
 | 
				
			|||||||
@ -25,15 +25,20 @@ public class NamedCollider : ComponentHandler {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public override string ContentLabel() {
 | 
					    public override string ContentLabel() {
 | 
				
			||||||
        UpdateComponent();
 | 
					        UpdateComponent();
 | 
				
			||||||
        return "";
 | 
					        return objName;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override void UpdateComponent() {
 | 
					    public override void UpdateComponent() {
 | 
				
			||||||
        base.UpdateComponent();
 | 
					        base.UpdateComponent();
 | 
				
			||||||
        colliderComponent = GetComponent<Collider>();
 | 
					        colliderComponent = GetComponent<Collider>();
 | 
				
			||||||
 | 
					        rigidbodyComponent = GetComponent<Rigidbody>();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Collider colliderComponent;
 | 
					    public Collider colliderComponent;
 | 
				
			||||||
 | 
					    public string objName = "ColliderXY";
 | 
				
			||||||
 | 
					    public Rigidbody rigidbodyComponent;
 | 
				
			||||||
 | 
					    private bool _collidedWithObj = false;
 | 
				
			||||||
 | 
					    private string _otherColliderTag = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public override string titleText {
 | 
					    public override string titleText {
 | 
				
			||||||
        get {
 | 
					        get {
 | 
				
			||||||
@ -85,4 +90,84 @@ public class NamedCollider : ComponentHandler {
 | 
				
			|||||||
        if (nodeState == NodeState.Running) {
 | 
					        if (nodeState == NodeState.Running) {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override void Run(NodeState nodeState)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        switch (nodeState)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            case NodeState.FirstRun:
 | 
				
			||||||
 | 
					                _collidedWithObj = false;
 | 
				
			||||||
 | 
					                /* colliderComponent.isTrigger = true;
 | 
				
			||||||
 | 
					                 if (rigidbodyComponent != null)
 | 
				
			||||||
 | 
					                 {
 | 
				
			||||||
 | 
					                     rigidbodyComponent.isKinematic = true;
 | 
				
			||||||
 | 
					                 }*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case NodeState.Running:
 | 
				
			||||||
 | 
					                if (_collidedWithObj)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    _otherColliderTag = "";
 | 
				
			||||||
 | 
					                    Task.SetSucceeded();
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            case NodeState.Aborting:
 | 
				
			||||||
 | 
					                //colliderComponent.isTrigger = false;
 | 
				
			||||||
 | 
					                _collidedWithObj = false;
 | 
				
			||||||
 | 
					                _otherColliderTag = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                /* if (rigidbodyComponent != null)
 | 
				
			||||||
 | 
					                 {
 | 
				
			||||||
 | 
					                     rigidbodyComponent.isKinematic = false;
 | 
				
			||||||
 | 
					                 }*/
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override void Set(NodeState nodeState, string key, string value)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (nodeState == NodeState.FirstRun)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (key == "tag")
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _otherColliderTag = value;
 | 
				
			||||||
 | 
					                Task.SetSucceeded();
 | 
				
			||||||
 | 
					                return;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        Task.SetFailed();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void OnTriggerEnter(Collider other)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (_otherColliderTag != "")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if(other.gameObject.CompareTag(_otherColliderTag))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _collidedWithObj = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _collidedWithObj = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void OnCollisionEnter(Collision collision)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (_otherColliderTag != "")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (collision.gameObject.CompareTag(_otherColliderTag))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _collidedWithObj = true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            _collidedWithObj = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										90
									
								
								Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedGrabEvent.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										90
									
								
								Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedGrabEvent.cs
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,90 @@
 | 
				
			|||||||
 | 
					//============= Copyright (c) Ludic GmbH, All rights reserved. ==============
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					// Purpose: Part of the My Behaviour Tree Controller Code
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					//=============================================================================
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using System.Collections;
 | 
				
			||||||
 | 
					using System.Collections.Generic;
 | 
				
			||||||
 | 
					using UnityEngine;
 | 
				
			||||||
 | 
					using UnityEngine.EventSystems;
 | 
				
			||||||
 | 
					using UnityEngine.UI;
 | 
				
			||||||
 | 
					using MyBT;
 | 
				
			||||||
 | 
					using UnityEngine.XR.Interaction.Toolkit;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if UNITY_EDITOR
 | 
				
			||||||
 | 
					using UnityEditor;
 | 
				
			||||||
 | 
					[CustomEditor(typeof(NamedGrabEvent))]
 | 
				
			||||||
 | 
					public class NamedGrabEventInspector : ComponentHandlerInspector {
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class NamedGrabEvent : ComponentHandler {
 | 
				
			||||||
 | 
					    public override string TypeLabel () {
 | 
				
			||||||
 | 
					        return "NamedGrabEvent";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override string ContentLabel() {
 | 
				
			||||||
 | 
					        UpdateComponent();
 | 
				
			||||||
 | 
					        return objName;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override void UpdateComponent() {
 | 
				
			||||||
 | 
					        base.UpdateComponent();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (GetComponent<XRGrabInteractable>())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            //_xrGrabInteractable = GetComponent<XRGrabInteractable>();
 | 
				
			||||||
 | 
					            GetComponent<XRGrabInteractable>().selectEntered.AddListener(SelectEnterEventHandler);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            Debug.LogWarning($"NamedEventTrigger '{gameObject.name}' could not attach click event (missing button or collider)");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public string objName = "GrabObjXY";
 | 
				
			||||||
 | 
					    //private XRGrabInteractable _xrGrabInteractable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private bool triggered = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void SelectEnterEventHandler(SelectEnterEventArgs args)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        triggered = true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override string titleText {
 | 
				
			||||||
 | 
					        get {
 | 
				
			||||||
 | 
					            return "Run: Will Succeed on Pointer Click";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public override string[][] helpText {
 | 
				
			||||||
 | 
					        get {
 | 
				
			||||||
 | 
					            return new string[][] {
 | 
				
			||||||
 | 
					                new string[] {"Run", "Return Success on Press", $"BTC.Run(\"{roomId}\", \"{gameObject.name}\")"},
 | 
				
			||||||
 | 
					            };
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public override void Run(MyBT.NodeState nodeState) {
 | 
				
			||||||
 | 
					        if (nodeState == NodeState.FirstRun) {
 | 
				
			||||||
 | 
					            // reset event trigger at start
 | 
				
			||||||
 | 
					            triggered = false;
 | 
				
			||||||
 | 
					            //ToggleActive(true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (nodeState == NodeState.Aborting) {
 | 
				
			||||||
 | 
					            triggered = false;
 | 
				
			||||||
 | 
					            //ToggleActive(false);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (triggered) {
 | 
				
			||||||
 | 
					            //ToggleActive(false);
 | 
				
			||||||
 | 
					            Task.SetSucceeded();
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					fileFormatVersion: 2
 | 
				
			||||||
 | 
					guid: 31f211919999446788077b329f6169c7
 | 
				
			||||||
 | 
					MonoImporter:
 | 
				
			||||||
 | 
					  externalObjects: {}
 | 
				
			||||||
 | 
					  serializedVersion: 2
 | 
				
			||||||
 | 
					  defaultReferences: []
 | 
				
			||||||
 | 
					  executionOrder: 0
 | 
				
			||||||
 | 
					  icon: {instanceID: 0}
 | 
				
			||||||
 | 
					  userData: 
 | 
				
			||||||
 | 
					  assetBundleName: 
 | 
				
			||||||
 | 
					  assetBundleVariant: 
 | 
				
			||||||
@ -1 +1 @@
 | 
				
			|||||||
2024-07-17T08:32:50.9227510Z
 | 
					2024-07-17T14:25:00.5967240Z
 | 
				
			||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -3,7 +3,10 @@
 | 
				
			|||||||
--- !u!78 &1
 | 
					--- !u!78 &1
 | 
				
			||||||
TagManager:
 | 
					TagManager:
 | 
				
			||||||
  serializedVersion: 2
 | 
					  serializedVersion: 2
 | 
				
			||||||
  tags: []
 | 
					  tags:
 | 
				
			||||||
 | 
					  - Anchor
 | 
				
			||||||
 | 
					  - Pilz
 | 
				
			||||||
 | 
					  - Zwiebel
 | 
				
			||||||
  layers:
 | 
					  layers:
 | 
				
			||||||
  - Default
 | 
					  - Default
 | 
				
			||||||
  - TransparentFX
 | 
					  - TransparentFX
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user