77 lines
1.9 KiB
C#
77 lines
1.9 KiB
C#
|
//============= 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.UI;
|
|||
|
using MyBT;
|
|||
|
using UnityEngine.Video;
|
|||
|
|
|||
|
#if UNITY_EDITOR
|
|||
|
using UnityEditor;
|
|||
|
[CustomEditor(typeof(NamedRigidbody))]
|
|||
|
public class NamedRigidbodyInspector : ComponentHandlerInspector {
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
[System.Serializable]
|
|||
|
public class NamedRigidbody : ComponentHandler {
|
|||
|
public override string TypeLabel () {
|
|||
|
return "Rigidbody";
|
|||
|
}
|
|||
|
|
|||
|
public override string ContentLabel() {
|
|||
|
UpdateComponent();
|
|||
|
return "";
|
|||
|
}
|
|||
|
|
|||
|
public override void UpdateComponent() {
|
|||
|
base.UpdateComponent();
|
|||
|
rigidbodyComponent = GetComponent<Rigidbody>();
|
|||
|
}
|
|||
|
|
|||
|
public Rigidbody rigidbodyComponent;
|
|||
|
public Vector3 startPosition;
|
|||
|
|
|||
|
public override string titleText {
|
|||
|
get {
|
|||
|
return "Run: Set Rigidbody Physically Active";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override string[][] helpText {
|
|||
|
get {
|
|||
|
return new string[][] {
|
|||
|
new string[] {"Run", "Set Physically Active", $"BTC.Run(\"{roomId}\", \"{gameObject.name}\")"}
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Start() {
|
|||
|
startPosition = transform.position;
|
|||
|
}
|
|||
|
|
|||
|
public override void Run(MyBT.NodeState nodeState) {
|
|||
|
// when aborting
|
|||
|
if (nodeState == NodeState.Aborting) {
|
|||
|
rigidbodyComponent.isKinematic = true;
|
|||
|
transform.position = startPosition;
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
// at start
|
|||
|
if (nodeState == NodeState.FirstRun) {
|
|||
|
// reset event trigger
|
|||
|
rigidbodyComponent.isKinematic = false;
|
|||
|
}
|
|||
|
|
|||
|
// during runtime
|
|||
|
if (nodeState == NodeState.Running) {
|
|||
|
}
|
|||
|
}
|
|||
|
}
|