Modifiers are resources now so I can easily dump them into levels. Yay.
This commit is contained in:
parent
92c707b2f0
commit
f13c4a7061
|
|
@ -1,5 +1,5 @@
|
||||||
class_name StateModifier
|
class_name StateModifier
|
||||||
extends Reference
|
extends Resource
|
||||||
## State modification
|
## State modification
|
||||||
##
|
##
|
||||||
## A state modifier doesn't have any direct control of a game object.
|
## A state modifier doesn't have any direct control of a game object.
|
||||||
|
|
@ -33,7 +33,7 @@ var debug: bool = false
|
||||||
## the state animation. Or perform a 'Replace Animation'
|
## the state animation. Or perform a 'Replace Animation'
|
||||||
var modifier_type = TYPE.NONE
|
var modifier_type = TYPE.NONE
|
||||||
|
|
||||||
var name :String = ''
|
export var name :String = ''
|
||||||
#var ready :bool = false
|
#var ready :bool = false
|
||||||
var is_active: bool = false
|
var is_active: bool = false
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ signal modifier_event(event_id )
|
||||||
#var animation_sequence_timer: Timer
|
#var animation_sequence_timer: Timer
|
||||||
|
|
||||||
var timeout: Timer
|
var timeout: Timer
|
||||||
var timeout_seconds: float = 0.0
|
export var timeout_seconds: float = 0.0
|
||||||
|
|
||||||
# Meant to be called on timeout or other counters this modifier may have.
|
# Meant to be called on timeout or other counters this modifier may have.
|
||||||
# Should be updated whenever modifier owner transfers
|
# Should be updated whenever modifier owner transfers
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
|
export var modifier :Resource
|
||||||
|
|
||||||
var modifier_type = 0
|
var modifier_type = 0
|
||||||
|
|
||||||
|
|
@ -23,20 +24,21 @@ export var gravity_modifier: int = 0
|
||||||
# var a = 2
|
# var a = 2
|
||||||
# var b = "text"
|
# var b = "text"
|
||||||
|
|
||||||
var modifier :StateModifier
|
#var modifier :StateModifier
|
||||||
#var modifier_properties: ModifierProperties
|
#var modifier_properties: ModifierProperties
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
modifier = StateModifier.new()
|
assert(modifier is StateModifier)
|
||||||
modifier.ready( modifier_name, animation_name , modifier.TYPE.NONE, timeout_seconds)
|
# modifier = StateModifier.new()
|
||||||
modifier.modifier_properties = ModifierProperties.new( move_speed,
|
# modifier.ready( modifier_name, animation_name , modifier.TYPE.NONE, timeout_seconds)
|
||||||
gravity_modifier,
|
# modifier.modifier_properties = ModifierProperties.new( move_speed,
|
||||||
move_acceleration,
|
# gravity_modifier,
|
||||||
move_speed_modifier,
|
# move_acceleration,
|
||||||
move_modifier_move_acceleration,
|
# move_speed_modifier,
|
||||||
jerk_factor)
|
# move_modifier_move_acceleration,
|
||||||
|
# jerk_factor)
|
||||||
print("Debug Direction property shy are you stopid?! ", directional_modifier)
|
print("Debug Direction property shy are you stopid?! ", directional_modifier)
|
||||||
modifier.modifier_properties.directional_modifier = directional_modifier
|
modifier.modifier_properties.directional_modifier = directional_modifier
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,16 @@ extends Node2D
|
||||||
# This node can keep an array of various interactibles within a level
|
# This node can keep an array of various interactibles within a level
|
||||||
# and provide several helper functions for managing them perhaps.
|
# and provide several helper functions for managing them perhaps.
|
||||||
|
|
||||||
export(String) var modifier_parent_callback = ""
|
export var enabled :bool = true
|
||||||
|
|
||||||
|
export var callable_state_machine :NodePath
|
||||||
|
var request_push_state_modifier: FuncRef
|
||||||
|
|
||||||
export var debug_receiver :bool = false
|
export var debug_receiver :bool = false
|
||||||
|
|
||||||
var call_function: FuncRef
|
|
||||||
|
|
||||||
#var interactable_function_callables = []
|
|
||||||
|
|
||||||
var modifier_collection = []
|
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
# Declare member variables here. Examples:
|
||||||
# var a = 2
|
# var a = 2
|
||||||
|
|
@ -30,24 +32,28 @@ var modifier_collection = []
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
if modifier_parent_callback:
|
assert(callable_state_machine != null)
|
||||||
call_function = funcref(owner, modifier_parent_callback)
|
|
||||||
else:
|
## FuncRef to request state machine change state
|
||||||
print("Warning: No modifier receiver function defined on ", owner.name)
|
request_push_state_modifier = funcref(get_node(callable_state_machine), 'push_state_modifier')
|
||||||
|
assert(request_push_state_modifier.is_valid())
|
||||||
|
|
||||||
|
|
||||||
# Switching to a new model that starts with Hitbox
|
# Switching to a new model that starts with Hitbox
|
||||||
func register_modifier(modifier: StateModifier):
|
func register_modifier(modifier: StateModifier):
|
||||||
if modifier_collection.has(modifier) == false:
|
if enabled:
|
||||||
print("New Modifier Registered " + modifier.name)
|
request_push_state_modifier.call_func(StateModifier)
|
||||||
modifier_collection.append(modifier)
|
# if modifier_collection.has(modifier) == false:
|
||||||
if call_function.is_valid():
|
# print("New Modifier Registered " + modifier.name)
|
||||||
call_function.call_func(modifier, true)
|
# modifier_collection.append(modifier)
|
||||||
|
# if call_function.is_valid():
|
||||||
|
# call_function.call_func(modifier, true)
|
||||||
|
|
||||||
func remove_modifier(modifier):
|
func remove_modifier(modifier):
|
||||||
print("Modifier Removal " + modifier.name)
|
print("Modifier Removal not implemented here." + modifier.name)
|
||||||
if modifier_collection.has(modifier):
|
# if modifier_collection.has(modifier):
|
||||||
var modifier_index = modifier_collection.rfind(modifier)
|
# var modifier_index = modifier_collection.rfind(modifier)
|
||||||
if modifier_index != -1:
|
# if modifier_index != -1:
|
||||||
modifier_collection.remove(modifier_index)
|
# modifier_collection.remove(modifier_index)
|
||||||
if call_function.is_valid():
|
# if call_function.is_valid():
|
||||||
call_function.call_func(modifier, false)
|
# call_function.call_func(modifier, false)
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/state_machine_animated_actor.gd"
|
"path": "res://lib/classes/state_machine_animated_actor.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Reference",
|
"base": "Resource",
|
||||||
"class": "StateModifier",
|
"class": "StateModifier",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/state_modifier.gd"
|
"path": "res://lib/classes/state_modifier.gd"
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,12 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "hurt" ]
|
animation_sequence = [ "hurt" ]
|
||||||
|
|
||||||
[sub_resource type="Resource" id=4]
|
[sub_resource type="Resource" id=4]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "attack-punch" ]
|
animation_sequence = [ "attack-punch" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "attack-shoot" ]
|
animation_sequence = [ "attack-shoot" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "attack-sword" ]
|
animation_sequence = [ "attack-sword" ]
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "climb" ]
|
animation_sequence = [ "climb" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "idle-crouch" ]
|
animation_sequence = [ "idle-crouch" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "run_crouch" ]
|
animation_sequence = [ "run_crouch" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "death" ]
|
animation_sequence = [ "death" ]
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "walk" ]
|
animation_sequence = [ "walk" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "land" ]
|
animation_sequence = [ "land" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "ledge-climb" ]
|
animation_sequence = [ "ledge-climb" ]
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,10 @@ horizontal_acceleration = 0.0
|
||||||
horizontal_speed_offset = 0.0
|
horizontal_speed_offset = 0.0
|
||||||
horizontal_speed_offset_acceleration = 0.0
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
animation_sequence = [ "ledge-grab" ]
|
animation_sequence = [ "ledge-grab" ]
|
||||||
|
|
|
||||||
|
|
@ -55,3 +55,6 @@ shape = SubResource( 2 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_lock_": true
|
"_edit_lock_": true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Camera Bounds" parent="." index="7"]
|
||||||
|
tile_data = PoolIntArray( -65536, 0, 0, -65521, 0, 0, 65535, 0, 0, 16, 0, 0, 524287, 0, 0, 458768, 0, 0, 589824, 0, 0, 589839, 0, 0 )
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,33 @@
|
||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/classes/Level.gd" type="Script" id=1]
|
[ext_resource path="res://src/classes/Level.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://assets/UI/no_cam_tile.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="ConvexPolygonShape2D" id=5]
|
||||||
|
points = PoolVector2Array( 20, 20, 0.326027, 20, 0.326027, 0.605103, 20, 0.605103 )
|
||||||
|
|
||||||
|
[sub_resource type="TileSet" id=6]
|
||||||
|
0/name = "no_cam_tile.png 0"
|
||||||
|
0/texture = ExtResource( 2 )
|
||||||
|
0/tex_offset = Vector2( 0, 0 )
|
||||||
|
0/modulate = Color( 1, 1, 1, 1 )
|
||||||
|
0/region = Rect2( 0, 0, 20, 20 )
|
||||||
|
0/tile_mode = 0
|
||||||
|
0/occluder_offset = Vector2( 0, 0 )
|
||||||
|
0/navigation_offset = Vector2( 0, 0 )
|
||||||
|
0/shape_offset = Vector2( 0, 0 )
|
||||||
|
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
0/shape = SubResource( 5 )
|
||||||
|
0/shape_one_way = false
|
||||||
|
0/shape_one_way_margin = 1.0
|
||||||
|
0/shapes = [ {
|
||||||
|
"autotile_coord": Vector2( 0, 0 ),
|
||||||
|
"one_way": false,
|
||||||
|
"one_way_margin": 1.0,
|
||||||
|
"shape": SubResource( 5 ),
|
||||||
|
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||||
|
} ]
|
||||||
|
0/z_index = 0
|
||||||
|
|
||||||
[node name="LevelTemplate" type="Node2D"]
|
[node name="LevelTemplate" type="Node2D"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
@ -21,3 +48,11 @@ cell_size = Vector2( 16, 16 )
|
||||||
format = 1
|
format = 1
|
||||||
|
|
||||||
[node name="PlayerStart" type="Position2D" parent="."]
|
[node name="PlayerStart" type="Position2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Camera Bounds" type="TileMap" parent="."]
|
||||||
|
tile_set = SubResource( 6 )
|
||||||
|
cell_size = Vector2( 20, 20 )
|
||||||
|
show_collision = true
|
||||||
|
collision_layer = 256
|
||||||
|
collision_mask = 0
|
||||||
|
format = 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user