This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.NodeCanvas
{
}
public class FindCoverPoint : MonoBehaviour
{
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5b5d7c5940f63bc47a90d02b3d44d587
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -11,7 +11,9 @@
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
"GUID:7efac18f239530141802fb139776f333",
"GUID:508392158bd966c4d9c21e19661a441d",
"GUID:f06555f75b070af458a003d92f9efb00"
"GUID:f06555f75b070af458a003d92f9efb00",
"GUID:4307f53044263cf4b835bd812fc161a4",
"GUID:4c25c05f410a3a447a75c3b0909152ef"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -12,7 +12,7 @@ namespace BITKit
public BBParameter<QuestSystem.Info> quest;
protected override void OnExecute()
{
if (quest.value.state is not QuestSystem.State.Complete)
if (quest.value.State is not QuestSystem.State.Complete)
QuestSystem.Complete(quest.value);
EndAction();
}

View File

@@ -19,5 +19,14 @@ namespace BITKit
output.SetValue(quest);
EndAction();
}
protected override void OnStop(bool interrupted)
{
base.OnStop(interrupted);
if (interrupted)
{
if(output.isDefined)
QuestSystem.Cancel(output.value);
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1e3674d9698522f428cb5d0597d8eb80
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using NodeCanvas.Framework;
using UnityEngine;
namespace BITKit.NodeCanvas
{
public sealed class CheckEnvironmentVariable:ActionTask
{
public BBParameter<string> key;
protected override void OnUpdate()
{
if (Data.Get<bool>(key.value))
{
EndAction(true);
}
}
}
public sealed class WaitUntilEnvironmentVariable:ConditionTask
{
public BBParameter<string> key;
protected override bool OnCheck()
{
return Data.Get<bool>(key.value);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cef364b738ebdab4bb01704092e24279
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d98e5bb0c3690684bbe33b7e5c56dd7e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Animancer;
using NodeCanvas.DialogueTrees;
using UnityEngine;
namespace BITKit.NodeCanvas.Director
{
public class ActorRandomAnimation : MonoBehaviour
{
[SerializeField] private AnimancerComponent animancerComponent;
[SerializeField] private AnimationClip[] clips;
private IDialogueActor _actor;
private void OnEnable()
{
_actor = GetComponent<IDialogueActor>();
DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest;
}
private void OnDisable()
{
DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest;
}
private void OnSubtitlesRequest(SubtitlesRequestInfo obj)
{
if(obj.actor != _actor) return;
animancerComponent.Stop();
var state =animancerComponent.Play(clips.Random());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 40c7a825d953b804c862d2e8295de71c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using NodeCanvas.Framework;
using UnityEngine;
namespace BITKit.NodeCanvas.Director
{
public class DirectorNode : ActionTask
{
public BBParameter<string> directorName;
public bool isStart;
protected override void OnExecute()
{
base.OnExecute();
if(isStart)
DirectorService.Register(directorName.value);
else
DirectorService.UnRegister(directorName.value);
EndAction();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8392b577f14613c4181afa893b8d9643
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using NodeCanvas.DialogueTrees;
using UnityEngine;
namespace BITKit.NodeCanvas.Director
{
public class DirectorService : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod]
private static void Reload()
{
allowDirector.Clear();
}
private static readonly ValidHandle allowDirector = new();
public static void Register(string directorName)
{
allowDirector.AddElement(directorName);
}
public static void UnRegister(string directorName)
{
allowDirector.RemoveElement(directorName);
}
[SerializeField] private CinemachineVirtualCamera directorCamera;
private Cinemachine3rdPersonFollow _trd;
private Transform _lastActor;
private Vector3 _defaultShoulderOffset;
private void OnEnable()
{
DialogueTree.OnSubtitlesRequest += OnSubtitlesRequest;
allowDirector.AddListener(OnAllow);
_trd = directorCamera.GetCinemachineComponent<Cinemachine3rdPersonFollow>();
_defaultShoulderOffset = _trd.ShoulderOffset;
}
private void OnDisable()
{
DialogueTree.OnSubtitlesRequest -= OnSubtitlesRequest;
allowDirector.RemoveListener(OnAllow);
}
private void OnSubtitlesRequest(SubtitlesRequestInfo obj)
{
if (obj.actor is not MonoBehaviour monoBehaviour) return;
var transform1 = monoBehaviour.transform;
directorCamera.LookAt = transform1;
directorCamera.Follow = _lastActor ? _lastActor : transform1;
var newOffset = _defaultShoulderOffset;
newOffset.z = _lastActor ? _defaultShoulderOffset.z : 3;
_trd.ShoulderOffset = newOffset;
_lastActor = transform1;
}
private void OnAllow(bool allow)
{
if (allow)
{
directorCamera.Priority = 64;
}
else
{
directorCamera.Priority = -1;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ad95d668b0ed8264c892fc2969bc5f38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -7,7 +7,7 @@ using BITKit.SubSystems;
using BITKit.SubSystems.Quest;
namespace BITKit
{
public class InvokeMonoAction : ActionTask
public class InvokeMonoActionTask : ActionTask
{
public BBParameter<MonoAction> action;
protected override void OnExecute()

View File

@@ -50,6 +50,8 @@ namespace BITKit.Node {
var _dir = target.value.position - transform.position;
if(_dir is {x:0,y:0,z:0}) return;
var direction =Quaternion.LookRotation(Vector3.ProjectOnPlane(_dir ,Vector3.up)) ;
transform.rotation = Quaternion.RotateTowards(transform.rotation,direction,Time.deltaTime*agent.angularSpeed);

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 36f50994aef89d64989e1344ca13eaa6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using NodeCanvas.Framework;
using UnityEngine;
namespace BITKit.NodeCanvas
{
public sealed class SetBehaviourEnabled:ActionTask
{
public BBParameter<Object> behaviour;
public BBParameter<bool> enabled;
protected override void OnExecute()
{
switch (behaviour.value)
{
case MonoBehaviour monoBehaviour:
monoBehaviour.enabled = enabled.value;
break;
case Collider collider:
collider.enabled = enabled.value;
break;
case Component component:
component.GetType().GetProperty(nameof(BoxCollider.enabled),
BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase
).SetValue(behaviour.value, enabled.value);
break;
}
EndAction();
}
protected override string info
{
get
{
if(behaviour.isNoneOrNull || enabled.isNoneOrNull)
return "Set Behaviour Enabled";
var enabledStr = enabled.value ? "Enabled" : "Disabled";
return $"Set {behaviour.name} {enabledStr}";
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a5ed4c02c86bf8d4ba4f1eb84b1f4a3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
using UnityEngine.AI;
namespace BITKit.NodeCanvas.Pathfinding
{
[Category("Movement/Pathfinding")]
[Description("Makes the agent wander randomly within the navigation map")]
public class AIWander : ActionTask<NavMeshAgent>
{
[Tooltip("The speed to wander with.")]
public BBParameter<float> speed = 4;
[Tooltip("The distance to keep from each wander point.")]
public BBParameter<float> keepDistance = 0.1f;
[Tooltip("A wander point can't be closer than this distance")]
public BBParameter<float> minWanderDistance = 5;
[Tooltip("A wander point can't be further than this distance")]
public BBParameter<float> maxWanderDistance = 20;
[Tooltip("If enabled, will keep wandering forever. If not, only one wander point will be performed.")]
public bool repeat = true;
[Tooltip("If enabled,will execute a move and exit")]
public bool forget;
private Vector3? lastPosition;
private readonly IntervalUpdate newPositionInterval=new (1);
private int newTargetCount;
protected override void OnExecute() {
agent.speed = speed.value;
if (IsArrived is false)
{
if (lastPosition.HasValue &&
Vector3.Distance(agent.pathEndPosition, lastPosition.Value) <= keepDistance.value)
{
newPositionInterval.Reset();
EndAction();
return;
}
}
DoWander();
}
protected override string info
{
get
{
reportBuilder.Clear();
reportBuilder.AppendLine(nameof(AIWander));
reportBuilder.AppendLine($"NewTargetCount:{newTargetCount}");
reportBuilder.AppendLine($"LastPosition:{lastPosition}");
reportBuilder.AppendLine($"RemainDistance:{agent.remainingDistance}");
return reportBuilder.ToString();
}
}
private readonly StringBuilder reportBuilder = new();
protected override void OnUpdate() {
if ( IsArrived ) {
if ( repeat ) {
DoWander();
} else {
EndAction();
}
lastPosition = null;
}
else
{
if (forget)
{
EndAction();
}
}
}
private bool IsArrived => !agent.pathPending && agent.remainingDistance <= agent.stoppingDistance + keepDistance.value;
void DoWander() {
var min = minWanderDistance.value;
var max = maxWanderDistance.value;
min = Mathf.Clamp(min, 0.01f, max);
max = Mathf.Clamp(max, min, max);
var wanderPos = agent.transform.position;
if (lastPosition.HasValue && newPositionInterval.AllowUpdateWithoutReset is false)
{
wanderPos = lastPosition.Value;
agent.SetDestination(wanderPos);
}
else
{
while ((wanderPos - agent.transform.position).magnitude < min)
{
wanderPos = (Random.insideUnitSphere * max) + agent.transform.position;
}
NavMeshHit hit;
if ( NavMesh.SamplePosition(wanderPos, out hit, agent.height * 2, NavMesh.AllAreas) ) {
agent.SetDestination(hit.position);
lastPosition = hit.position;
newTargetCount++;
newPositionInterval.Reset();
}
}
}
protected override void OnPause() { OnStop(); }
protected override void OnStop()
{
if (agent.gameObject.activeSelf && agent.isOnNavMesh)
{
if (forget is false)
agent.ResetPath();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fe62f37bb6ab5044eba76bdd40363e0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using NodeCanvas.Framework;
using UnityEngine.Playables;
namespace BITKit.NodeCanvas.Timeline
{
public class PlayTimeline : ActionTask<PlayableDirector>
{
public BBParameter<bool> waitUntilFinish;
protected override void OnExecute()
{
base.OnExecute();
if(waitUntilFinish.value)
{
agent.stopped += OnPlayEnd;
}
agent.time = 0;
agent.Play();
}
protected override void OnStop()
{
base.OnStop();
if (waitUntilFinish.value)
{
agent.stopped -= OnPlayEnd;
}
}
private void OnPlayEnd(PlayableDirector obj)
{
EndAction();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6ebe65ed10e28f4698926ce5306025e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: