Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use customized blob builder instead of one from Unity.Entity #184

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fccfaf1
replace `Unity.Entities.BlobBuilder` by `com.quabug.BLOB`
quabug Apr 2, 2022
5ff3d01
blob variant stream
quabug Apr 4, 2022
8a56a0e
fix variants
quabug Apr 7, 2022
442d6a4
remove deprecated packages
quabug Apr 7, 2022
ce47d66
update behavior component builder
quabug Apr 7, 2022
36861fe
`UnsafeBlobStreamValue`
quabug Apr 8, 2022
bf57eec
rename scope value to global value.
quabug Apr 8, 2022
f1b3f3e
replace blob container
quabug Apr 14, 2022
e045e52
node data builder
quabug Apr 16, 2022
1086142
fix errors
quabug Apr 27, 2022
1ee12c1
fix save to file
quabug Apr 28, 2022
9f150e7
fix error
quabug Apr 28, 2022
494addc
fix test of expression variant
quabug Apr 28, 2022
0bab649
move NodeBlob to Core
quabug Apr 28, 2022
a90ceba
set size of empty nodes to zero explicitly
quabug Apr 28, 2022
5b6871c
remove dependency of Unity.Entities from tests
quabug Apr 28, 2022
8e7b328
use play mode testing for tests of simple composites to avoid crash.
quabug Apr 28, 2022
9fc51de
fix drawer of node variant
quabug Apr 29, 2022
28ef18e
use ManagedNodeBlobRef for GameObject BT.
quabug Apr 29, 2022
961db0e
fix NodeBuilder of each node.
quabug May 4, 2022
94f269e
fix variant test
quabug Jun 21, 2022
843aa42
test cases of single variant
quabug Jun 26, 2022
b37789e
rename directory
quabug Jun 26, 2022
bd5dbef
tests of single variant and multiple variant.
quabug Jul 20, 2022
60b87fe
fix variables.
quabug Jul 31, 2022
2a16d65
fix runtime
quabug Jul 31, 2022
5b64885
refer to blob package.
quabug Jul 31, 2022
4da2202
update package manifest.
quabug Jul 31, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Assets/Samples/Animator/AnimatorSample.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"GUID:d3630359ae08047918d5cd6cddd51767",
"GUID:734d92eba21c94caba915361bd5ac177",
"GUID:4285913d8daed4d6fb1061c793376ad4",
"GUID:6d84eb5386377416e93c122a00485b68"
"GUID:6d84eb5386377416e93c122a00485b68",
"GUID:9835e0fdeb3db2247b6bf67e4f7d0469"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
9 changes: 5 additions & 4 deletions Assets/Samples/Animator/SetAnimatorTrigger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using EntitiesBT.Core;
using Blob;
using EntitiesBT.Core;
using Nuwa.Blob;
using Unity.Entities;
using UnityEngine;
Expand All @@ -20,13 +21,13 @@ public NodeState Tick<TNodeBlob, TBlackboard>(int index, ref TNodeBlob blob, ref
}
}

public class AnimatorTriggerNameBuilder : Builder<int>
public class AnimatorTriggerNameBuilder : Nuwa.Blob.Builder<int>
{
public string TriggerName;

public override void Build(BlobBuilder builder, ref int data)
protected override void BuildImpl(IBlobStream stream, ref int value)
{
data = Animator.StringToHash(TriggerName);
value = Animator.StringToHash(TriggerName);
}
}
}
8 changes: 5 additions & 3 deletions Assets/Samples/GameObjectWithoutEntity/BTController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Blob;
using EntitiesBT.Core;
using EntitiesBT.Components;
using EntitiesBT.Entities;
Expand All @@ -8,12 +9,13 @@ namespace EntitiesBT.Sample
public class BTController : MonoBehaviour
{
public BTNode RootNode;
private NodeBlobRef _nodeBlobRef;
private ManagedNodeBlobRef _nodeBlobRef;
private GameObjectBlackboard _bb;

private void Awake()
{
_nodeBlobRef = new NodeBlobRef(RootNode.ToBlob(RootNode.FindScopeValuesList()));
var blobRef = RootNode.Node.ToBuilder(RootNode.FindGlobalValuesList()).CreateManagedBlobAssetReference();
_nodeBlobRef = new ManagedNodeBlobRef(blobRef, gameObject.GetInstanceID());
Destroy(RootNode.gameObject);
_bb = new GameObjectBlackboard(gameObject);
VirtualMachine.Reset(ref _nodeBlobRef, ref _bb);
Expand All @@ -27,7 +29,7 @@ private void Update()

private void OnDestroy()
{
_nodeBlobRef.BlobRef.Dispose();
_nodeBlobRef.Dispose();
}
}
}
76 changes: 75 additions & 1 deletion Assets/Samples/GameObjectWithoutEntity/GameObjectSample.unity
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,21 @@ MonoBehaviour:
_variantTypeName: EntitiesBT.Variant.IVariantReader`1[[System.Single, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 2
_writer:
_variantTypeName: EntitiesBT.Variant.IVariantWriter`1[[System.Single, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 2
_readerAndWriter:
_variantTypeName: EntitiesBT.Variant.IVariantReaderAndWriter`1[[System.Single,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 3
00000001:
Expand Down Expand Up @@ -514,6 +517,74 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1371246634
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1371246636}
- component: {fileID: 1371246635}
m_Layer: 0
m_Name: RepeatTimesNode
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1371246635
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1371246634}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9aa8e40e4654495e832b55e693d52966, type: 3}
m_Name:
m_EditorClassIdentifier:
NodeData:
NodeType: EntitiesBT.Nodes.RepeatTimesNode, EntitiesBT.Runtime, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
Builder:
BlobDataType: EntitiesBT.Nodes.RepeatTimesNode, EntitiesBT.Runtime, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
FieldNames:
- TickTimes
- BreakStates
Builders:
- id: 0
- id: 1
RunOnMainThread: 0
references:
version: 1
00000000:
type: {class: Int32Builder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
Value: 99
00000001:
type: {class: DynamicIntEnumBuilder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
EnumTypeName: EntitiesBT.Core.NodeState, EntitiesBT.Runtime, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
Value: 0
--- !u!4 &1371246636
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1371246634}
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_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1406639141
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -664,7 +735,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: cd51157a0681449e922dfe58f2e96327, type: 3}
m_Name:
m_EditorClassIdentifier:
RootNode: {fileID: 1406639143}
RootNode: {fileID: 1371246635}
--- !u!23 &2006228428
MeshRenderer:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -796,18 +867,21 @@ MonoBehaviour:
_variantTypeName: EntitiesBT.Variant.IVariantReader`1[[System.Single, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 2
_writer:
_variantTypeName: EntitiesBT.Variant.IVariantWriter`1[[System.Single, mscorlib,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 2
_readerAndWriter:
_variantTypeName: EntitiesBT.Variant.IVariantReaderAndWriter`1[[System.Single,
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],
EntitiesBT.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
IsOptional: 0
_variant:
id: 3
00000001:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"GUID:c7babe7561eb244059259745ef27b866",
"GUID:734d92eba21c94caba915361bd5ac177",
"GUID:f320ee23a990e5640812e0939a441a2b",
"GUID:6d84eb5386377416e93c122a00485b68"
"GUID:6d84eb5386377416e93c122a00485b68",
"GUID:9835e0fdeb3db2247b6bf67e4f7d0469"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
3 changes: 2 additions & 1 deletion Assets/Samples/Runtime/EntitiesBT.Sample.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:abe4851e67df59644865a60dae54a845",
"GUID:f320ee23a990e5640812e0939a441a2b",
"GUID:6d84eb5386377416e93c122a00485b68"
"GUID:6d84eb5386377416e93c122a00485b68",
"GUID:9835e0fdeb3db2247b6bf67e4f7d0469"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
26 changes: 26 additions & 0 deletions Assets/Samples/Runtime/Entity/EntityMoveDynamicVelocity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using EntitiesBT.Core;
using EntitiesBT.Entities;
using EntitiesBT.Variant;
using Unity.Mathematics;
using Unity.Transforms;

namespace EntitiesBT.Sample
{
[Serializable]
[BehaviorNode("CBCA71B5-B674-4EFA-B227-83A53CAB37EF")]
public struct EntityMoveDynamicVelocityNode : INodeData
{
public BlobVariantRW<float3> Velocity;

public NodeState Tick<TNodeBlob, TBlackboard>(int index, ref TNodeBlob blob, ref TBlackboard bb)
where TNodeBlob : struct, INodeBlob
where TBlackboard : struct, IBlackboard
{
ref var translation = ref bb.GetDataRef<Translation>();
var deltaTime = bb.GetData<BehaviorTreeTickDeltaTime>();
translation.Value += Velocity.Read(index, ref blob, ref bb) * deltaTime.Value;
return NodeState.Running;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Assets/Samples/Runtime/Entity/IsEntityPositionInBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Blob;
using EntitiesBT.Core;
using Nuwa.Blob;
using Unity.Entities;
Expand All @@ -23,14 +24,14 @@ public NodeState Tick<TNodeBlob, TBlackboard>(int index, ref TNodeBlob blob, ref
}

[DefaultBuilder]
public class ColliderBoundsBuilder : Builder<Bounds>
public class ColliderBoundsBuilder : Nuwa.Blob.Builder<Bounds>
{
public Transform Transform;
public BoxCollider Box;

public override void Build(BlobBuilder builder, ref Bounds data)
protected override void BuildImpl(IBlobStream stream, ref Bounds value)
{
data = new Bounds(Box.center + Transform.position, Box.size);
value = new Bounds(Box.center + Transform.position, Box.size);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"GUID:4285913d8daed4d6fb1061c793376ad4",
"GUID:abe4851e67df59644865a60dae54a845",
"GUID:f320ee23a990e5640812e0939a441a2b",
"GUID:6d84eb5386377416e93c122a00485b68"
"GUID:6d84eb5386377416e93c122a00485b68",
"GUID:9835e0fdeb3db2247b6bf67e4f7d0469"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
8 changes: 4 additions & 4 deletions Assets/Samples/Runtime/InputSystem/InputActionGuidBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using Blob;
using Nuwa.Blob;
using Unity.Entities;
using UnityEngine.InputSystem;

namespace EntitiesBT.Extensions.InputSystem
{
public class InputActionGuidBuilder : PlainDataBuilder<Guid>
public class InputActionGuidBuilder : Nuwa.Blob.Builder<Guid>
{
public InputActionReference InputAction;

public override void Build(BlobBuilder builder, ref Guid data)
protected override void BuildImpl(IBlobStream stream, ref Guid value)
{
data = InputAction.action.id;
value = InputAction.action.id;
}
}

Expand Down
20 changes: 12 additions & 8 deletions Assets/Samples/Variable/VariableSample.unity
Original file line number Diff line number Diff line change
Expand Up @@ -439,15 +439,19 @@ MonoBehaviour:
_variant:
id: 7
00000001:
type: {class: StringBuilder, ns: Nuwa.Blob, asm: Nuwa.Blob}
type: {class: UnityStringBuilder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
Value: 233213adffda
Value: 3214jklfdajkl
00000002:
type: {class: DynamicArrayBuilder, ns: Nuwa.Blob, asm: Nuwa.Blob}
type: {class: DynamicBlobDataBuilder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
ArrayElementType: System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089
Value:
BlobDataType: Unity.Entities.BlobArray`1[[System.Int32, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]], Unity.Entities, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
FieldNames:
- m_OffsetPtr
- m_Length
Builders:
- id: 8
- id: 9
00000003:
Expand Down Expand Up @@ -505,11 +509,11 @@ MonoBehaviour:
00000008:
type: {class: Int32Builder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
Value: 333
Value: 0
00000009:
type: {class: Int32Builder, ns: Nuwa.Blob, asm: Nuwa.Blob}
data:
Value: 444
Value: 0
0000000A:
type: {class: <IVariantWriter>/Int64ComponentVariant, ns: EntitiesBT.Variant.CodeGen,
asm: Assembly-CSharp}
Expand Down
Loading