Skip to content

Commit

Permalink
.clang formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbrain committed Jan 15, 2024
1 parent 1168f86 commit 769f8aa
Show file tree
Hide file tree
Showing 12 changed files with 362 additions and 230 deletions.
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
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
61 changes: 26 additions & 35 deletions extension/src/beehave_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,54 +33,45 @@

using namespace godot;

void BeehaveContext::_bind_methods()
{
ClassDB::bind_method(D_METHOD("set_tree", "tree"), &BeehaveContext::set_tree);
ClassDB::bind_method(D_METHOD("get_tree"), &BeehaveContext::get_tree);
ClassDB::bind_method(D_METHOD("set_blackboard", "blackboard"), &BeehaveContext::set_blackboard);
ClassDB::bind_method(D_METHOD("get_blackboard"), &BeehaveContext::get_blackboard);
ClassDB::bind_method(D_METHOD("set_actor", "actor"), &BeehaveContext::set_actor);
ClassDB::bind_method(D_METHOD("get_actor"), &BeehaveContext::get_actor);
ClassDB::bind_method(D_METHOD("set_delta", "delta"), &BeehaveContext::set_delta);
ClassDB::bind_method(D_METHOD("get_delta"), &BeehaveContext::get_delta);
void BeehaveContext::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tree", "tree"), &BeehaveContext::set_tree);
ClassDB::bind_method(D_METHOD("get_tree"), &BeehaveContext::get_tree);
ClassDB::bind_method(D_METHOD("set_blackboard", "blackboard"), &BeehaveContext::set_blackboard);
ClassDB::bind_method(D_METHOD("get_blackboard"), &BeehaveContext::get_blackboard);
ClassDB::bind_method(D_METHOD("set_actor", "actor"), &BeehaveContext::set_actor);
ClassDB::bind_method(D_METHOD("get_actor"), &BeehaveContext::get_actor);
ClassDB::bind_method(D_METHOD("set_delta", "delta"), &BeehaveContext::set_delta);
ClassDB::bind_method(D_METHOD("get_delta"), &BeehaveContext::get_delta);
}

BeehaveTree* BeehaveContext::get_tree() const
{
return this->tree;
BeehaveTree *BeehaveContext::get_tree() const {
return this->tree;
}

void BeehaveContext::set_tree(BeehaveTree* tree)
{
this->tree = tree;
void BeehaveContext::set_tree(BeehaveTree *tree) {
this->tree = tree;
}

BeehaveBlackboard* BeehaveContext::get_blackboard() const
{
return this->blackboard;
BeehaveBlackboard *BeehaveContext::get_blackboard() const {
return this->blackboard;
}

void BeehaveContext::set_blackboard(BeehaveBlackboard* blackboard)
{
this->blackboard = blackboard;
void BeehaveContext::set_blackboard(BeehaveBlackboard *blackboard) {
this->blackboard = blackboard;
}

Node* BeehaveContext::get_actor() const
{
return this->actor;
Node *BeehaveContext::get_actor() const {
return this->actor;
}

void BeehaveContext::set_actor(Node* actor)
{
this->actor = actor;
void BeehaveContext::set_actor(Node *actor) {
this->actor = actor;
}

double BeehaveContext::get_delta() const
{
return delta;
double BeehaveContext::get_delta() const {
return delta;
}

void BeehaveContext::set_delta(double delta)
{
this->delta = delta;
}
void BeehaveContext::set_delta(double delta) {
this->delta = delta;
}
49 changes: 25 additions & 24 deletions extension/src/beehave_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,40 @@
#ifndef BEEHAVE_CONTEXT_H
#define BEEHAVE_CONTEXT_H

#include <classes/ref_counted.hpp>
#include <classes/node.hpp>
#include <classes/ref_counted.hpp>

namespace godot {

// Forward declarations to avoid cyclic dependencies.
class BeehaveTree;
class BeehaveBlackboard;
// Forward declarations to avoid cyclic dependencies.
class BeehaveTree;
class BeehaveBlackboard;

class BeehaveContext : public RefCounted {
GDCLASS(BeehaveContext, RefCounted);

BeehaveTree *tree;
BeehaveBlackboard *blackboard;
Node *actor;
double delta;

class BeehaveContext : public RefCounted
{
GDCLASS(BeehaveContext, RefCounted);
protected:
static void _bind_methods();

BeehaveTree* tree;
BeehaveBlackboard* blackboard;
Node* actor;
double delta;
protected:
static void _bind_methods();
public:
BeehaveTree* get_tree() const;
void set_tree(BeehaveTree* tree);
public:
BeehaveTree *get_tree() const;
void set_tree(BeehaveTree *tree);

BeehaveBlackboard* get_blackboard() const;
void set_blackboard(BeehaveBlackboard* blackboard);
BeehaveBlackboard *get_blackboard() const;
void set_blackboard(BeehaveBlackboard *blackboard);

Node* get_actor() const;
void set_actor(Node* actor);
Node *get_actor() const;
void set_actor(Node *actor);

double get_delta() const;
void set_delta(double delta);
};
double get_delta() const;
void set_delta(double delta);
};

}
} //namespace godot

#endif // BEEHAVE_CONTEXT_H
17 changes: 5 additions & 12 deletions extension/src/nodes/beehave_blackboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,15 @@

using namespace godot;

BeehaveBlackboard::BeehaveBlackboard()
{

BeehaveBlackboard::BeehaveBlackboard() {
}

BeehaveBlackboard::~BeehaveBlackboard()
{

BeehaveBlackboard::~BeehaveBlackboard() {
}

void BeehaveBlackboard::test()
{

void BeehaveBlackboard::test() {
}

void BeehaveBlackboard::_bind_methods()
{
ClassDB::bind_method(D_METHOD("test"), &BeehaveBlackboard::test);
void BeehaveBlackboard::_bind_methods() {
ClassDB::bind_method(D_METHOD("test"), &BeehaveBlackboard::test);
}
Loading

0 comments on commit 769f8aa

Please sign in to comment.