Compare commits
33 Commits
Author | SHA1 | Date |
---|---|---|
Chris Cromer | 16fb77e0de | |
Chris Cromer | 33d9401445 | |
Chris Cromer | 77d844c911 | |
Chris Cromer | 368ca33006 | |
Chris Cromer | 9068d4fb25 | |
Chris Cromer | acf6ed6f73 | |
Chris Cromer | 4860855cc8 | |
Chris Cromer | 354a3c6946 | |
Chris Cromer | bb56fff04e | |
Chris Cromer | 27403e7e9a | |
Chris Cromer | b84ed69198 | |
Martin Araneda | 937e173fce | |
Martin Araneda | 1a317042c2 | |
Chris Cromer | 3cc4252684 | |
Chris Cromer | 91b55ca6e1 | |
Chris Cromer | 1e60846d3c | |
Chris Cromer | 498d575d29 | |
Chris Cromer | 581d8e71cf | |
Chris Cromer | dd58fac7a7 | |
Chris Cromer | 17fe82323c | |
Chris Cromer | 364b9ac898 | |
Chris Cromer | 298a21d516 | |
Chris Cromer | b76ef9cda5 | |
Chris Cromer | 4482c8af6a | |
Chris Cromer | 3b533fb03d | |
Chris Cromer | 57cc75c249 | |
Chris Cromer | 4298dfb4c0 | |
Chris Cromer | 73b41dcde3 | |
Chris Cromer | dad3e6581a | |
Chris Cromer | b8146bd002 | |
Chris Cromer | aae40bf6e7 | |
Chris Cromer | 7ecaa95045 | |
Chris Cromer | 0a54849e5f |
|
@ -0,0 +1,220 @@
|
||||||
|
---
|
||||||
|
AccessModifierOffset: 0
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: Always
|
||||||
|
IndentAccessModifiers: true
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
UseCRLF: false
|
||||||
|
Language: Cpp
|
||||||
|
IndentWidth: 4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignArrayOfStructures: Left
|
||||||
|
AlignConsecutiveAssignments: AcrossComments
|
||||||
|
AlignConsecutiveBitFields: AcrossComments
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: AcrossComments
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlignOperands: AlignAfterOperator
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: false
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: None
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: No
|
||||||
|
BinPackArguments: false
|
||||||
|
BinPackParameters: false
|
||||||
|
AttributeMacros:
|
||||||
|
- __capability
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: true
|
||||||
|
AfterClass: true
|
||||||
|
AfterControlStatement: Always
|
||||||
|
AfterEnum: true
|
||||||
|
AfterFunction: true
|
||||||
|
AfterNamespace: true
|
||||||
|
AfterObjCDeclaration: true
|
||||||
|
AfterStruct: true
|
||||||
|
AfterUnion: true
|
||||||
|
AfterExternBlock: true
|
||||||
|
BeforeCatch: true
|
||||||
|
BeforeElse: true
|
||||||
|
BeforeLambdaBody: true
|
||||||
|
BeforeWhile: true
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakBeforeBinaryOperators: All
|
||||||
|
BreakBeforeConceptDeclarations: false
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
BreakInheritanceList: AfterColon
|
||||||
|
BreakStringLiterals: false
|
||||||
|
ColumnLimit: 0
|
||||||
|
CommentPragmas: "^ IWYU pragma:"
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||||
|
ConstructorInitializerIndentWidth: 4
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: true
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IfMacros:
|
||||||
|
- KJ_IF_MAYBE
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: ^<ext/.*\.h>
|
||||||
|
Priority: 2
|
||||||
|
CaseSensitive: false
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: ^<.*\.h>
|
||||||
|
Priority: 1
|
||||||
|
CaseSensitive: false
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: ^<.*
|
||||||
|
Priority: 2
|
||||||
|
CaseSensitive: false
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: .*
|
||||||
|
Priority: 0
|
||||||
|
CaseSensitive: false
|
||||||
|
SortPriority: 0
|
||||||
|
IncludeIsMainRegex: ([-_](test|unittest))?$
|
||||||
|
IncludeIsMainSourceRegex: ""
|
||||||
|
IndentCaseBlocks: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: Indent
|
||||||
|
IndentGotoLabels: false
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
IndentRequires: true
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
JavaScriptQuotes: Double
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||||
|
LambdaBodyIndentation: OuterScope
|
||||||
|
MacroBlockBegin: ""
|
||||||
|
MacroBlockEnd: ""
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
ObjCBinPackProtocolList: Never
|
||||||
|
ObjCBlockIndentWidth: 4
|
||||||
|
ObjCBreakBeforeNestedBlockParam: false
|
||||||
|
ObjCSpaceAfterProperty: true
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PPIndentWidth: 4
|
||||||
|
PackConstructorInitializers: Never
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 1
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 200
|
||||||
|
PointerAlignment: Left
|
||||||
|
QualifierAlignment: Left
|
||||||
|
RawStringFormats:
|
||||||
|
- Language: Cpp
|
||||||
|
BasedOnStyle: google
|
||||||
|
Delimiters:
|
||||||
|
- cc
|
||||||
|
- CC
|
||||||
|
- cpp
|
||||||
|
- Cpp
|
||||||
|
- CPP
|
||||||
|
- c++
|
||||||
|
- C++
|
||||||
|
CanonicalDelimiter: ""
|
||||||
|
- Language: TextProto
|
||||||
|
EnclosingFunctions:
|
||||||
|
- EqualsProto
|
||||||
|
- EquivToProto
|
||||||
|
- PARSE_PARTIAL_TEXT_PROTO
|
||||||
|
- PARSE_TEST_PROTO
|
||||||
|
- PARSE_TEXT_PROTO
|
||||||
|
- ParseTextOrDie
|
||||||
|
- ParseTextProtoOrDie
|
||||||
|
- ParseTestProto
|
||||||
|
- ParsePartialTestProto
|
||||||
|
BasedOnStyle: google
|
||||||
|
Delimiters:
|
||||||
|
- pb
|
||||||
|
- PB
|
||||||
|
- proto
|
||||||
|
- PROTO
|
||||||
|
CanonicalDelimiter: pb
|
||||||
|
ReferenceAlignment: Left
|
||||||
|
ReflowComments: false
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
SeparateDefinitionBlocks: Always
|
||||||
|
ShortNamespaceLines: 0
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: true
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: false
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: true
|
||||||
|
SpaceBeforeCpp11BracedList: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: Custom
|
||||||
|
SpaceBeforeParensOptions:
|
||||||
|
AfterControlStatements: true
|
||||||
|
AfterForeachMacros: false
|
||||||
|
AfterFunctionDeclarationName: false
|
||||||
|
AfterFunctionDefinitionName: false
|
||||||
|
AfterIfMacros: false
|
||||||
|
AfterOverloadedOperator: true
|
||||||
|
BeforeNonEmptyParentheses: false
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInLineCommentPrefix:
|
||||||
|
Minimum: 1
|
||||||
|
Maximum: 1
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
StatementAttributeLikeMacros:
|
||||||
|
- Q_EMIT
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- STRINGIZE
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
- NS_SWIFT_NAME
|
||||||
|
- CF_SWIFT_NAME
|
|
@ -0,0 +1,28 @@
|
||||||
|
# See https://pre-commit.com for more information
|
||||||
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: mixed-line-ending
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: check-shebang-scripts-are-executable
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: no-commit-to-branch
|
||||||
|
args: [--branch, master, --branch, develop]
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: v15.0.7
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
types_or: [c++, c]
|
||||||
|
args: ["-style=file"]
|
||||||
|
#- repo: https://github.com/pocc/pre-commit-hooks
|
||||||
|
# rev: v1.3.5
|
||||||
|
# hooks:
|
||||||
|
# - id: clang-tidy
|
||||||
|
# args: [-checks=clang-diagnostic-return-type]
|
||||||
|
# files: src/.*\.cpp
|
|
@ -37,6 +37,9 @@ godot_headers_path = "godot-cpp/godot-headers/"
|
||||||
cpp_bindings_path = "godot-cpp/"
|
cpp_bindings_path = "godot-cpp/"
|
||||||
cpp_library = "libgodot-cpp"
|
cpp_library = "libgodot-cpp"
|
||||||
|
|
||||||
|
obelisk_bindings_path = "obelisk/"
|
||||||
|
obelisk_library = "libobelisk"
|
||||||
|
|
||||||
# Updates the environment with the option variables.
|
# Updates the environment with the option variables.
|
||||||
opts.Update(env)
|
opts.Update(env)
|
||||||
|
|
||||||
|
@ -112,9 +115,9 @@ else:
|
||||||
cpp_library += '.' + str(env['bits'])
|
cpp_library += '.' + str(env['bits'])
|
||||||
|
|
||||||
# make sure our binding library is properly includes
|
# make sure our binding library is properly includes
|
||||||
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
|
env.Append(CPPPATH=['.', obelisk_bindings_path + 'include/', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
|
||||||
env.Append(LIBPATH=[cpp_bindings_path + 'bin/'])
|
env.Append(LIBPATH=[cpp_bindings_path + 'bin/', obelisk_bindings_path + 'bin/'])
|
||||||
env.Append(LIBS=[cpp_library])
|
env.Append(LIBS=[cpp_library, obelisk_library])
|
||||||
|
|
||||||
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
||||||
env.Append(CPPPATH=['src/'])
|
env.Append(CPPPATH=['src/'])
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
[gd_scene load_steps=5 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://Main.gdns" type="Script" id=1]
|
[ext_resource path="res://Main.gdns" type="Script" id=1]
|
||||||
[ext_resource path="res://levels/PrototypeR.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://levels/TestLevel.tscn" type="PackedScene" id=2]
|
||||||
[ext_resource path="res://gui/GameOver.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://gui/GameOver.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://gui/GameWon.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://gui/GameWon.tscn" type="PackedScene" id=4]
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
game_version = "1.0.0"
|
game_version = "1.1.0"
|
||||||
level = ExtResource( 2 )
|
level = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Level" type="Node" parent="."]
|
[node name="Level" type="Node" parent="."]
|
||||||
|
|
Binary file not shown.
|
@ -6,6 +6,7 @@ export var direction = -1
|
||||||
export var detect_edges = true
|
export var detect_edges = true
|
||||||
export var speed = 25
|
export var speed = 25
|
||||||
export var gravity = 9.8
|
export var gravity = 9.8
|
||||||
|
var timer := Timer.new()
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
@ -15,6 +16,12 @@ func _ready() -> void:
|
||||||
$FloorChecker.enabled = detect_edges
|
$FloorChecker.enabled = detect_edges
|
||||||
Event.connect("level_loaded", self, "_on_level_loaded")
|
Event.connect("level_loaded", self, "_on_level_loaded")
|
||||||
|
|
||||||
|
add_child(timer)
|
||||||
|
timer.wait_time = 0.1
|
||||||
|
var err = timer.connect("timeout", self, "_on_timer_timeout")
|
||||||
|
if err == OK:
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if is_on_wall() or not $FloorChecker.is_colliding() and is_on_floor() and $FloorChecker.enabled:
|
if is_on_wall() or not $FloorChecker.is_colliding() and is_on_floor() and $FloorChecker.enabled:
|
||||||
|
@ -41,3 +48,8 @@ func squash() -> void:
|
||||||
|
|
||||||
func _on_level_loaded() -> void:
|
func _on_level_loaded() -> void:
|
||||||
Event.emit_signal("object_created", self.get_name(), "Walking", global_position, Vector2(0, 0))
|
Event.emit_signal("object_created", self.get_name(), "Walking", global_position, Vector2(0, 0))
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
Event.emit_signal("report_object", self.get_name(), "walking", global_position, velocity)
|
||||||
|
timer.start()
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://gdnative/alai.tres" type="GDNativeLibrary" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_name = "AI"
|
||||||
|
class_name = "AI"
|
||||||
|
library = ExtResource( 1 )
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=10 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://characters/player/sprites/green.tres" type="SpriteFrames" id=1]
|
[ext_resource path="res://characters/player/sprites/green.tres" type="SpriteFrames" id=1]
|
||||||
[ext_resource path="res://characters/player/states/Idle.gdns" type="Script" id=2]
|
[ext_resource path="res://characters/player/states/Idle.gdns" type="Script" id=2]
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
[ext_resource path="res://characters/player/states/Jump.gdns" type="Script" id=6]
|
[ext_resource path="res://characters/player/states/Jump.gdns" type="Script" id=6]
|
||||||
[ext_resource path="res://characters/player/states/Fall.gdns" type="Script" id=7]
|
[ext_resource path="res://characters/player/states/Fall.gdns" type="Script" id=7]
|
||||||
[ext_resource path="res://assets/sounds/jump.wav" type="AudioStream" id=8]
|
[ext_resource path="res://assets/sounds/jump.wav" type="AudioStream" id=8]
|
||||||
|
[ext_resource path="res://characters/player/AI.gdns" type="Script" id=9]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 7, 12 )
|
extents = Vector2( 7, 12 )
|
||||||
|
@ -16,6 +17,9 @@ extents = Vector2( 7, 12 )
|
||||||
collision_mask = 10
|
collision_mask = 10
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="AI" type="Node" parent="."]
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
frames = ExtResource( 1 )
|
frames = ExtResource( 1 )
|
||||||
animation = "idle"
|
animation = "idle"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
|
||||||
|
var timer := Timer.new()
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
add_child(timer)
|
||||||
|
timer.wait_time = 0.1
|
||||||
|
var err = timer.connect("timeout", self, "_on_timer_timeout")
|
||||||
|
if err == OK:
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
Event.emit_signal("report_object", self.get_name(), "not collected", global_position, Vector2())
|
||||||
|
timer.start()
|
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=11 format=2]
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
|
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=2]
|
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=2]
|
||||||
[ext_resource path="res://collectables/coin/states/CoinNotCollected.gdns" type="Script" id=3]
|
[ext_resource path="res://collectables/coin/states/CoinNotCollected.gdns" type="Script" id=3]
|
||||||
[ext_resource path="res://collectables/coin/states/CoinCollected.gdns" type="Script" id=4]
|
[ext_resource path="res://collectables/coin/states/CoinCollected.gdns" type="Script" id=4]
|
||||||
[ext_resource path="res://assets/sounds/coin.wav" type="AudioStream" id=5]
|
[ext_resource path="res://assets/sounds/coin.wav" type="AudioStream" id=5]
|
||||||
|
[ext_resource path="res://collectables/coin/Coin.gd" type="Script" id=6]
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id=1]
|
[sub_resource type="CircleShape2D" id=1]
|
||||||
radius = 6.0
|
radius = 6.0
|
||||||
|
@ -43,6 +44,7 @@ tracks/0/keys = {
|
||||||
|
|
||||||
[node name="Coin" type="Area2D"]
|
[node name="Coin" type="Area2D"]
|
||||||
collision_layer = 4
|
collision_layer = 4
|
||||||
|
script = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( 9, 9 )
|
position = Vector2( 9, 9 )
|
||||||
|
@ -51,7 +53,6 @@ shape = SubResource( 1 )
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
frames = SubResource( 4 )
|
frames = SubResource( 4 )
|
||||||
animation = "spin"
|
animation = "spin"
|
||||||
frame = 1
|
|
||||||
playing = true
|
playing = true
|
||||||
centered = false
|
centered = false
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
|
||||||
|
var timer := Timer.new()
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
add_child(timer)
|
||||||
|
timer.wait_time = 0.1
|
||||||
|
var err = timer.connect("timeout", self, "_on_timer_timeout")
|
||||||
|
if err == OK:
|
||||||
|
timer.start()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout() -> void:
|
||||||
|
Event.emit_signal("report_object", self.get_name(), "not touched", global_position, Vector2())
|
||||||
|
timer.start()
|
|
@ -1,9 +1,10 @@
|
||||||
[gd_scene load_steps=9 format=2]
|
[gd_scene load_steps=10 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/flag.png" type="Texture" id=1]
|
[ext_resource path="res://assets/flag.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://goal/GoalNotReached.gdns" type="Script" id=2]
|
[ext_resource path="res://goal/GoalNotReached.gdns" type="Script" id=2]
|
||||||
[ext_resource path="res://goal/GoalReached.gdns" type="Script" id=3]
|
[ext_resource path="res://goal/GoalReached.gdns" type="Script" id=3]
|
||||||
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=4]
|
[ext_resource path="res://state_machine/StateMachine.gdns" type="Script" id=4]
|
||||||
|
[ext_resource path="res://goal/Goal.gd" type="Script" id=5]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=5]
|
[sub_resource type="RectangleShape2D" id=5]
|
||||||
extents = Vector2( 10, 18 )
|
extents = Vector2( 10, 18 )
|
||||||
|
@ -25,15 +26,13 @@ animations = [ {
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
[node name="Goal" type="Area2D"]
|
[node name="Goal" type="Area2D"]
|
||||||
position = Vector2( 324, 378 )
|
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( 18, 18 )
|
|
||||||
shape = SubResource( 5 )
|
shape = SubResource( 5 )
|
||||||
|
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
position = Vector2( 18, 18 )
|
|
||||||
frames = SubResource( 8 )
|
frames = SubResource( 8 )
|
||||||
animation = "flagmove"
|
animation = "flagmove"
|
||||||
playing = true
|
playing = true
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<map version="1.8" tiledversion="1.8.0" orientation="orthogonal" renderorder="right-down" width="39" height="32" tilewidth="18" tileheight="18" infinite="0" nextlayerid="5" nextobjectid="1">
|
||||||
|
<tileset firstgid="1" source="../tilesets/tiles.tsx"/>
|
||||||
|
<layer id="4" name="Background" width="39" height="32">
|
||||||
|
<data encoding="csv">
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,18,19,19,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,18,39,39,39,39,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,38,39,39,39,39,39,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,58,59,98,59,59,59,60,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,117,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,127,89,0,0,0,0,0,138,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
<layer id="1" name="Middleground" width="39" height="32">
|
||||||
|
<data encoding="csv">
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
122,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,124,
|
||||||
|
142,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,144,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
|
||||||
|
123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,
|
||||||
|
123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123,123
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
<layer id="3" name="Foreground" width="39" height="32">
|
||||||
|
<data encoding="csv">
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,0,0,0,0,136,0,0,0,136,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,127,0,0,0,0,0,75,0,0,0,0,75,0,126,0,75,0,0,0,0,126,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,35,0,0,0,0,35,0,0,0,35,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,55,0,0,0,0,55,0,0,0,55,0,0,0,0,0,0
|
||||||
|
</data>
|
||||||
|
</layer>
|
||||||
|
</map>
|
|
@ -0,0 +1,24 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="vnen.tiled_importer"
|
||||||
|
type="PackedScene"
|
||||||
|
path="res://.import/TestLevel.tmx-6c18e110a6e6432fa76e1b0b7b8bc560.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://levels/TestLevel.tmx"
|
||||||
|
dest_files=[ "res://.import/TestLevel.tmx-6c18e110a6e6432fa76e1b0b7b8bc560.scn" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
custom_properties=true
|
||||||
|
tile_metadata=false
|
||||||
|
uv_clip=true
|
||||||
|
y_sort=true
|
||||||
|
image_flags=7
|
||||||
|
collision_layer=2
|
||||||
|
collision_mask=0
|
||||||
|
embed_internal_images=false
|
||||||
|
save_tiled_properties=false
|
||||||
|
add_background=true
|
||||||
|
post_import_script=""
|
|
@ -0,0 +1,84 @@
|
||||||
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://characters/enemies/shelly/Shelly.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://assets/music/prototype_r.ogg" type="AudioStream" id=6]
|
||||||
|
[ext_resource path="res://assets/backgrounds/hills.png" type="Texture" id=7]
|
||||||
|
[ext_resource path="res://levels/TestLevel.tmx" type="PackedScene" id=8]
|
||||||
|
[ext_resource path="res://CameraLimit.gdns" type="Script" id=9]
|
||||||
|
[ext_resource path="res://characters/enemies/dreadtooth/Dreadtooth.tscn" type="PackedScene" id=10]
|
||||||
|
|
||||||
|
[node name="TestLevel" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Player" parent="." instance=ExtResource( 5 )]
|
||||||
|
position = Vector2( 36, 498 )
|
||||||
|
collision_layer = 5
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="Player"]
|
||||||
|
current = true
|
||||||
|
limit_left = 0
|
||||||
|
limit_top = 0
|
||||||
|
limit_right = 512
|
||||||
|
limit_bottom = 288
|
||||||
|
drag_margin_h_enabled = true
|
||||||
|
drag_margin_v_enabled = true
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_bone_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VisibilityNotifier2D" type="VisibilityNotifier2D" parent="Player/Camera2D"]
|
||||||
|
rect = Rect2( 0, 0, 24, 24 )
|
||||||
|
|
||||||
|
[node name="ParallaxBackground" type="ParallaxBackground" parent="."]
|
||||||
|
|
||||||
|
[node name="ParallaxLayer" type="ParallaxLayer" parent="ParallaxBackground"]
|
||||||
|
motion_scale = Vector2( 0.2, 0.1 )
|
||||||
|
motion_offset = Vector2( 0, -288 )
|
||||||
|
motion_mirroring = Vector2( 528, 0 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="ParallaxBackground/ParallaxLayer"]
|
||||||
|
texture = ExtResource( 7 )
|
||||||
|
centered = false
|
||||||
|
|
||||||
|
[node name="Map" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="TestLevel" parent="Map" instance=ExtResource( 8 )]
|
||||||
|
script = ExtResource( 9 )
|
||||||
|
|
||||||
|
[node name="CoinHUD" parent="." instance=ExtResource( 4 )]
|
||||||
|
|
||||||
|
[node name="Coins" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="Coin" parent="Coins" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 144, 504 )
|
||||||
|
|
||||||
|
[node name="Coin5" parent="Coins" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 270, 468 )
|
||||||
|
|
||||||
|
[node name="Coin7" parent="Coins" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 216, 504 )
|
||||||
|
|
||||||
|
[node name="Coin8" parent="Coins" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 459, 468 )
|
||||||
|
|
||||||
|
[node name="Coin9" parent="Coins" instance=ExtResource( 2 )]
|
||||||
|
position = Vector2( 560, 468 )
|
||||||
|
|
||||||
|
[node name="BGM" type="AudioStreamPlayer" parent="."]
|
||||||
|
stream = ExtResource( 6 )
|
||||||
|
volume_db = -25.0
|
||||||
|
autoplay = true
|
||||||
|
|
||||||
|
[node name="Goal" parent="." instance=ExtResource( 3 )]
|
||||||
|
position = Vector2( 656, 504 )
|
||||||
|
|
||||||
|
[node name="Enemies" type="Node" parent="."]
|
||||||
|
|
||||||
|
[node name="Shelly" parent="Enemies" instance=ExtResource( 1 )]
|
||||||
|
position = Vector2( 379, 510 )
|
||||||
|
|
||||||
|
[node name="Dreadtooth" parent="Enemies" instance=ExtResource( 10 )]
|
||||||
|
position = Vector2( 640, 510 )
|
|
@ -2,6 +2,7 @@ extends Node
|
||||||
|
|
||||||
|
|
||||||
export var monitor_enabled: bool = false
|
export var monitor_enabled: bool = false
|
||||||
|
export var anonymous: bool = true
|
||||||
export var debug: bool = false
|
export var debug: bool = false
|
||||||
export var development_url: String = "http://localhost:4050/api/v1"
|
export var development_url: String = "http://localhost:4050/api/v1"
|
||||||
var url_real: String = "https://alai.cromer.cl/api/v1"
|
var url_real: String = "https://alai.cromer.cl/api/v1"
|
||||||
|
@ -58,6 +59,7 @@ func _ready() -> void:
|
||||||
|
|
||||||
game_version = get_parent().game_version
|
game_version = get_parent().game_version
|
||||||
|
|
||||||
|
if not anonymous:
|
||||||
player["rut"] = ""
|
player["rut"] = ""
|
||||||
player["name"] = ""
|
player["name"] = ""
|
||||||
player["email"] = ""
|
player["email"] = ""
|
||||||
|
@ -82,6 +84,7 @@ func _ready() -> void:
|
||||||
else:
|
else:
|
||||||
os_id = 0
|
os_id = 0
|
||||||
|
|
||||||
|
if not anonymous:
|
||||||
game["player"] = player
|
game["player"] = player
|
||||||
game["level_id"] = 0
|
game["level_id"] = 0
|
||||||
game["os_id"] = os_id
|
game["os_id"] = os_id
|
||||||
|
@ -108,6 +111,12 @@ func _ready() -> void:
|
||||||
|
|
||||||
func _physics_process(_delta: float) -> void:
|
func _physics_process(_delta: float) -> void:
|
||||||
if monitor_enabled:
|
if monitor_enabled:
|
||||||
|
if anonymous and has_node("MonitorGUI"):
|
||||||
|
$MonitorGUI.queue_free()
|
||||||
|
Event.emit_signal("monitor_loaded")
|
||||||
|
get_tree().paused = false
|
||||||
|
start_monitor()
|
||||||
|
else:
|
||||||
if has_node("MonitorGUI") and not $MonitorGUI.visible:
|
if has_node("MonitorGUI") and not $MonitorGUI.visible:
|
||||||
$MonitorGUI.visible = true
|
$MonitorGUI.visible = true
|
||||||
Event.emit_signal("monitor_loaded")
|
Event.emit_signal("monitor_loaded")
|
||||||
|
@ -124,11 +133,11 @@ func _physics_process(_delta: float) -> void:
|
||||||
|
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
|
|
||||||
if Input.is_action_just_pressed("Send"):
|
if debug and Input.is_action_just_pressed("Send"):
|
||||||
stop_monitor()
|
stop_monitor()
|
||||||
send_data()
|
send_data()
|
||||||
else:
|
else:
|
||||||
if Input.is_action_just_pressed("Send"):
|
if debug and Input.is_action_just_pressed("Send"):
|
||||||
start_monitor()
|
start_monitor()
|
||||||
else:
|
else:
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
|
@ -137,11 +146,13 @@ func _physics_process(_delta: float) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _on_input_validated(validated_player: Dictionary) -> void:
|
func _on_input_validated(validated_player: Dictionary) -> void:
|
||||||
|
if not anonymous:
|
||||||
$MonitorGUI.queue_free()
|
$MonitorGUI.queue_free()
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
Event.emit_signal("game_started")
|
Event.emit_signal("game_started")
|
||||||
player = validated_player.duplicate(true)
|
player = validated_player.duplicate(true)
|
||||||
game["player"] = player
|
game["player"] = player
|
||||||
|
start_monitor()
|
||||||
|
|
||||||
|
|
||||||
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
fact("coin" is "gold");
|
||||||
|
rule("gold coin" is "collectable" if "coin" is "gold");
|
||||||
|
|
||||||
|
fact("goal" is "touchable");
|
||||||
|
|
||||||
|
fact("shelly" is "dangerous");
|
||||||
|
fact("shelly" is "bouncable");
|
||||||
|
fact("shelly" can "walk");
|
||||||
|
|
||||||
|
fact("dreadtooth" is "dangerous");
|
||||||
|
fact("dreadtooth" can "walk");
|
||||||
|
|
||||||
|
action(if "shelly" is "bouncable" then "jump on" else "jump over");
|
||||||
|
action(if "dreadtooth" is "bouncable" then "jump on" else "jump over");
|
||||||
|
|
||||||
|
action(if "coin" is "collectable" then "collect" else "avoid");
|
||||||
|
action(if "goal" is "touchable" then "touch" else "avoid");
|
|
@ -0,0 +1,292 @@
|
||||||
|
#ifndef OBELISK_KNOWLEDGE_BASE_H
|
||||||
|
#define OBELISK_KNOWLEDGE_BASE_H
|
||||||
|
|
||||||
|
#include "models/action.h"
|
||||||
|
#include "models/entity.h"
|
||||||
|
#include "models/fact.h"
|
||||||
|
#include "models/rule.h"
|
||||||
|
#include "models/suggest_action.h"
|
||||||
|
#include "models/verb.h"
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The KnowledgeBase class represents a collection of facts, rules,
|
||||||
|
* actions, and related language connectors.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class KnowledgeBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The filename of the opened KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const char* filename_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The SQLite connection handle.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
sqlite3* dbConnection_ = nullptr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The user passed flags to use when opening the database.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int flags_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Enable foreign key functionality in the open database.
|
||||||
|
*
|
||||||
|
* This must always be done when the connection is opened or it will
|
||||||
|
* not enforce the foreign key constraints.
|
||||||
|
*/
|
||||||
|
void enableForeignKeys();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the tables in the database.
|
||||||
|
*
|
||||||
|
* @param[in] function This function is called to create the table.
|
||||||
|
*/
|
||||||
|
void createTable(std::function<const char*()> function);
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new KnowledgeBase object.
|
||||||
|
*
|
||||||
|
* @param[in] filename The name of the file to save the knowledge
|
||||||
|
* base as.
|
||||||
|
* @param[in] flags The flags to open the KnowledgeBase with.
|
||||||
|
*/
|
||||||
|
KnowledgeBase(const char* filename, int flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new KnowledgeBase object.
|
||||||
|
*
|
||||||
|
* @param[in] filename The name of the file to save the knowledge
|
||||||
|
* base as.
|
||||||
|
*/
|
||||||
|
KnowledgeBase(const char* filename) :
|
||||||
|
KnowledgeBase(filename,
|
||||||
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the KnowledgeBase object.
|
||||||
|
*
|
||||||
|
* This will close the opened KnowledgeBase before destroying it.
|
||||||
|
*/
|
||||||
|
~KnowledgeBase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add entities to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] entities The entities to add. If the insert is
|
||||||
|
* successful it will have a row ID, if not the ID will be 0.
|
||||||
|
*/
|
||||||
|
void addEntities(std::vector<obelisk::Entity>& entities);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add verbs to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] verbs The verbs to add. If the insert is
|
||||||
|
* successful it will have a row ID, if not the ID will be 0.
|
||||||
|
*/
|
||||||
|
void addVerbs(std::vector<obelisk::Verb>& verbs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add actions to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] actions The actions to add. If the insert is
|
||||||
|
* successful it will have a row ID, if nto the ID will be 0.
|
||||||
|
*/
|
||||||
|
void addActions(std::vector<obelisk::Action>& actions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add facts to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] facts The facts to add. If the insert is
|
||||||
|
* successful it will have a row ID, if not the ID will be 0.
|
||||||
|
*/
|
||||||
|
void addFacts(std::vector<obelisk::Fact>& facts);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add suggested actions to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] suggestActions The suggested actions to add. If
|
||||||
|
* the insert is successful it will have a row ID, if not the ID
|
||||||
|
* will be 0.
|
||||||
|
*/
|
||||||
|
void addSuggestActions(
|
||||||
|
std::vector<obelisk::SuggestAction>& suggestActions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add rules to the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] rules The rules to add. If the insert is
|
||||||
|
* successful it will have a row ID, if not the ID will be 0.
|
||||||
|
*/
|
||||||
|
void addRules(std::vector<obelisk::Rule>& rules);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get an Entity object based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in,out] entity The Entity object should contain just the
|
||||||
|
* ID and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getEntity(obelisk::Entity& entity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a Verb object based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in,out] verb The Verb object should contain just the ID
|
||||||
|
* and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getVerb(obelisk::Verb& verb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get an Action based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in] action The Action object should contain just the ID
|
||||||
|
* and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getAction(obelisk::Action& action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a Fact object based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in,out] fact The Fact object should contain just the ID
|
||||||
|
* and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getFact(obelisk::Fact& fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a SuggestAction based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in,out] suggestAction The SuggestAction object should
|
||||||
|
* contain just the ID and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getSuggestAction(obelisk::SuggestAction& suggestAction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get a Rule based on the ID it contains.
|
||||||
|
*
|
||||||
|
* @param[in,out] rule The Rule object should contain just the ID
|
||||||
|
* and the rest will be filled in.
|
||||||
|
*/
|
||||||
|
void getRule(obelisk::Rule& rule);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if a rule looks for this Fact, if so update its
|
||||||
|
* truth.
|
||||||
|
*
|
||||||
|
* @param[in,out] fact The Fact to check for existing rules.
|
||||||
|
*/
|
||||||
|
void checkRule(obelisk::Fact& fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update the is true field in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in,out] fact The fact to update.
|
||||||
|
*/
|
||||||
|
void updateIsTrue(obelisk::Fact& fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Query the KnowledgeBase to see if a Fact is true or false.
|
||||||
|
*
|
||||||
|
* @param[in] fact The Fact to check.
|
||||||
|
*/
|
||||||
|
void queryFact(obelisk::Fact& fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Query the KnowledgeBase to get a suggested action based
|
||||||
|
* on a Fact.
|
||||||
|
* If a SuggestAction doesn't exist, it will return an empty Action.
|
||||||
|
*
|
||||||
|
* @param[in] fact The Fact to search for.
|
||||||
|
* @param[out] action The Action that is suggested to take.
|
||||||
|
*/
|
||||||
|
void querySuggestAction(obelisk::Fact& fact,
|
||||||
|
obelisk::Action& action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Take a float and divide it into 2 floats.
|
||||||
|
*
|
||||||
|
* This is useful to store doubles in SQLite since SQLite doesn't
|
||||||
|
* have a double type. Instead just store the 2 floats in the
|
||||||
|
* database. Then after selecting them combine them.
|
||||||
|
*
|
||||||
|
* @param[out] result1 The first float generated from the double.
|
||||||
|
* @param[out] result2 The second float generated from the double.
|
||||||
|
* @param[in] var The double to split into the 2 floats.
|
||||||
|
*/
|
||||||
|
void getFloat(float& result1, float& result2, double var);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Combines 2 separated floats back into a double.
|
||||||
|
*
|
||||||
|
* This will recombine the separated floats from the getFloat
|
||||||
|
* method.
|
||||||
|
*
|
||||||
|
* @param[out] result The double generated from the combined floats.
|
||||||
|
* @param[in] var1 The first float to combine.
|
||||||
|
* @param[in] var2 The second float to combine.
|
||||||
|
*/
|
||||||
|
void getDouble(double& result, float var1, float var2);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Exception thrown by the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class KnowledgeBaseException : public std::exception
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The error message given.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
const std::string errorMessage_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new KnowledgeBaseException object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
KnowledgeBaseException() :
|
||||||
|
errorMessage_("an unknown error ocurred")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new KnowledgeBaseException object.
|
||||||
|
*
|
||||||
|
* @param[in] errorMessage The error message given when thrown.
|
||||||
|
*/
|
||||||
|
KnowledgeBaseException(const std::string& errorMessage) :
|
||||||
|
errorMessage_(errorMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the error message that occurred.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the error message.
|
||||||
|
*/
|
||||||
|
const char* what() const noexcept
|
||||||
|
{
|
||||||
|
return errorMessage_.c_str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,128 @@
|
||||||
|
#ifndef OBELISK_MODELS_ACTION_H
|
||||||
|
#define OBELISK_MODELS_ACTION_H
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The Action model represents an action to take when a fact is true
|
||||||
|
* or false.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Action
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the Action in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The name of the Action.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string name_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Action object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Action() :
|
||||||
|
id_(0),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Action object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Action.
|
||||||
|
*/
|
||||||
|
Action(int id) :
|
||||||
|
id_(id),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Action object.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the Action.
|
||||||
|
*/
|
||||||
|
Action(std::string name) :
|
||||||
|
id_(0),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Action object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Action.
|
||||||
|
* @param[in] name The name of the Action.
|
||||||
|
*/
|
||||||
|
Action(int id, std::string name) :
|
||||||
|
id_(id),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the Action table in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the Action.
|
||||||
|
*
|
||||||
|
* @return int& Returns the ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the Action.
|
||||||
|
*
|
||||||
|
* @param[in] id Set the ID of the Action.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the name of the Action.
|
||||||
|
*
|
||||||
|
* @return std::string& The Action name.
|
||||||
|
*/
|
||||||
|
std::string& getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the name of the Action.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the Action.
|
||||||
|
*/
|
||||||
|
void setName(std::string name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select an Action from the datbase based on the object
|
||||||
|
* name.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectByName(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert an Action into the KnowledgeBase based on the
|
||||||
|
* object's fields.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,128 @@
|
||||||
|
#ifndef OBELISK_MODELS_ENTITY_H
|
||||||
|
#define OBELISK_MODELS_ENTITY_H
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The Entity model represents either a left or right side entity,
|
||||||
|
* typically used in facts and rules.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Entity
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the Entity in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The name of the Entity.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string name_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Entity object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Entity() :
|
||||||
|
id_(0),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Entity object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Entity.
|
||||||
|
*/
|
||||||
|
Entity(int id) :
|
||||||
|
id_(id),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Entity object.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the Entity.
|
||||||
|
*/
|
||||||
|
Entity(std::string name) :
|
||||||
|
id_(0),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Entity object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Entity.
|
||||||
|
* @param[in] name The name of the Entity.
|
||||||
|
*/
|
||||||
|
Entity(int id, std::string name) :
|
||||||
|
id_(id),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the table in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the Entity.
|
||||||
|
*
|
||||||
|
* @return int& Returns the ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the Entity.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Entity.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the name of the Entity.
|
||||||
|
*
|
||||||
|
* @return std::string& The name of the Entity.
|
||||||
|
*/
|
||||||
|
std::string& getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the name of the Entity.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the Entity.
|
||||||
|
*/
|
||||||
|
void setName(std::string name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select an Entity from the KnowledgeBase based on the
|
||||||
|
* object's name.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectByName(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert an Entity into the KnowledgeBase based on the
|
||||||
|
* object's fields.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,247 @@
|
||||||
|
#ifndef OBELISK_MODELS_FACT_H
|
||||||
|
#define OBELISK_MODELS_FACT_H
|
||||||
|
|
||||||
|
#include "models/action.h"
|
||||||
|
#include "models/entity.h"
|
||||||
|
#include "models/fact.h"
|
||||||
|
#include "models/verb.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The Fact model represents truth in the releationship between two
|
||||||
|
* entities separated by a verb.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Fact
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the Fact in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Entity from the left side of the expression.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Entity leftEntity_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Entity from the right side of the expression.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Entity rightEntity_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Verb that represents the relationship in the
|
||||||
|
* expression.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Verb verb_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether or not the fact is considered true or not.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
double isTrue_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Fact object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Fact() :
|
||||||
|
id_(0),
|
||||||
|
leftEntity_(),
|
||||||
|
rightEntity_(),
|
||||||
|
verb_(),
|
||||||
|
isTrue_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Fact in the KnowledgeBase.
|
||||||
|
*/
|
||||||
|
Fact(int id) :
|
||||||
|
id_(id),
|
||||||
|
leftEntity_(),
|
||||||
|
rightEntity_(),
|
||||||
|
verb_(),
|
||||||
|
isTrue_(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] leftEntity The Entity on the left side of the
|
||||||
|
* expression.
|
||||||
|
* @param[in] rightEntity The Entity on the right side of the
|
||||||
|
* expression.
|
||||||
|
* @param[in] verb The Verb separating the entities.
|
||||||
|
* @param[in] isTrue Whether or not the fact is true.
|
||||||
|
*/
|
||||||
|
Fact(obelisk::Entity leftEntity,
|
||||||
|
obelisk::Entity rightEntity,
|
||||||
|
obelisk::Verb verb,
|
||||||
|
double isTrue = 0) :
|
||||||
|
id_(0),
|
||||||
|
leftEntity_(leftEntity),
|
||||||
|
rightEntity_(rightEntity),
|
||||||
|
verb_(verb),
|
||||||
|
isTrue_(isTrue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Fact in the KnowledgeBase.
|
||||||
|
* @param[in] leftEntity The Entity on the left side of the
|
||||||
|
* expression.
|
||||||
|
* @param[in] rightEntity The Entity on the right side of the
|
||||||
|
* expression.
|
||||||
|
* @param[in] verb The Verb separating the entities.
|
||||||
|
* @param[in] isTrue Whether or not the fact is true.
|
||||||
|
*/
|
||||||
|
Fact(int id,
|
||||||
|
obelisk::Entity leftEntity,
|
||||||
|
obelisk::Entity rightEntity,
|
||||||
|
obelisk::Verb verb,
|
||||||
|
double isTrue = 0) :
|
||||||
|
id_(id),
|
||||||
|
leftEntity_(leftEntity),
|
||||||
|
rightEntity_(rightEntity),
|
||||||
|
verb_(verb),
|
||||||
|
isTrue_(isTrue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the Fact table in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the Fact
|
||||||
|
*
|
||||||
|
* @return int& Returns the ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the Fact.
|
||||||
|
*
|
||||||
|
* @param[in] id Set the ID of the Fact.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the left Entity object.
|
||||||
|
*
|
||||||
|
* @return Entity& The left Entity.
|
||||||
|
*/
|
||||||
|
Entity& getLeftEntity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the left Entity object.
|
||||||
|
*
|
||||||
|
* @param[in] leftEntity The left Entity to set.
|
||||||
|
*/
|
||||||
|
void setLeftEntity(obelisk::Entity leftEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the right Entity object.
|
||||||
|
*
|
||||||
|
* @return Entity& The right Entity.
|
||||||
|
*/
|
||||||
|
Entity& getRightEntity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the right Entity object.
|
||||||
|
*
|
||||||
|
* @param[in] rightEntity The right Entity to set.
|
||||||
|
*/
|
||||||
|
void setRightEntity(obelisk::Entity rightEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Verb object.
|
||||||
|
*
|
||||||
|
* @return Verb& The Verb.
|
||||||
|
*/
|
||||||
|
Verb& getVerb();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Verb object.
|
||||||
|
*
|
||||||
|
* @param[in] verb The Verb.
|
||||||
|
*/
|
||||||
|
void setVerb(obelisk::Verb verb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Gets the isTrue value.
|
||||||
|
*
|
||||||
|
* @return true If the Fact is considered true.
|
||||||
|
* @return false If the Fact is considered false.
|
||||||
|
*/
|
||||||
|
double& getIsTrue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Fact as true or false.
|
||||||
|
*
|
||||||
|
* @param[in] isTrue Whether or not the Fact is true.
|
||||||
|
*/
|
||||||
|
void setIsTrue(double isTrue);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select the Fact from the KnowledgeBase by IDs of the
|
||||||
|
* sub-objects.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectById(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select the Fact from the KnowledgeBase by the name's of
|
||||||
|
* the entities and verb.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectByName(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select an Action from the KnowledgeBase using the provided
|
||||||
|
* Fact.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
* @param[out] action The Action to take based on the provided fact.
|
||||||
|
*/
|
||||||
|
void selectActionByFact(sqlite3* dbConnection,
|
||||||
|
obelisk::Action& action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert the Fact into the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update whether or not the fact is true in the
|
||||||
|
* KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection.
|
||||||
|
*/
|
||||||
|
void updateIsTrue(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,163 @@
|
||||||
|
#ifndef OBELISK_MODELS_RULE_H
|
||||||
|
#define OBELISK_MODELS_RULE_H
|
||||||
|
|
||||||
|
#include "models/fact.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The Rule model represents a truth relation between 2 Facts.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Rule
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the Rule in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Fact that depends on the Fact reason being true.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Fact fact_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Fact that makes the other Fact true or false.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Fact reason_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Rule object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Rule() :
|
||||||
|
id_(0),
|
||||||
|
fact_(),
|
||||||
|
reason_()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Rule object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Rule in the KnowledgeBase.
|
||||||
|
*/
|
||||||
|
Rule(int id) :
|
||||||
|
id_(id),
|
||||||
|
fact_(),
|
||||||
|
reason_()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Rule object.
|
||||||
|
*
|
||||||
|
* @param[in] fact The Fact.
|
||||||
|
* @param[in] reason The reason Fact.
|
||||||
|
*/
|
||||||
|
Rule(obelisk::Fact fact, obelisk::Fact reason) :
|
||||||
|
id_(0),
|
||||||
|
fact_(fact),
|
||||||
|
reason_(reason)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Rule object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Rule.
|
||||||
|
* @param[in] fact The Fact.
|
||||||
|
* @param[in] reason The reason Fact.
|
||||||
|
*/
|
||||||
|
Rule(int id, obelisk::Fact fact, obelisk::Fact reason) :
|
||||||
|
id_(id),
|
||||||
|
fact_(fact),
|
||||||
|
reason_(reason)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the Rule table in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the Rule.
|
||||||
|
*
|
||||||
|
* @return int& The ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the Rule.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Fact object.
|
||||||
|
*
|
||||||
|
* @return obelisk::Fact& The Fact.
|
||||||
|
*/
|
||||||
|
obelisk::Fact& getFact();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] fact The Fact.
|
||||||
|
*/
|
||||||
|
void setFact(obelisk::Fact fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the reason Fact object.
|
||||||
|
*
|
||||||
|
* @return obelisk::Fact& The reason Fact.
|
||||||
|
*/
|
||||||
|
obelisk::Fact& getReason();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the reason Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] reason The reason Fact.
|
||||||
|
*/
|
||||||
|
void setReason(obelisk::Fact reason);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select the Rule from the KnowledgeBase by IDs of the
|
||||||
|
* sub-objects.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectById(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the rules that match the reason.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
* @param[out] rules The rules to fill in from the database.
|
||||||
|
*/
|
||||||
|
static void selectByReason(sqlite3* dbConnection,
|
||||||
|
int reasonId,
|
||||||
|
std::vector<obelisk::Rule>& rules);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert the Rule into the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,185 @@
|
||||||
|
#ifndef OBELISK_MODELS_SUGGEST_ACTION_H
|
||||||
|
#define OBELISK_MODELS_SUGGEST_ACTION_H
|
||||||
|
|
||||||
|
#include "models/action.h"
|
||||||
|
#include "models/fact.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The SuggestAction model representas the actions to take depending
|
||||||
|
* on if the Fact is true or false.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class SuggestAction
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the SuggestAction.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Fact to check the truth of.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Fact fact_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Action to take if the Fact is true.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Action trueAction_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The Action to take if the Fact is false.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
obelisk::Action falseAction_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new SuggestAction object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
SuggestAction() :
|
||||||
|
id_(0),
|
||||||
|
fact_(),
|
||||||
|
trueAction_(),
|
||||||
|
falseAction_()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new SuggestAction object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the SuggestAction in the KnowledgeBase.
|
||||||
|
*/
|
||||||
|
SuggestAction(int id) :
|
||||||
|
id_(id),
|
||||||
|
fact_(),
|
||||||
|
trueAction_(),
|
||||||
|
falseAction_()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new SuggestAction object.
|
||||||
|
*
|
||||||
|
* @param[in] fact The Fact.
|
||||||
|
* @param[in] trueAction The true Action.
|
||||||
|
* @param[in] falseAction The false Action.
|
||||||
|
*/
|
||||||
|
SuggestAction(obelisk::Fact fact,
|
||||||
|
obelisk::Action trueAction,
|
||||||
|
obelisk::Action falseAction) :
|
||||||
|
id_(0),
|
||||||
|
fact_(fact),
|
||||||
|
trueAction_(trueAction),
|
||||||
|
falseAction_(falseAction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new SuggestAction object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the SuggestAction in the KnowledgeBase.
|
||||||
|
* @param[in] fact The Fact.
|
||||||
|
* @param[in] trueAction The true Action.
|
||||||
|
* @param[in] falseAction The false Action.
|
||||||
|
*/
|
||||||
|
SuggestAction(int id,
|
||||||
|
obelisk::Fact fact,
|
||||||
|
obelisk::Action trueAction,
|
||||||
|
obelisk::Action falseAction) :
|
||||||
|
id_(id),
|
||||||
|
fact_(fact),
|
||||||
|
trueAction_(trueAction),
|
||||||
|
falseAction_(falseAction)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the SuggestAction table in the database.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the SuggestAction.
|
||||||
|
*
|
||||||
|
* @return int& Returns the ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the SuggestAction.
|
||||||
|
*
|
||||||
|
* @param[in] id The new ID.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Fact object.
|
||||||
|
*
|
||||||
|
* @return obelisk::Fact& Returns the Fact.
|
||||||
|
*/
|
||||||
|
obelisk::Fact& getFact();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the Fact object.
|
||||||
|
*
|
||||||
|
* @param[in] fact The new Fact.
|
||||||
|
*/
|
||||||
|
void setFact(obelisk::Fact fact);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the true Action object.
|
||||||
|
*
|
||||||
|
* @return obelisk::Action& Returns the true Action.
|
||||||
|
*/
|
||||||
|
obelisk::Action& getTrueAction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the true Action object.
|
||||||
|
*
|
||||||
|
* @param[in] trueAction The new true Action.
|
||||||
|
*/
|
||||||
|
void setTrueAction(obelisk::Action trueAction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the false Action object.
|
||||||
|
*
|
||||||
|
* @return obelisk::Action& Returns the false Action.
|
||||||
|
*/
|
||||||
|
obelisk::Action& getFalseAction();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the false Action object.
|
||||||
|
*
|
||||||
|
* @param[in] falseAction The new false Action.
|
||||||
|
*/
|
||||||
|
void setFalseAction(obelisk::Action falseAction);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select the SuggestAction from the KnowledgeBase by IDs of
|
||||||
|
* the sub-objects.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectById(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert the SuggestAction into the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,126 @@
|
||||||
|
#ifndef OBELISK_MODELS_VERB_H
|
||||||
|
#define OBELISK_MODELS_VERB_H
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The Verb model represents a verb which is used to connnect
|
||||||
|
* entities.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Verb
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief The ID of the Verb in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int id_;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The name of the Verb.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::string name_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Verb object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Verb() :
|
||||||
|
id_(0),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Verb object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Verb.
|
||||||
|
*/
|
||||||
|
Verb(int id) :
|
||||||
|
id_(id),
|
||||||
|
name_("")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Verb object.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the Verb.
|
||||||
|
*/
|
||||||
|
Verb(std::string name) :
|
||||||
|
id_(0),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Verb object.
|
||||||
|
*
|
||||||
|
* @param[in] id The ID of the Verb.
|
||||||
|
* @param[in] name The name of the Verb.
|
||||||
|
*/
|
||||||
|
Verb(int id, std::string name) :
|
||||||
|
id_(id),
|
||||||
|
name_(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create the Verb table in the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @return const char* Returns the query used to create the table.
|
||||||
|
*/
|
||||||
|
static const char* createTable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the ID of the Verb.
|
||||||
|
*
|
||||||
|
* @return int& Returns the ID.
|
||||||
|
*/
|
||||||
|
int& getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the ID of the Verb.
|
||||||
|
*
|
||||||
|
* @param[in] id Set the ID of the Verb.
|
||||||
|
*/
|
||||||
|
void setId(int id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the name of the Verb.
|
||||||
|
*
|
||||||
|
* @return std::string& The Verb name.
|
||||||
|
*/
|
||||||
|
std::string& getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the name of the Verb.
|
||||||
|
*
|
||||||
|
* @param[in] name The Verb name.
|
||||||
|
*/
|
||||||
|
void setName(std::string name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Select a verb by name from the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void selectByName(sqlite3* dbConnection);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert a new verb into the KnowledgeBase.
|
||||||
|
*
|
||||||
|
* @param[in] dbConnection The database connection to use.
|
||||||
|
*/
|
||||||
|
void insert(sqlite3* dbConnection);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,82 @@
|
||||||
|
#ifndef OBELISK_INCLUDE_OBELISK_H
|
||||||
|
#define OBELISK_INCLUDE_OBELISK_H
|
||||||
|
|
||||||
|
#include "knowledge_base.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The obelisk namespace contains everything needed to compile obelisk
|
||||||
|
* code.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
namespace obelisk
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @brief The obelisk library provides everything needed to consult the
|
||||||
|
* KnowledgeBase.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class Obelisk
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::unique_ptr<obelisk::KnowledgeBase> kb_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Construct a new Obelisk object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Obelisk(std::string filename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the Obelisk object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
~Obelisk() = default;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the obelisk version.
|
||||||
|
*
|
||||||
|
* @return std::string The version.
|
||||||
|
*/
|
||||||
|
std::string getVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the obelisk library so version.
|
||||||
|
*
|
||||||
|
* @return int The version.
|
||||||
|
*/
|
||||||
|
int getLibVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Query the obelisk KnowledgeBase to see if a Fact is true
|
||||||
|
* or not.
|
||||||
|
*
|
||||||
|
* @param[in] p_obelisk The obelisk object pointer.
|
||||||
|
* @param[in] left_entity The left entity.
|
||||||
|
* @param[in] verb The verb.
|
||||||
|
* @param[in] right_entity The right entity.
|
||||||
|
* @return double Returns whether or not the Fact is true.
|
||||||
|
*/
|
||||||
|
double query(const std::string& leftEntity,
|
||||||
|
const std::string& verb,
|
||||||
|
const std::string& rightEntity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Query the Obelisk KnowledgeBase and return the suggested
|
||||||
|
* action to take.
|
||||||
|
*
|
||||||
|
* @param[in] leftEntity The left entity.
|
||||||
|
* @param[in] verb The verb.
|
||||||
|
* @param[in] rightEntity The right entity.
|
||||||
|
* @return std::string Returns the suggested action.
|
||||||
|
*/
|
||||||
|
std::string queryAction(const std::string& leftEntity,
|
||||||
|
const std::string& verb,
|
||||||
|
const std::string& rightEntity);
|
||||||
|
};
|
||||||
|
} // namespace obelisk
|
||||||
|
|
||||||
|
#endif
|
|
@ -49,5 +49,5 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _ready();
|
void _ready();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,7 +12,7 @@ void alai::Event::_register_methods()
|
||||||
godot::register_signal<Event>("player_died");
|
godot::register_signal<Event>("player_died");
|
||||||
godot::register_signal<Event>("player_won");
|
godot::register_signal<Event>("player_won");
|
||||||
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
|
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
|
||||||
|
godot::register_signal<Event>("report_object", "name", GODOT_VARIANT_TYPE_STRING, "state", GODOT_VARIANT_TYPE_STRING, "position", GODOT_VARIANT_TYPE_VECTOR2, "velocity", GODOT_VARIANT_TYPE_VECTOR2);
|
||||||
}
|
}
|
||||||
|
|
||||||
alai::Event::Event()
|
alai::Event::Event()
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace alai
|
||||||
class Event : public godot::Node
|
class Event : public godot::Node
|
||||||
{
|
{
|
||||||
GODOT_CLASS(Event, godot::Node)
|
GODOT_CLASS(Event, godot::Node)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief This method registers classes with Godot.
|
* @brief This method registers classes with Godot.
|
||||||
|
@ -42,6 +43,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _init();
|
void _init();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
11
src/Main.cpp
11
src/Main.cpp
|
@ -1,6 +1,6 @@
|
||||||
#include "Main.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "Main.h"
|
||||||
|
#include "obelisk.h"
|
||||||
|
|
||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
|
|
||||||
|
@ -40,6 +40,10 @@ void alai::Main::_init()
|
||||||
|
|
||||||
void alai::Main::_ready()
|
void alai::Main::_ready()
|
||||||
{
|
{
|
||||||
|
auto obelisk = std::unique_ptr<obelisk::Obelisk> {new obelisk::Obelisk("alai.kb")};
|
||||||
|
godot::Godot::print("Obelisk version: " + godot::String(obelisk->getVersion().c_str()));
|
||||||
|
godot::Godot::print("Obelisk library version: " + godot::String(std::to_string(obelisk->getLibVersion()).c_str()));
|
||||||
|
|
||||||
auto success = _project_settings->load_resource_pack("monitor.pck");
|
auto success = _project_settings->load_resource_pack("monitor.pck");
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
@ -66,8 +70,7 @@ void alai::Main::_ready()
|
||||||
{
|
{
|
||||||
_os->set_window_size(window_size);
|
_os->set_window_size(window_size);
|
||||||
_os->set_window_position(
|
_os->set_window_position(
|
||||||
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5
|
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
success = _project_settings->load_resource_pack("crt.pck");
|
success = _project_settings->load_resource_pack("crt.pck");
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef ALAI_MAIN_H
|
#ifndef ALAI_MAIN_H
|
||||||
#define ALAI_MAIN_H
|
#define ALAI_MAIN_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <Node.hpp>
|
#include <Node.hpp>
|
||||||
|
@ -10,6 +9,7 @@
|
||||||
#include <ProjectSettings.hpp>
|
#include <ProjectSettings.hpp>
|
||||||
#include <Ref.hpp>
|
#include <Ref.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the alai namespace for all the code included in the game.
|
* @brief This is the alai namespace for all the code included in the game.
|
||||||
|
@ -227,6 +227,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void load_level();
|
void load_level();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
|
#include "Event.h"
|
||||||
#include "coin/CoinCollected.h"
|
#include "coin/CoinCollected.h"
|
||||||
|
|
||||||
#include "Event.h"
|
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
|
||||||
#include <AnimationPlayer.hpp>
|
#include <AnimationPlayer.hpp>
|
||||||
|
#include <AudioStreamPlayer.hpp>
|
||||||
|
|
||||||
void alai::CoinCollected::_register_methods()
|
void alai::CoinCollected::_register_methods()
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,6 +68,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _on_animation_finished(godot::String anim_name);
|
void _on_animation_finished(godot::String anim_name);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "coin/CoinCounter.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "coin/CoinCounter.h"
|
||||||
|
|
||||||
#include <String.hpp>
|
#include <String.hpp>
|
||||||
|
|
||||||
|
@ -43,7 +42,8 @@ void alai::CoinCounter::_on_coin_collected(int amount)
|
||||||
{
|
{
|
||||||
coin_string = "0" + godot::String::num(coins);
|
coin_string = "0" + godot::String::num(coins);
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
coin_string = godot::String::num(coins);
|
coin_string = godot::String::num(coins);
|
||||||
}
|
}
|
||||||
set_text(coin_string);
|
set_text(coin_string);
|
||||||
|
|
|
@ -52,9 +52,8 @@ namespace alai
|
||||||
void _on_CoinHUD_ready();
|
void _on_CoinHUD_ready();
|
||||||
void _on_coin_collected(int amount);
|
void _on_coin_collected(int amount);
|
||||||
void _ready();
|
void _ready();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -69,6 +69,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _on_body_entered(Node *node);
|
void _on_body_entered(Node *node);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -69,6 +69,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _on_Goal_body_entered(Node *node);
|
void _on_Goal_body_entered(Node *node);
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "goal/GoalReached.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "goal/GoalReached.h"
|
||||||
|
|
||||||
#include <Area2D.hpp>
|
#include <Area2D.hpp>
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,6 @@ namespace alai
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
#include <Godot.hpp>
|
|
||||||
|
|
||||||
#include "Event.h"
|
|
||||||
#include "state_machine/StateMachine.h"
|
|
||||||
#include "state_machine/State.h"
|
|
||||||
#include "Main.h"
|
|
||||||
#include "CameraLimit.h"
|
#include "CameraLimit.h"
|
||||||
#include "player/Player.h"
|
#include "Event.h"
|
||||||
#include "player/states/PlayerIdle.h"
|
#include "Main.h"
|
||||||
#include "player/states/PlayerMove.h"
|
|
||||||
#include "player/states/PlayerJump.h"
|
|
||||||
#include "player/states/PlayerFall.h"
|
|
||||||
#include "coin/CoinNotCollected.h"
|
|
||||||
#include "coin/CoinCollected.h"
|
#include "coin/CoinCollected.h"
|
||||||
#include "coin/CoinCounter.h"
|
#include "coin/CoinCounter.h"
|
||||||
#include "goal/GoalReached.h"
|
#include "coin/CoinNotCollected.h"
|
||||||
#include "goal/GoalNotReached.h"
|
#include "goal/GoalNotReached.h"
|
||||||
|
#include "goal/GoalReached.h"
|
||||||
#include "gui/game_over/GameOverScreen.h"
|
#include "gui/game_over/GameOverScreen.h"
|
||||||
#include "gui/game_won/GameWonScreen.h"
|
#include "gui/game_won/GameWonScreen.h"
|
||||||
|
#include "player/AI.h"
|
||||||
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerFall.h"
|
||||||
|
#include "player/states/PlayerIdle.h"
|
||||||
|
#include "player/states/PlayerJump.h"
|
||||||
|
#include "player/states/PlayerMove.h"
|
||||||
|
#include "state_machine/State.h"
|
||||||
|
#include "state_machine/StateMachine.h"
|
||||||
|
|
||||||
|
#include <Godot.hpp>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function connects the gdnative init function.
|
* @brief This function connects the gdnative init function.
|
||||||
|
@ -53,6 +54,7 @@ extern "C" void GDN_EXPORT godot_nativescript_init(void *handle)
|
||||||
godot::register_class<alai::Main>();
|
godot::register_class<alai::Main>();
|
||||||
godot::register_class<alai::CameraLimit>();
|
godot::register_class<alai::CameraLimit>();
|
||||||
godot::register_class<alai::player::Player>();
|
godot::register_class<alai::player::Player>();
|
||||||
|
godot::register_class<alai::player::AI>();
|
||||||
godot::register_class<alai::player::PlayerIdle>();
|
godot::register_class<alai::player::PlayerIdle>();
|
||||||
godot::register_class<alai::player::PlayerMove>();
|
godot::register_class<alai::player::PlayerMove>();
|
||||||
godot::register_class<alai::player::PlayerJump>();
|
godot::register_class<alai::player::PlayerJump>();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "gui/game_over/GameOverScreen.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "gui/game_over/GameOverScreen.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <PackedScene.hpp>
|
#include <PackedScene.hpp>
|
||||||
|
@ -39,9 +38,9 @@ void alai::GameOverScreen::_ready()
|
||||||
|
|
||||||
void alai::GameOverScreen::_on_restart_button_pressed()
|
void alai::GameOverScreen::_on_restart_button_pressed()
|
||||||
{
|
{
|
||||||
if (_resource_loader->exists("res://levels/PrototypeR.tscn"))
|
if (_resource_loader->exists("res://levels/TestLevel.tscn"))
|
||||||
{
|
{
|
||||||
godot::Ref<godot::PackedScene> level_scene = _resource_loader->load("res://levels/PrototypeR.tscn");
|
godot::Ref<godot::PackedScene> level_scene = _resource_loader->load("res://levels/TestLevel.tscn");
|
||||||
auto level = level_scene->instance();
|
auto level = level_scene->instance();
|
||||||
auto level_node = get_tree()->get_root()->get_node("Main")->find_node("Level");
|
auto level_node = get_tree()->get_root()->get_node("Main")->find_node("Level");
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <ResourceLoader.hpp>
|
#include <ResourceLoader.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace alai
|
namespace alai
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +56,6 @@ namespace alai
|
||||||
void connect_signal();
|
void connect_signal();
|
||||||
void _on_visibility_changed();
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "gui/game_won/GameWonScreen.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "gui/game_won/GameWonScreen.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <SceneTree.hpp>
|
#include <SceneTree.hpp>
|
||||||
|
|
|
@ -47,6 +47,6 @@ namespace alai
|
||||||
void connect_signal();
|
void connect_signal();
|
||||||
void _on_visibility_changed();
|
void _on_visibility_changed();
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,171 @@
|
||||||
|
#include "player/AI.h"
|
||||||
|
|
||||||
|
#include <InputEventAction.hpp>
|
||||||
|
|
||||||
|
void alai::player::AI::_register_methods()
|
||||||
|
{
|
||||||
|
godot::register_method("_ready", &AI::_ready);
|
||||||
|
godot::register_method("_physics_process", &AI::_physics_process);
|
||||||
|
godot::register_method("_on_object_report", &AI::_on_object_report);
|
||||||
|
godot::register_method("_on_timer_timeout", &AI::_on_timer_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
alai::player::AI::AI()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
alai::player::AI::~AI()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::_init()
|
||||||
|
{
|
||||||
|
_input = godot::Input::get_singleton();
|
||||||
|
obelisk = std::unique_ptr<obelisk::Obelisk> {new obelisk::Obelisk("alai.kb")};
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::_ready()
|
||||||
|
{
|
||||||
|
parent = Object::cast_to<Player>(get_parent());
|
||||||
|
|
||||||
|
event = get_node<alai::Event>("/root/Event");
|
||||||
|
event->connect("report_object", this, "_on_object_report");
|
||||||
|
|
||||||
|
add_child(timer);
|
||||||
|
timer->set_wait_time(1);
|
||||||
|
auto err = timer->connect("timeout", this, "_on_timer_timeout");
|
||||||
|
if (err != godot::Error::OK)
|
||||||
|
{
|
||||||
|
godot::Godot::print("Timer could not be connected!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::_physics_process(float delta)
|
||||||
|
{
|
||||||
|
auto player_position = parent->get_global_position();
|
||||||
|
auto player_direction = parent->get_velocity();
|
||||||
|
bool walking = false;
|
||||||
|
|
||||||
|
std::sort(entities.begin(), entities.end(), [](const Entity &a, const Entity &b) -> bool
|
||||||
|
{
|
||||||
|
return a.position.x < b.position.x;
|
||||||
|
});
|
||||||
|
|
||||||
|
while (!entities.empty())
|
||||||
|
{
|
||||||
|
const auto &entity = entities.front();
|
||||||
|
|
||||||
|
auto entityName = entity.name.utf8().get_data();
|
||||||
|
|
||||||
|
double distance = std::abs(player_position.x - entity.position.x);
|
||||||
|
|
||||||
|
int jump_distance = -1;
|
||||||
|
auto action = obelisk->queryAction(entityName, "is", "bouncable");
|
||||||
|
if (action == "jump on")
|
||||||
|
{
|
||||||
|
jump_distance = 100;
|
||||||
|
}
|
||||||
|
else if (action == "jump over")
|
||||||
|
{
|
||||||
|
jump_distance = 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastEntity == "")
|
||||||
|
{
|
||||||
|
if (jump_distance != -1 && distance < jump_distance)
|
||||||
|
{
|
||||||
|
lastEntity = entity.originalName;
|
||||||
|
timer->start();
|
||||||
|
if (player_position.x < entity.position.x)
|
||||||
|
{
|
||||||
|
auto ev = godot::InputEventAction()._new();
|
||||||
|
ev->set_action("jump");
|
||||||
|
ev->set_pressed(true);
|
||||||
|
_input->parse_input_event(ev);
|
||||||
|
}
|
||||||
|
else if (player_position.x > entity.position.x)
|
||||||
|
{
|
||||||
|
auto ev = godot::InputEventAction()._new();
|
||||||
|
ev->set_action("jump");
|
||||||
|
ev->set_pressed(true);
|
||||||
|
_input->parse_input_event(ev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obelisk->query(entityName, "is", "gold") > 0 && obelisk->query(std::string("gold ") + entityName, "is", "collectable") > 0)
|
||||||
|
{
|
||||||
|
if (entity.position.x > player_position.x)
|
||||||
|
{
|
||||||
|
if (!walking && !_input->is_action_pressed("left") && !_input->is_action_pressed("right"))
|
||||||
|
{
|
||||||
|
walking = true;
|
||||||
|
_input->action_press("right");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!walking && !_input->is_action_pressed("left") && !_input->is_action_pressed("right"))
|
||||||
|
{
|
||||||
|
walking = true;
|
||||||
|
_input->action_press("left");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distance > -10 && distance < 10 && player_position.y - entity.position.y > 20)
|
||||||
|
{
|
||||||
|
timer->stop();
|
||||||
|
lastEntity = "";
|
||||||
|
if (!_input->is_action_pressed("jump"))
|
||||||
|
{
|
||||||
|
_input->action_press("jump");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (obelisk->query(entityName, "is", "touchable") > 0)
|
||||||
|
{
|
||||||
|
if (!walking && !_input->is_action_pressed("left") && !_input->is_action_pressed("right"))
|
||||||
|
{
|
||||||
|
walking = true;
|
||||||
|
if (entity.position.x > player_position.x)
|
||||||
|
{
|
||||||
|
_input->action_press("right");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_input->action_press("left");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
entities.pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::unset_action(godot::String action)
|
||||||
|
{
|
||||||
|
auto ev = godot::InputEventAction()._new();
|
||||||
|
ev->set_action(action);
|
||||||
|
ev->set_pressed(false);
|
||||||
|
_input->parse_input_event(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::_on_timer_timeout()
|
||||||
|
{
|
||||||
|
unset_action("left");
|
||||||
|
unset_action("right");
|
||||||
|
unset_action("jump");
|
||||||
|
lastEntity = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void alai::player::AI::_on_object_report(godot::String name, godot::String state, godot::Vector2 position, godot::Vector2 velocity)
|
||||||
|
{
|
||||||
|
auto entity = Entity();
|
||||||
|
entity.originalName = name;
|
||||||
|
entity.name = name.to_lower().rstrip("0123456789");
|
||||||
|
entity.state = state;
|
||||||
|
entity.position = position;
|
||||||
|
entity.velocity = velocity;
|
||||||
|
entities.emplace_front(entity);
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
#ifndef ALAI_PLAYER_AI_H
|
||||||
|
#define ALAI_PLAYER_AI_H
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
#include "obelisk.h"
|
||||||
|
#include "player/Player.h"
|
||||||
|
|
||||||
|
#include <Godot.hpp>
|
||||||
|
#include <Input.hpp>
|
||||||
|
#include <Node.hpp>
|
||||||
|
#include <Timer.hpp>
|
||||||
|
#include <Vector2.hpp>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
namespace alai
|
||||||
|
{
|
||||||
|
namespace player
|
||||||
|
{
|
||||||
|
class Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
godot::String originalName;
|
||||||
|
godot::String name;
|
||||||
|
godot::String state;
|
||||||
|
godot::Vector2 position;
|
||||||
|
godot::Vector2 velocity;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AI : public godot::Node
|
||||||
|
{
|
||||||
|
GODOT_CLASS(AI, godot::Node)
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief Input singleton.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
godot::Input* _input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The obelisk object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
std::unique_ptr<obelisk::Obelisk> obelisk;
|
||||||
|
|
||||||
|
alai::Event* event;
|
||||||
|
|
||||||
|
std::deque<alai::player::Entity> entities;
|
||||||
|
|
||||||
|
alai::player::Player* parent;
|
||||||
|
|
||||||
|
godot::String lastEntity;
|
||||||
|
|
||||||
|
godot::Timer* timer = godot::Timer()._new();
|
||||||
|
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @brief This method registers classes with Godot.
|
||||||
|
*
|
||||||
|
* @details This method registers methods, properties, and signals with the Godot engine.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
_register_methods();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Construct a new AI object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
AI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Destroy the AI object.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
~AI();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize the class from Godot.
|
||||||
|
*
|
||||||
|
* @details This method is called just once when the Godot engine connects to the instance of the class.
|
||||||
|
*/
|
||||||
|
void _init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Code to be run when ready.
|
||||||
|
*
|
||||||
|
* @details This method is run when all the children of this node are ready.
|
||||||
|
*/
|
||||||
|
void _ready();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The physics processed every delta time.
|
||||||
|
*
|
||||||
|
* @param[in] delta The time since the method was last run.
|
||||||
|
*/
|
||||||
|
void _physics_process(float delta);
|
||||||
|
|
||||||
|
void _on_timer_timeout();
|
||||||
|
|
||||||
|
void unset_action(godot::String action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Callback that receives information about the game environment.
|
||||||
|
*
|
||||||
|
* @param[in] name The name of the object.
|
||||||
|
* @param[in] state The state the object is in.
|
||||||
|
* @param[in] position The position of the object.
|
||||||
|
* @param[in] velocity The object's velocity.
|
||||||
|
*/
|
||||||
|
void _on_object_report(godot::String name, godot::String state, godot::Vector2 position, godot::Vector2 velocity);
|
||||||
|
};
|
||||||
|
} // namespace player
|
||||||
|
} // namespace alai
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,5 @@
|
||||||
#include "player/Player.h"
|
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
|
#include "player/Player.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
#include <Camera2D.hpp>
|
#include <Camera2D.hpp>
|
||||||
|
@ -83,7 +82,8 @@ void alai::player::Player::_ready()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void alai::player::Player::_on_level_loaded() {
|
void alai::player::Player::_on_level_loaded()
|
||||||
|
{
|
||||||
auto state = get_node("StateMachine")->get_child(0);
|
auto state = get_node("StateMachine")->get_child(0);
|
||||||
if (state != nullptr)
|
if (state != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -176,7 +176,8 @@ void alai::player::Player::_physics_process(float delta)
|
||||||
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2) - sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().x);
|
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2) - sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().x);
|
||||||
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3) + sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().y);
|
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3) + sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().y);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
WARN_PRINT("Could not clamp player based on sprite frame size!");
|
WARN_PRINT("Could not clamp player based on sprite frame size!");
|
||||||
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2));
|
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2));
|
||||||
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
|
||||||
|
@ -196,11 +197,13 @@ void alai::player::Player::_physics_process(float delta)
|
||||||
{
|
{
|
||||||
// The first time the notifier is checked always returns false in the first frame
|
// The first time the notifier is checked always returns false in the first frame
|
||||||
// So skip the check from the first frame
|
// So skip the check from the first frame
|
||||||
if (notifier_initialized) {
|
if (notifier_initialized)
|
||||||
|
{
|
||||||
auto event = get_node<alai::Event>("/root/Event");
|
auto event = get_node<alai::Event>("/root/Event");
|
||||||
event->emit_signal("player_died");
|
event->emit_signal("player_died");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
notifier_initialized = true;
|
notifier_initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,7 +291,7 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _on_level_loaded();
|
void _on_level_loaded();
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "player/states/PlayerFall.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerFall.h"
|
||||||
|
|
||||||
void alai::player::PlayerFall::_register_methods()
|
void alai::player::PlayerFall::_register_methods()
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "player/states/PlayerIdle.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerIdle.h"
|
||||||
|
|
||||||
void alai::player::PlayerIdle::_register_methods()
|
void alai::player::PlayerIdle::_register_methods()
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "player/states/PlayerJump.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerJump.h"
|
||||||
|
|
||||||
#include <AudioStreamPlayer.hpp>
|
#include <AudioStreamPlayer.hpp>
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "player/states/PlayerMove.h"
|
|
||||||
|
|
||||||
#include "player/Player.h"
|
#include "player/Player.h"
|
||||||
|
#include "player/states/PlayerMove.h"
|
||||||
|
|
||||||
void alai::player::PlayerMove::_register_methods()
|
void alai::player::PlayerMove::_register_methods()
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include "state_machine/State.h"
|
#include "state_machine/State.h"
|
||||||
|
|
||||||
|
#include <AnimatedSprite.hpp>
|
||||||
#include <Godot.hpp>
|
#include <Godot.hpp>
|
||||||
#include <Input.hpp>
|
#include <Input.hpp>
|
||||||
#include <AnimatedSprite.hpp>
|
|
||||||
|
|
||||||
namespace alai
|
namespace alai
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
void _physics_process(float delta);
|
void _physics_process(float delta);
|
||||||
};
|
};
|
||||||
}
|
} // namespace player
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -98,6 +98,6 @@ namespace alai
|
||||||
*/
|
*/
|
||||||
virtual StateMachine *get_state_machine() final;
|
virtual StateMachine *get_state_machine() final;
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "state_machine/StateMachine.h"
|
|
||||||
|
|
||||||
#include "state_machine/State.h"
|
#include "state_machine/State.h"
|
||||||
|
#include "state_machine/StateMachine.h"
|
||||||
|
|
||||||
void alai::StateMachine::_register_methods()
|
void alai::StateMachine::_register_methods()
|
||||||
{
|
{
|
||||||
|
@ -83,7 +82,8 @@ void alai::StateMachine::setup()
|
||||||
{
|
{
|
||||||
this->call("_state_enter", get_current_state());
|
this->call("_state_enter", get_current_state());
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
|
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,6 +257,6 @@ namespace alai
|
||||||
return _call(method, godot::Array::make(args...));
|
return _call(method, godot::Array::make(args...));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace alai
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue