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

🚧 [WIP] reimplement all nodes in C++ #287

Open
wants to merge 19 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
185 changes: 185 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# Commented out parameters are those with the same value as base LLVM style.
# We can uncomment them if we want to change their value, or enforce the
# chosen value in case the base style changes (last sync: Clang 14.0).
---
### General config, applies to all languages ###
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignArrayOfStructures: None
# AlignConsecutiveMacros: None
# AlignConsecutiveAssignments: None
# AlignConsecutiveBitFields: None
# AlignConsecutiveDeclarations: None
# AlignEscapedNewlines: Right
AlignOperands: DontAlign
AlignTrailingComments: false
# AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortEnumsOnASingleLine: true
# AllowShortBlocksOnASingleLine: Never
# AllowShortCaseLabelsOnASingleLine: false
# AllowShortFunctionsOnASingleLine: All
# AllowShortLambdasOnASingleLine: All
# AllowShortIfStatementsOnASingleLine: Never
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
# AlwaysBreakBeforeMultilineStrings: false
# AlwaysBreakTemplateDeclarations: MultiLine
# AttributeMacros:
# - __capability
# BinPackArguments: true
# BinPackParameters: true
# BraceWrapping:
# AfterCaseLabel: false
# AfterClass: false
# AfterControlStatement: Never
# AfterEnum: false
# AfterFunction: false
# AfterNamespace: false
# AfterObjCDeclaration: false
# AfterStruct: false
# AfterUnion: false
# AfterExternBlock: false
# BeforeCatch: false
# BeforeElse: false
# BeforeLambdaBody: false
# BeforeWhile: false
# IndentBraces: false
# SplitEmptyFunction: true
# SplitEmptyRecord: true
# SplitEmptyNamespace: true
# BreakBeforeBinaryOperators: None
# BreakBeforeConceptDeclarations: true
# BreakBeforeBraces: Attach
# BreakBeforeInheritanceComma: false
# BreakInheritanceList: BeforeColon
# BreakBeforeTernaryOperators: true
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# QualifierAlignment: Leave
# CompactNamespaces: false
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
Cpp11BracedListStyle: false
# DeriveLineEnding: true
# DerivePointerAlignment: false
# DisableFormat: false
# EmptyLineAfterAccessModifier: Never
# EmptyLineBeforeAccessModifier: LogicalBlock
# ExperimentalAutoDetectBinPacking: false
# PackConstructorInitializers: BinPack
ConstructorInitializerAllOnOneLineOrOnePerLine: true
# AllowAllConstructorInitializersOnNextLine: true
# FixNamespaceComments: true
# ForEachMacros:
# - foreach
# - Q_FOREACH
# - BOOST_FOREACH
# IfMacros:
# - KJ_IF_MAYBE
# IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: "^<.*"
Priority: 3
# IncludeIsMainRegex: '(Test)?$'
# IncludeIsMainSourceRegex: ''
# IndentAccessModifiers: false
IndentCaseLabels: true
# IndentCaseBlocks: false
# IndentGotoLabels: true
# IndentPPDirectives: None
# IndentExternBlock: AfterExternBlock
# IndentRequires: false
IndentWidth: 4
# IndentWrappedFunctionNames: false
# InsertTrailingCommas: None
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
# LambdaBodyIndentation: Signature
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
# NamespaceIndentation: None
# PenaltyBreakAssignment: 2
# PenaltyBreakBeforeFirstCallParameter: 19
# PenaltyBreakComment: 300
# PenaltyBreakFirstLessLess: 120
# PenaltyBreakOpenParenthesis: 0
# PenaltyBreakString: 1000
# PenaltyBreakTemplateDeclaration: 10
# PenaltyExcessCharacter: 1000000
# PenaltyReturnTypeOnItsOwnLine: 60
# PenaltyIndentedWhitespace: 0
# PointerAlignment: Right
# PPIndentWidth: -1
# ReferenceAlignment: Pointer
# ReflowComments: true
# RemoveBracesLLVM: false
# SeparateDefinitionBlocks: Leave
# ShortNamespaceLines: 1
# SortIncludes: CaseSensitive
# SortJavaStaticImport: Before
# SortUsingDeclarations: true
# SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
# SpaceAfterTemplateKeyword: true
# SpaceBeforeAssignmentOperators: true
# SpaceBeforeCaseColon: false
# SpaceBeforeCpp11BracedList: false
# SpaceBeforeCtorInitializerColon: true
# SpaceBeforeInheritanceColon: true
# SpaceBeforeParens: ControlStatements
# SpaceBeforeParensOptions:
# AfterControlStatements: true
# AfterForeachMacros: true
# AfterFunctionDefinitionName: false
# AfterFunctionDeclarationName: false
# AfterIfMacros: true
# AfterOverloadedOperator: false
# BeforeNonEmptyParentheses: false
# SpaceAroundPointerQualifiers: Default
# SpaceBeforeRangeBasedForLoopColon: true
# SpaceInEmptyBlock: false
# SpaceInEmptyParentheses: false
# SpacesBeforeTrailingComments: 1
# SpacesInAngles: Never
# SpacesInConditionalStatement: false
# SpacesInContainerLiterals: true
# SpacesInCStyleCastParentheses: false
## Godot TODO: We'll want to use a min of 1, but we need to see how to fix
## our comment capitalization at the same time.
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
# SpaceBeforeSquareBrackets: false
# BitFieldColonSpacing: Both
# StatementAttributeLikeMacros:
# - Q_EMIT
# StatementMacros:
# - Q_UNUSED
# - QT_REQUIRE_VERSION
TabWidth: 4
# UseCRLF: false
UseTab: Always
# WhitespaceSensitiveMacros:
# - STRINGIZE
# - PP_STRINGIZE
# - BOOST_PP_STRINGIZE
# - NS_SWIFT_NAME
# - CF_SWIFT_NAME
---
### C++ specific config ###
Language: Cpp
Standard: c++17
22 changes: 11 additions & 11 deletions .github/workflows/beehave-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ on:
branches:
- "godot-4.x"
paths-ignore:
- '**.jpg'
- '**.png'
- '**.svg'
- '**.md'
- '**plugin.cfg'
- "**.jpg"
- "**.png"
- "**.svg"
- "**.md"
- "**plugin.cfg"
pull_request:
paths-ignore:
- '**.jpg'
- '**.png'
- '**.svg'
- '**.md'
- '**plugin.cfg'
- "**.jpg"
- "**.png"
- "**.svg"
- "**.md"
- "**plugin.cfg"
workflow_dispatch:

concurrency:
Expand All @@ -31,7 +31,7 @@ jobs:
fail-fast: false
max-parallel: 10
matrix:
godot-version: ['4.0.4', '4.1.3', '4.2.1']
godot-version: ["4.2.1"]

name: "🤖 CI on Godot ${{ matrix.godot-version }}"
uses: ./.github/workflows/unit-tests.yml
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ reports/
*.dblite
*.exp
*.lib
*.obj
*.obj

.vs
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ To better understand what branch to choose from for which Godot version, please
|---|---|--|
|`3.x`|`3.x`|`1.x`|
|`4.x`|`4.x`|`2.x`|
|`4.x`|`4.x`|`3.x`|

Refer to [this guide](https://bitbra.in/2023/09/03/godot-addon-compatibility.html) for more details behind this structure.

Expand All @@ -58,12 +59,6 @@ Behavior trees are a modular way to build AI logic for your game. For simple AI,

[Learn how to beehave on the official wiki!](https://bitbra.in/beehave/#/manual/)

## Tutorial (Godot 3.5+)

[bitbrain](https://youtube.com/@bitbraindev) recorded this tutorial to show in more depth how to use this addon:

[![tutorial-thumbnail](https://img.youtube.com/vi/n0gVEA1dyPQ/0.jpg)](https://www.youtube.com/watch?v=n0gVEA1dyPQ)

# 🥰 Credits

- logo designs by [@NathanHoad](https://twitter.com/nathanhoad) & [@StuartDeVille](https://twitter.com/StuartDeVille)
Expand Down
18 changes: 17 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@
import os
import sys

def recursive_glob(rootdir, pattern):
matches = []
for root, dirnames, filenames in os.walk(rootdir):
for filename in filenames:
if filename.endswith(pattern):
matches.append(os.path.join(root, filename))
return matches

env = SConscript("godot-cpp/SConstruct")

# Add those directory manually, so we can skip the godot_cpp directory when including headers in C++ files
source_path = [
os.path.join("godot-cpp", "include","godot_cpp"),
os.path.join("godot-cpp", "gen", "include","godot_cpp")
]
env.Append(CPPPATH=[env.Dir(d) for d in source_path])

# For the reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
Expand All @@ -14,7 +29,8 @@ env = SConscript("godot-cpp/SConstruct")

# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["extension/src/"])
sources = Glob("extension/src/*.cpp")

sources = recursive_glob('extension/src', '.cpp')

if env["platform"] == "macos":
library = env.SharedLibrary(
Expand Down
26 changes: 24 additions & 2 deletions addons/beehave/beehave.gdextension
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[configuration]
entry_symbol = "initialize_beehave_types"
entry_symbol = "beehave_library_init"
compatibility_minimum = 4.2

[libraries]
Expand All @@ -20,4 +20,26 @@ ios.debug = "res://addons/beehave/libs/ios/beehave.ios.template_debug.universal
ios.release = "res://addons/beehave/libs/ios/beehave.ios.template_release.universal.dylib"

[icons]
BeehaveTree = "res://addons/beehave/icons/tree.svg"
BeehaveTree = "res://addons/beehave/icons/tree.svg"
BeehaveTreeNode = "res://addons/beehave/icons/category_bt.svg"
BeehaveBlackboard = "res://addons/beehave/icons/blackboard.svg"
BeehaveComposite = "res://addons/beehave/icons/category_composite.svg"
BeehaveSelector = "res://addons/beehave/icons/selector.svg"
BeehaveSelectorRandom = "res://addons/beehave/icons/selector_random.svg"
BeehaveSelectorReactive = "res://addons/beehave/icons/selector_reactive.svg"
BeehaveSequence = "res://addons/beehave/icons/sequence.svg"
BeehaveSequenceRandom = "res://addons/beehave/icons/sequence_random.svg"
BeehaveSequenceReactive = "res://addons/beehave/icons/sequence_reactive.svg"
BeehaveSequenceStar = "res://addons/beehave/icons/sequence_star.svg"
BeehaveSequenceStar = "res://addons/beehave/icons/sequence_star.svg"
BeehaveDecorator = "res://addons/beehave/icons/category_decorator.svg"
BeehaveCooldown = "res://addons/beehave/icons/cooldown.svg"
BeehaveDelayer = "res://addons/beehave/icons/delayer.svg"
BeehaveFailer = "res://addons/beehave/icons/failer.svg"
BeehaveSucceeder = "res://addons/beehave/icons/succeeder.svg"
BeehaveInverter = "res://addons/beehave/icons/inverter.svg"
BeehaveLimiter = "res://addons/beehave/icons/limiter.svg"
BeehaveTimeLimiter = "res://addons/beehave/icons/limiter.svg"
BeehaveLeaf = "res://addons/beehave/icons/category_leaf.svg"
BeehaveAction = "res://addons/beehave/icons/action.svg"
BeehaveCondition = "res://addons/beehave/icons/condition.svg"
Binary file modified addons/beehave/libs/windows/beehave.windows.editor.x86_64.dll
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion addons/beehave/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ extends EditorPlugin

func _init():
name = "BeehavePlugin"
print("Beehave initialized!")
print("Beehave initialized!")
2 changes: 1 addition & 1 deletion addons/gdUnit4/GdUnitRunner.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"included":{"res://test/":[]},"server_port":31002,"skipped":{},"version":"1.0"}
{"included":{"res://test/nodes/decorators/cooldown_test.gd":[]},"server_port":31002,"skipped":{},"version":"1.0"}
25 changes: 18 additions & 7 deletions addons/gdUnit4/bin/GdUnitBuildTool.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
extends SceneTree

enum {
INIT, PROCESSING, EXIT
INIT,
PROCESSING,
EXIT
}

const RETURN_SUCCESS = 0
Expand All @@ -11,9 +13,19 @@ const RETURN_WARNING = 101

var _console := CmdConsole.new()
var _cmd_options: = CmdOptions.new([
CmdOption.new("-scp, --src_class_path", "-scp <source_path>", "The full class path of the source file.", TYPE_STRING),
CmdOption.new("-scl, --src_class_line", "-scl <line_number>", "The selected line number to generate test case.", TYPE_INT)
])
CmdOption.new(
"-scp, --src_class_path",
"-scp <source_path>",
"The full class path of the source file.",
TYPE_STRING
),
CmdOption.new(
"-scl, --src_class_line",
"-scl <line_number>",
"The selected line number to generate test case.",
TYPE_INT
)
])

var _status := INIT
var _source_file :String = ""
Expand Down Expand Up @@ -49,13 +61,11 @@ func _idle(_delta):
var script := ResourceLoader.load(_source_file) as Script
if script == null:
exit(RETURN_ERROR, "Can't load source file %s!" % _source_file)

var result := GdUnitTestSuiteBuilder.create(script, _source_line)
if result.is_error():
print_json_error(result.error_message())
exit(RETURN_ERROR, result.error_message())
return

_console.prints_color("Added testcase: %s" % result.value(), Color.CORNFLOWER_BLUE)
print_json_result(result.value())
exit(RETURN_SUCCESS)
Expand Down Expand Up @@ -86,7 +96,8 @@ func print_json_error(error :String) -> void:
func show_options() -> void:
_console.prints_color(" Usage:", Color.DARK_SALMON)
_console.prints_color(" build -scp <source_path> -scl <line_number>", Color.DARK_SALMON)
_console.prints_color("-- Options ---------------------------------------------------------------------------------------", Color.DARK_SALMON).new_line()
_console.prints_color("-- Options ---------------------------------------------------------------------------------------",
Color.DARK_SALMON).new_line()
for option in _cmd_options.default_options():
descripe_option(option)

Expand Down
Loading
Loading