correct some issue

This commit is contained in:
AleaJactaEst 2021-01-21 22:03:44 +01:00
parent db3cb83817
commit 70f3ae38c6
33 changed files with 1913 additions and 1898 deletions

View file

@ -6,40 +6,40 @@ signal value_changed( value )
export( Texture ) var minus_texture setget set_minus_texture, get_minus_texture
func set_minus_texture( value ):
minus_texture = value
if self.has_node( "kh_h_slider/minus" ):
$kh_h_slider/minus.texture_normal = minus_texture
minus_texture = value
if self.has_node( "kh_h_slider/minus" ):
$kh_h_slider/minus.texture_normal = minus_texture
func get_minus_texture():
return minus_texture
return minus_texture
export( Texture ) var plus_texture setget set_plus_texture, get_plus_texture
func set_plus_texture( value ):
plus_texture = value
if self.has_node( "kh_h_slider/plus" ):
$kh_h_slider/plus.texture_normal = plus_texture
plus_texture = value
if self.has_node( "kh_h_slider/plus" ):
$kh_h_slider/plus.texture_normal = plus_texture
func get_plus_texture():
return plus_texture
return plus_texture
func _ready():
self.add_child( preload( "res://addons/kh_slider/kh_h_slider.tscn" ).instance() )
self.add_child( preload( "res://addons/kh_slider/kh_h_slider.tscn" ).instance() )
$kh_h_slider/minus.connect( "pressed", self, "_on_minus_pressed" )
$kh_h_slider/value.connect( "changed", self, "_on_value_changed" )
$kh_h_slider/value.connect( "value_changed", self, "_on_value_value_changed" )
$kh_h_slider/plus.connect( "pressed", self, "_on_plus_pressed" )
$kh_h_slider/minus.texture_normal = minus_texture
$kh_h_slider/plus.texture_normal = plus_texture
$kh_h_slider/minus.connect( "pressed", self, "_on_minus_pressed" )
$kh_h_slider/value.connect( "changed", self, "_on_value_changed" )
$kh_h_slider/value.connect( "value_changed", self, "_on_value_value_changed" )
$kh_h_slider/plus.connect( "pressed", self, "_on_plus_pressed" )
$kh_h_slider/minus.texture_normal = minus_texture
$kh_h_slider/plus.texture_normal = plus_texture
func _on_minus_pressed():
$kh_h_slider/value.value -= $kh_h_slider/value.step
$kh_h_slider/value.value -= $kh_h_slider/value.step
func _on_plus_pressed():
$kh_h_slider/value.value += $kh_h_slider/value.step
$kh_h_slider/value.value += $kh_h_slider/value.step
func _on_value_changed():
emit_signal( "changed" )
emit_signal( "changed" )
func _on_value_value_changed( value ):
emit_signal( "value_changed", value )
emit_signal( "value_changed", value )

View file

@ -2,7 +2,7 @@ tool
extends EditorPlugin
func _enter_tree():
add_custom_type("KhHSlider", "HBoxContainer", preload("kh_h_slider.gd"), preload("kh_h_slider.png"))
add_custom_type("KhHSlider", "HBoxContainer", preload("kh_h_slider.gd"), preload("kh_h_slider.png"))
func _exit_tree():
remove_custom_type("KhHSlider")
remove_custom_type("KhHSlider")

View file

@ -31,63 +31,63 @@ var size_changed = true
func add_child_to_content( node):
if self.get_content():
self.get_content().add_child(node)
if self.get_content():
self.get_content().add_child(node)
func add_window_part( node ):
add_child( node )
add_child( node )
func set_mouse_pass_to_children( node ):
for child in node.get_children():
set_mouse_pass_to_children( child )
if node is Control:
node.mouse_filter = MOUSE_FILTER_PASS
for child in node.get_children():
set_mouse_pass_to_children( child )
if node is Control:
node.mouse_filter = MOUSE_FILTER_PASS
#func _ready():
func _enter_tree():
########
#### Window's part création.
# The internal elements structure is:
# self - MarginContainer
# background - NinePatchRect
# parts - VBoxContainer
# header_box - MarginContainer
# header - HBoxContainer
# quit - TextureButton
# close - TextureButton
# open - TextureButton
# label - Label
# content_box - MarginContainer
# scroll_container - Scrollcontainer
# content - VBoxContainer
# footer_box - MarginContainer
# footer - HBoxContainer
# contextual_help - Label
# resize - TextureButton
########
#### Window's part création.
# The internal elements structure is:
# self - MarginContainer
# background - NinePatchRect
# parts - VBoxContainer
# header_box - MarginContainer
# header - HBoxContainer
# quit - TextureButton
# close - TextureButton
# open - TextureButton
# label - Label
# content_box - MarginContainer
# scroll_container - Scrollcontainer
# content - VBoxContainer
# footer_box - MarginContainer
# footer - HBoxContainer
# contextual_help - Label
# resize - TextureButton
###
# self
self.size_flags_horizontal = SIZE_EXPAND
self.size_flags_vertical = SIZE_EXPAND
###
# self
self.size_flags_horizontal = SIZE_EXPAND
self.size_flags_vertical = SIZE_EXPAND
self.set( "custom_constants/margin_right", 0)
self.set( "custom_constants/margin_top", 0)
self.set( "custom_constants/margin_left", 0)
self.set( "custom_constants/margin_bottom", 0)
self.set( "custom_constants/margin_right", 0)
self.set( "custom_constants/margin_top", 0)
self.set( "custom_constants/margin_left", 0)
self.set( "custom_constants/margin_bottom", 0)
self.connect ( "gui_input", self, "_on_window_gui_input" )
if is_movable and not self.is_dragged_by_header_only:
self.mouse_default_cursor_shape = CURSOR_MOVE
###
###
# background
var background
if not self.has_node( "background" ):
background = NinePatchRect.new()
background.name = "background"
if not background_texture:
self.connect ( "gui_input", self, "_on_window_gui_input" )
if is_movable and not self.is_dragged_by_header_only:
self.mouse_default_cursor_shape = CURSOR_MOVE
###
###
# background
var background
if not self.has_node( "background" ):
background = NinePatchRect.new()
background.name = "background"
if not background_texture:
# var background_image = Image.new()
# var stream_texture = load('res://addons/ui_window/background_default.jpg')
# if not stream_texture :
@ -97,435 +97,435 @@ func _enter_tree():
# background.texture = ImageTexture.new()
# background.texture.create_from_image( background_image )
# background.texture.flags = Texture.FLAG_FILTER | Texture.FLAG_REPEAT
pass
else:
background.texture = background_texture
background.texture.flags = Texture.FLAG_FILTER | Texture.FLAG_REPEAT
pass
else:
background.texture = background_texture
background.texture.flags = Texture.FLAG_FILTER | Texture.FLAG_REPEAT
background.axis_stretch_horizontal = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.axis_stretch_vertical = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.axis_stretch_horizontal = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.axis_stretch_vertical = NinePatchRect.AXIS_STRETCH_MODE_TILE
background.size_flags_horizontal = SIZE_EXPAND_FILL
background.size_flags_vertical = SIZE_EXPAND_FILL
background.size_flags_horizontal = SIZE_EXPAND_FILL
background.size_flags_vertical = SIZE_EXPAND_FILL
background.region_rect = Rect2( 0, 0, 0, 0 )
background.patch_margin_left = 4
background.patch_margin_top = 32
background.patch_margin_right = 4
background.patch_margin_bottom = 4
background.region_rect = Rect2( 0, 0, 0, 0 )
background.patch_margin_left = 4
background.patch_margin_top = 32
background.patch_margin_right = 4
background.patch_margin_bottom = 4
background.self_modulate = background_color
self.add_window_part( background )
background.self_modulate = background_color
self.add_window_part( background )
# background.set_owner( self )
###
###
# parts
var parts
if not self.has_node( "parts" ):
parts = VBoxContainer.new()
parts.name = "parts"
parts.size_flags_horizontal = SIZE_EXPAND_FILL
parts.size_flags_vertical = SIZE_EXPAND_FILL
self.add_window_part( parts )
###
###
# parts
var parts
if not self.has_node( "parts" ):
parts = VBoxContainer.new()
parts.name = "parts"
parts.size_flags_horizontal = SIZE_EXPAND_FILL
parts.size_flags_vertical = SIZE_EXPAND_FILL
self.add_window_part( parts )
# parts.set_owner( self )
###
###
# header_box
var header_box
if not parts.has_node( "header_box" ):
header_box = MarginContainer.new()
header_box.name = "header_box"
header_box.size_flags_horizontal = SIZE_EXPAND_FILL
header_box.size_flags_vertical = SIZE_SHRINK_CENTER
###
###
# header_box
var header_box
if not parts.has_node( "header_box" ):
header_box = MarginContainer.new()
header_box.name = "header_box"
header_box.size_flags_horizontal = SIZE_EXPAND_FILL
header_box.size_flags_vertical = SIZE_SHRINK_CENTER
header_box.set( "custom_constants/margin_right", 4)
header_box.set( "custom_constants/margin_top", 4)
header_box.set( "custom_constants/margin_left", 4)
header_box.set( "custom_constants/margin_bottom", 4)
header_box.set( "custom_constants/margin_right", 4)
header_box.set( "custom_constants/margin_top", 4)
header_box.set( "custom_constants/margin_left", 4)
header_box.set( "custom_constants/margin_bottom", 4)
if is_movable:
header_box.mouse_default_cursor_shape = CURSOR_MOVE
parts.add_child( header_box )
if is_movable:
header_box.mouse_default_cursor_shape = CURSOR_MOVE
parts.add_child( header_box )
# header_box.set_owner( parts )
header_box.connect ( "gui_input", self, "_on_Header_gui_input" )
###
###
# header
var header
if not header_box.has_node( "header" ):
header = HBoxContainer.new()
header.name = "header"
header.size_flags_horizontal = SIZE_EXPAND_FILL
header.size_flags_vertical = SIZE_EXPAND | SIZE_SHRINK_CENTER
if is_movable:
header.mouse_default_cursor_shape = CURSOR_MOVE
header_box.add_child( header )
header_box.connect ( "gui_input", self, "_on_Header_gui_input" )
###
###
# header
var header
if not header_box.has_node( "header" ):
header = HBoxContainer.new()
header.name = "header"
header.size_flags_horizontal = SIZE_EXPAND_FILL
header.size_flags_vertical = SIZE_EXPAND | SIZE_SHRINK_CENTER
if is_movable:
header.mouse_default_cursor_shape = CURSOR_MOVE
header_box.add_child( header )
# header.set_owner( header_box )
###
###
# quit
var quit_button
if not header.has_node( "quit" ):
quit_button = TextureButton.new()
quit_button.name = "quit"
quit_button.size_flags_horizontal = SIZE_SHRINK_END
quit_button.size_flags_vertical = SIZE_SHRINK_CENTER
###
###
# quit
var quit_button
if not header.has_node( "quit" ):
quit_button = TextureButton.new()
quit_button.name = "quit"
quit_button.size_flags_horizontal = SIZE_SHRINK_END
quit_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_quit = ImageTexture.new()
var img_quit = Image.new()
var stream_texture = load( "res://addons/kh_window/button_quit.png")
img_quit = stream_texture.get_data()
tex_quit.create_from_image( img_quit )
quit_button.texture_normal = tex_quit
var tex_quit = ImageTexture.new()
var img_quit = Image.new()
var stream_texture = load( "res://addons/kh_window/button_quit.png")
img_quit = stream_texture.get_data()
tex_quit.create_from_image( img_quit )
quit_button.texture_normal = tex_quit
header.add_child( quit_button )
header.add_child( quit_button )
# quit_button.set_owner( header )
quit_button.connect ( "pressed", self, "_on_Quit_pressed" )
###
# close
var close_button = TextureButton.new()
if not header.has_node( "close" ):
close_button = TextureButton.new()
close_button.name = "close"
close_button.size_flags_horizontal = SIZE_SHRINK_END
close_button.size_flags_vertical = SIZE_SHRINK_CENTER
quit_button.connect ( "pressed", self, "_on_Quit_pressed" )
###
# close
var close_button = TextureButton.new()
if not header.has_node( "close" ):
close_button = TextureButton.new()
close_button.name = "close"
close_button.size_flags_horizontal = SIZE_SHRINK_END
close_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_close = ImageTexture.new()
var img_close = Image.new()
var stream_texture = load("res://addons/kh_window/button_close.png")
img_close = stream_texture.get_data()
tex_close.create_from_image( img_close )
close_button.texture_normal = tex_close
var tex_close = ImageTexture.new()
var img_close = Image.new()
var stream_texture = load("res://addons/kh_window/button_close.png")
img_close = stream_texture.get_data()
tex_close.create_from_image( img_close )
close_button.texture_normal = tex_close
header.add_child( close_button )
header.add_child( close_button )
# close_button.set_owner( header )
close_button.connect ( "pressed", self, "_on_Close_pressed" )
###
# open
var open_button
if not header.has_node( "open" ):
open_button = TextureButton.new()
open_button.name = "open"
open_button.size_flags_horizontal = SIZE_SHRINK_END
open_button.size_flags_vertical = SIZE_SHRINK_CENTER
close_button.connect ( "pressed", self, "_on_Close_pressed" )
###
# open
var open_button
if not header.has_node( "open" ):
open_button = TextureButton.new()
open_button.name = "open"
open_button.size_flags_horizontal = SIZE_SHRINK_END
open_button.size_flags_vertical = SIZE_SHRINK_CENTER
var tex_open = ImageTexture.new()
var img_open = Image.new()
var stream_texture = load("res://addons/kh_window/button_open.png")
img_open = stream_texture.get_data()
tex_open.create_from_image( img_open )
open_button.texture_normal = tex_open
open_button.visible = false
header.add_child( open_button )
var tex_open = ImageTexture.new()
var img_open = Image.new()
var stream_texture = load("res://addons/kh_window/button_open.png")
img_open = stream_texture.get_data()
tex_open.create_from_image( img_open )
open_button.texture_normal = tex_open
open_button.visible = false
header.add_child( open_button )
# open_button.set_owner( header )
open_button.connect ( "pressed", self, "_on_Open_pressed" )
###
###
# Title Label
var title_label
if not header.has_node( "label" ):
title_label = Label.new()
title_label.name = "label"
title_label.text = title
title_label.size_flags_horizontal = SIZE_EXPAND_FILL
title_label.size_flags_vertical = SIZE_SHRINK_CENTER
if is_movable:
title_label.mouse_default_cursor_shape = CURSOR_MOVE
header.add_child( title_label )
open_button.connect ( "pressed", self, "_on_Open_pressed" )
###
###
# Title Label
var title_label
if not header.has_node( "label" ):
title_label = Label.new()
title_label.name = "label"
title_label.text = title
title_label.size_flags_horizontal = SIZE_EXPAND_FILL
title_label.size_flags_vertical = SIZE_SHRINK_CENTER
if is_movable:
title_label.mouse_default_cursor_shape = CURSOR_MOVE
header.add_child( title_label )
# title_label.set_owner( header )
###
###
# Content
var content_box
if not parts.has_node( "content_box" ):
content_box = MarginContainer.new()
content_box.name = "content_box"
content_box.size_flags_horizontal = SIZE_EXPAND_FILL
content_box.size_flags_vertical = SIZE_EXPAND_FILL
content_box.set( "custom_constants/margin_right", 8)
content_box.set( "custom_constants/margin_top", 8)
content_box.set( "custom_constants/margin_left", 8)
content_box.set( "custom_constants/margin_bottom", 8)
parts.add_child( content_box )
###
###
# Content
var content_box
if not parts.has_node( "content_box" ):
content_box = MarginContainer.new()
content_box.name = "content_box"
content_box.size_flags_horizontal = SIZE_EXPAND_FILL
content_box.size_flags_vertical = SIZE_EXPAND_FILL
content_box.set( "custom_constants/margin_right", 8)
content_box.set( "custom_constants/margin_top", 8)
content_box.set( "custom_constants/margin_left", 8)
content_box.set( "custom_constants/margin_bottom", 8)
parts.add_child( content_box )
# content_box.set_owner( parts )
###
###
if self.has_scrollbar:
# content_box/scroll_container
var content_scroll_container
if not content_box.has_node( "scroll_container" ):
content_scroll_container = ScrollContainer.new()
content_scroll_container.name = "scroll_container"
content_scroll_container.size_flags_horizontal = SIZE_FILL
content_scroll_container.size_flags_vertical = SIZE_FILL
content_scroll_container.scroll_deadzone = 0
content_box.add_child( content_scroll_container )
# content_scroll_container.set_owner( content_box )
###
###
# content
var content
if not content_scroll_container.has_node( "content" ):
content = MarginContainer.new()
content.name = "content"
content.size_flags_horizontal = SIZE_EXPAND_FILL
content.size_flags_vertical = SIZE_EXPAND_FILL
content_scroll_container.add_child( content )
# content.set_owner( content_scroll_container )
###
else:
var content
if not content_box.has_node( "content" ):
content = MarginContainer.new()
content.name = "content"
content.size_flags_horizontal = SIZE_EXPAND_FILL
content.size_flags_vertical = SIZE_EXPAND_FILL
content_box.add_child( content )
###
###
if self.has_scrollbar:
# content_box/scroll_container
var content_scroll_container
if not content_box.has_node( "scroll_container" ):
content_scroll_container = ScrollContainer.new()
content_scroll_container.name = "scroll_container"
content_scroll_container.size_flags_horizontal = SIZE_FILL
content_scroll_container.size_flags_vertical = SIZE_FILL
content_scroll_container.scroll_deadzone = 0
content_box.add_child( content_scroll_container )
# content_scroll_container.set_owner( content_box )
###
###
# content
var content
if not content_scroll_container.has_node( "content" ):
content = MarginContainer.new()
content.name = "content"
content.size_flags_horizontal = SIZE_EXPAND_FILL
content.size_flags_vertical = SIZE_EXPAND_FILL
content_scroll_container.add_child( content )
# content.set_owner( content_scroll_container )
###
else:
var content
if not content_box.has_node( "content" ):
content = MarginContainer.new()
content.name = "content"
content.size_flags_horizontal = SIZE_EXPAND_FILL
content.size_flags_vertical = SIZE_EXPAND_FILL
content_box.add_child( content )
###
# Footer
var footer_box
if not parts.has_node( "footer_box" ):
footer_box = MarginContainer.new()
footer_box.name = "footer_box"
footer_box.size_flags_horizontal = SIZE_FILL
footer_box.size_flags_vertical = SIZE_FILL
footer_box.set( "custom_constants/margin_right", content_margin.position.y)
footer_box.set( "custom_constants/margin_top", content_margin.size.x)
footer_box.set( "custom_constants/margin_left", content_margin.position.x)
footer_box.set( "custom_constants/margin_bottom", content_margin.size.y)
parts.add_child( footer_box )
###
# Footer
var footer_box
if not parts.has_node( "footer_box" ):
footer_box = MarginContainer.new()
footer_box.name = "footer_box"
footer_box.size_flags_horizontal = SIZE_FILL
footer_box.size_flags_vertical = SIZE_FILL
footer_box.set( "custom_constants/margin_right", content_margin.position.y)
footer_box.set( "custom_constants/margin_top", content_margin.size.x)
footer_box.set( "custom_constants/margin_left", content_margin.position.x)
footer_box.set( "custom_constants/margin_bottom", content_margin.size.y)
parts.add_child( footer_box )
# footer_box.set_owner( parts )
###
###
# footer_box/footer
var footer
if not footer_box.has_node( "footer" ):
footer = HBoxContainer.new()
footer.name = "footer"
footer.size_flags_horizontal = SIZE_EXPAND_FILL
footer.size_flags_vertical = SIZE_EXPAND_FILL
footer_box.add_child( footer )
###
###
# footer_box/footer
var footer
if not footer_box.has_node( "footer" ):
footer = HBoxContainer.new()
footer.name = "footer"
footer.size_flags_horizontal = SIZE_EXPAND_FILL
footer.size_flags_vertical = SIZE_EXPAND_FILL
footer_box.add_child( footer )
# footer.set_owner( footer_box )
###
###
# footer_label
var footer_label
if not footer.has_node( "footer_label" ):
footer_label = Label.new()
footer_label.name = "footer_label"
footer_label.size_flags_horizontal = SIZE_EXPAND
footer_label.size_flags_vertical = SIZE_EXPAND
###
###
# footer_label
var footer_label
if not footer.has_node( "footer_label" ):
footer_label = Label.new()
footer_label.name = "footer_label"
footer_label.size_flags_horizontal = SIZE_EXPAND
footer_label.size_flags_vertical = SIZE_EXPAND
footer.add_child( footer_label )
footer.add_child( footer_label )
###
# resize
var resize_button
if not footer.has_node( "resize" ):
resize_button = TextureButton.new()
resize_button.name = "resize"
resize_button.size_flags_horizontal = SIZE_FILL | SIZE_SHRINK_END
resize_button.size_flags_vertical = SIZE_SHRINK_END
###
# resize
var resize_button
if not footer.has_node( "resize" ):
resize_button = TextureButton.new()
resize_button.name = "resize"
resize_button.size_flags_horizontal = SIZE_FILL | SIZE_SHRINK_END
resize_button.size_flags_vertical = SIZE_SHRINK_END
var tex_resize = ImageTexture.new()
var img_resize = Image.new()
var stream_texture = load("res://addons/kh_window/button_resize.png")
img_resize = stream_texture.get_data()
tex_resize.create_from_image( img_resize )
resize_button.texture_normal = tex_resize
resize_button.mouse_default_cursor_shape = CURSOR_FDIAGSIZE
resize_button.action_mode = Button.ACTION_MODE_BUTTON_PRESS
var tex_resize = ImageTexture.new()
var img_resize = Image.new()
var stream_texture = load("res://addons/kh_window/button_resize.png")
img_resize = stream_texture.get_data()
tex_resize.create_from_image( img_resize )
resize_button.texture_normal = tex_resize
resize_button.mouse_default_cursor_shape = CURSOR_FDIAGSIZE
resize_button.action_mode = Button.ACTION_MODE_BUTTON_PRESS
# resize_button.mouse_filter = MOUSE_FILTER_STOP
footer.add_child( resize_button )
footer.add_child( resize_button )
# resize_button.set_owner( footer )
resize_button.connect ( "button_down", self, "_on_Resize_pressed" )
###er_label.set_owner( footer )
###
resize_button.connect ( "button_down", self, "_on_Resize_pressed" )
###er_label.set_owner( footer )
###
current_rect_size = self.rect_min_size
current_rect_size = self.rect_min_size
if is_borderless:
$background.region_rect = Rect2( $background.patch_margin_left-1
, $background.patch_margin_top-1
, 256-($background.patch_margin_left+$background.patch_margin_right)+2
, 256-($background.patch_margin_top+$background.patch_margin_bottom)+2 )
$background.patch_margin_left = 1
$background.patch_margin_top = 1
$background.patch_margin_right = 1
$background.patch_margin_bottom = 1
header_box.rect_min_size.y = 1
close_button.visible = false
open_button.visible = false
quit_button.visible = false
title_label.visible = false
if is_borderless:
$background.region_rect = Rect2( $background.patch_margin_left-1
, $background.patch_margin_top-1
, 256-($background.patch_margin_left+$background.patch_margin_right)+2
, 256-($background.patch_margin_top+$background.patch_margin_bottom)+2 )
$background.patch_margin_left = 1
$background.patch_margin_top = 1
$background.patch_margin_right = 1
$background.patch_margin_bottom = 1
header_box.rect_min_size.y = 1
close_button.visible = false
open_button.visible = false
quit_button.visible = false
title_label.visible = false
if not is_resizable:
if not has_footer:
footer_box.visible = false
else:
footer_box.get_node( "footer/resize" ).visible = false
if not is_resizable:
if not has_footer:
footer_box.visible = false
else:
footer_box.get_node( "footer/resize" ).visible = false
func _ready():
# On déplace les enfants ajouter via l'editeur sous content.
for child in self.get_children():
if not child.name =="parts" and not child.name =="background":
if child.name.begins_with( "footer_" ):
if footer_box.get_node("footer").has_node("footer_label"):
footer_box.get_node("footer").remove_child( footer_box.get_node("footer").get_node("footer_label") )
# On déplace les enfants ajouter via l'editeur sous content.
for child in self.get_children():
if not child.name =="parts" and not child.name =="background":
if child.name.begins_with( "footer_" ):
if footer_box.get_node("footer").has_node("footer_label"):
footer_box.get_node("footer").remove_child( footer_box.get_node("footer").get_node("footer_label") )
self.remove_child( child )
get_footer().add_child( child )
get_footer().move_child( child, 0 )
else:
self.remove_child( child )
get_content().add_child( child )
self.remove_child( child )
get_footer().add_child( child )
get_footer().move_child( child, 0 )
else:
self.remove_child( child )
get_content().add_child( child )
set_mouse_pass_to_children( self )
set_mouse_pass_to_children( self )
func _process(delta):
if size_changed:
self.rect_size = Vector2( clamp( self.rect_size.x, min_size.x, self.rect_size.x ), clamp( self.rect_size.y, min_size.y, self.rect_size.y ) )
size_changed = false
if size_changed:
self.rect_size = Vector2( clamp( self.rect_size.x, min_size.x, self.rect_size.x ), clamp( self.rect_size.y, min_size.y, self.rect_size.y ) )
size_changed = false
func _on_Window_mouse_entered():
print("mouse_entered")
print("mouse_entered")
func _on_Window_focus_entered():
print("focus_entered")
print("focus_entered")
func _on_Quit_pressed():
self.visible = false
self.visible = false
func get_content_child( p_node ):
return get_content().get_node( p_node )
return get_content().get_node( p_node )
func get_content():
if self.has_scrollbar:
return content_box.get_node( "scroll_container/content" )
else:
return content_box.get_node( "content" )
if self.has_scrollbar:
return content_box.get_node( "scroll_container/content" )
else:
return content_box.get_node( "content" )
func get_footer():
return footer_box.get_node( "footer" )
return footer_box.get_node( "footer" )
func close():
if not self.is_borderless:
self.header_box.get_node( "header/close" ).visible = false
self.header_box.get_node( "header/open" ).visible = true
self.content_box.visible = false
self.footer_box.visible = false
self.current_rect_size = self.rect_size
self.rect_size = Vector2( 0, 0 )
$background.rect_size = Vector2( 0, 0 )
$background.rect_min_size = Vector2( 0, 0 )
else:
self.header_box.get_node( "header/close" ).visible = false
self.header_box.get_node( "header/open" ).visible = false
self.content_box.visible = false
self.footer_box.visible = false
self.current_rect_size = self.rect_size
self.rect_size = Vector2( 0, 0 )
$background.rect_size = Vector2( 0, 0 )
$background.rect_min_size = Vector2( 0, 0 )
if not self.is_borderless:
self.header_box.get_node( "header/close" ).visible = false
self.header_box.get_node( "header/open" ).visible = true
self.content_box.visible = false
self.footer_box.visible = false
self.current_rect_size = self.rect_size
self.rect_size = Vector2( 0, 0 )
$background.rect_size = Vector2( 0, 0 )
$background.rect_min_size = Vector2( 0, 0 )
else:
self.header_box.get_node( "header/close" ).visible = false
self.header_box.get_node( "header/open" ).visible = false
self.content_box.visible = false
self.footer_box.visible = false
self.current_rect_size = self.rect_size
self.rect_size = Vector2( 0, 0 )
$background.rect_size = Vector2( 0, 0 )
$background.rect_min_size = Vector2( 0, 0 )
func _on_Close_pressed():
close()
close()
func open():
if not is_borderless:
header_box.get_node( "header/close" ).visible = true
header_box.get_node( "header/open" ).visible = false
content_box.visible = true
footer_box.visible = true
self.rect_size = current_rect_size
else:
header_box.get_node( "header/close" ).visible = false
header_box.get_node( "header/open" ).visible = false
content_box.visible = true
footer_box.visible = true
self.rect_size = current_rect_size
if not is_borderless:
header_box.get_node( "header/close" ).visible = true
header_box.get_node( "header/open" ).visible = false
content_box.visible = true
footer_box.visible = true
self.rect_size = current_rect_size
else:
header_box.get_node( "header/close" ).visible = false
header_box.get_node( "header/open" ).visible = false
content_box.visible = true
footer_box.visible = true
self.rect_size = current_rect_size
func _on_Open_pressed():
open()
open()
func _on_Resize_pressed():
is_resizing = true
is_resizing = true
func _input( event ):
if is_resizable:
if is_resizing and event is InputEventMouseButton and not event.pressed:
is_resizing = false
if event is InputEventMouseMotion and is_resizing:
var delta = event.relative
self.rect_size += delta
size_changed = true
if is_resizable:
if is_resizing and event is InputEventMouseButton and not event.pressed:
is_resizing = false
if event is InputEventMouseMotion and is_resizing:
var delta = event.relative
self.rect_size += delta
size_changed = true
func check_if_clicked( event ):
if not is_moving and event is InputEventMouseButton and event.is_pressed() and not event.is_echo() and event.button_index == 1 :
emit_signal( "window_clicked", self )
if not is_moving and event is InputEventMouseButton and event.is_pressed() and not event.is_echo() and event.button_index == 1 :
emit_signal( "window_clicked", self )
func _on_Header_gui_input( event ):
check_if_clicked( event )
check_if_clicked( event )
if self.is_dragged_by_header_only:
if is_movable:
if is_moving and event is InputEventMouseButton and not event.pressed:
is_moving = false
elif not is_moving and event is InputEventMouseButton and event.pressed:
is_moving = true
if event is InputEventMouseMotion and is_moving:
var delta = event.relative
self.rect_position += delta
if self.is_dragged_by_header_only:
if is_movable:
if is_moving and event is InputEventMouseButton and not event.pressed:
is_moving = false
elif not is_moving and event is InputEventMouseButton and event.pressed:
is_moving = true
if event is InputEventMouseMotion and is_moving:
var delta = event.relative
self.rect_position += delta
func _on_window_gui_input( event ):
check_if_clicked( event )
if not self.is_dragged_by_header_only:
if is_movable:
if is_moving and event is InputEventMouseButton and not event.pressed:
is_moving = false
elif not is_moving and event is InputEventMouseButton and event.pressed:
is_moving = true
if event is InputEventMouseMotion and is_moving:
var delta = event.relative
self.rect_position += delta
check_if_clicked( event )
if not self.is_dragged_by_header_only:
if is_movable:
if is_moving and event is InputEventMouseButton and not event.pressed:
is_moving = false
elif not is_moving and event is InputEventMouseButton and event.pressed:
is_moving = true
if event is InputEventMouseMotion and is_moving:
var delta = event.relative
self.rect_position += delta
func load_from_file( config_file ):
if config_file.has_section( self.name ):
self.rect_position = config_file.get_value( self.name, "position" )
self.rect_size = config_file.get_value( self.name, "size" )
self.is_borderless = config_file.get_value( self.name, "borderless" )
current_rect_position = self.rect_position
current_rect_size = self.rect_size
if config_file.get_value( self.name, "opened" ):
open()
else:
close()
if config_file.has_section( self.name ):
self.rect_position = config_file.get_value( self.name, "position" )
self.rect_size = config_file.get_value( self.name, "size" )
self.is_borderless = config_file.get_value( self.name, "borderless" )
current_rect_position = self.rect_position
current_rect_size = self.rect_size
if config_file.get_value( self.name, "opened" ):
open()
else:
close()
func save_to_file( config_file ):
var is_open = content_box.visible
var is_open = content_box.visible
config_file.set_value(self.name, "position", self.rect_position)
config_file.set_value(self.name, "position", self.rect_position)
if not is_open:
config_file.set_value(self.name, "size", current_rect_size)
else:
config_file.set_value(self.name, "size", self.rect_size)
if not is_open:
config_file.set_value(self.name, "size", current_rect_size)
else:
config_file.set_value(self.name, "size", self.rect_size)
if is_open:
config_file.set_value(self.name, "opened", true)
else:
config_file.set_value(self.name, "opened", false)
if is_open:
config_file.set_value(self.name, "opened", true)
else:
config_file.set_value(self.name, "opened", false)
config_file.set_value(self.name, "borderless", is_borderless)
config_file.set_value(self.name, "borderless", is_borderless)

BIN
assets/fonts/IMMORTAL.ttf Normal file

Binary file not shown.

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 62 KiB

View file

@ -69,7 +69,7 @@ config/icon="res://icon.png"
[autoload]
Creatures="*res://ressources/scripts/creatures_old.gd"
Creatures="*res://ressources/scripts/creatures.gd"
MusicManager="*res://scenes/interfaces/music_manager/music_manager.tscn"
Connection="*res://scenes/connection/connection.tscn"
Globals="*res://ressources/scripts/global.gd"

View file

@ -0,0 +1,85 @@
extends Node
class Creature_old2:
enum Sex { F, M, H, A, U }
var type
var pseudonym
func _init( p_pseudonym = "Créature" ):
self.type = "creature"
self.pseudonym = p_pseudonym
class Ra_old2 extends Creature_old2:
var sex = Creature_old2.Sex.F
var female_boobs = 0.0
var female_hip = 0.0
var male_pack = 0.0
var male_throat = 0.0
var female_pregnant = 0.0
var color = Color( 1.0, 1.0, 1.0 )
var douleur = 0.0
var trauma = 0.0
var oubli = 0.0
func _init( p_pseudonym = "Créature" ):
self.type = "ra"
self.pseudonym = p_pseudonym
func to_dictionary():
var dictionary = Dictionary()
dictionary[ "type" ] = self.type
dictionary[ "pseudonym" ] = self.pseudonym
dictionary[ "sex" ] = var2str( self.sex )
dictionary[ "female_boobs" ] = var2str( self.female_boobs )
dictionary[ "female_hip" ] = var2str( self.female_hip )
dictionary[ "male_pack" ] = var2str( self.male_pack )
dictionary[ "male_throat" ] = var2str( self.male_throat )
dictionary[ "female_pregnant" ] = var2str( self.female_pregnant )
dictionary[ "color" ] = var2str( self.color )
return dictionary
func from_dictionary( dictionary ):
self.pseudonym = dictionary.get( "pseudonym", self.pseudonym )
self.sex = dictionary.get( "sex", self.sex )
self.female_boobs = dictionary.get( "female_boobs", self.female_boobs )
self.female_hip = dictionary.get( "female_hip", self.female_hip )
self.male_pack = dictionary.get( "male_pack", self.male_pack )
self.male_throat = dictionary.get( "male_throat", self.male_throat )
self.female_pregnant = dictionary.get( "female_pregnant", self.female_pregnant )
self.color = dictionary.get( "color", self.color )
func from_file( filename ):
var file = File.new()
if file.file_exists( "user://creatures/" + filename ):
file.open( "user://creatures/" + filename, File.READ )
var lines = ""
while not file.eof_reached():
var current_line = file.get_line()
lines += current_line
var json = JSON.parse( lines ).result
var dict = {}
for data in json:
dict[ data ] = str2var( json[data] )
self.from_dictionary( dict )
file.close()

View file

@ -5,5 +5,5 @@ class_name Creature_old
func from_dict( datas ):
pass
pass

View file

@ -1,85 +0,0 @@
extends Node
class Creature_old2:
enum Sex { F, M, H, A, U }
var type
var pseudonym
func _init( p_pseudonym = "Créature" ):
self.type = "creature"
self.pseudonym = p_pseudonym
class Ra_old2 extends Creature_old2:
var sex = Creature_old2.Sex.F
var female_boobs = 0.0
var female_hip = 0.0
var male_pack = 0.0
var male_throat = 0.0
var female_pregnant = 0.0
var color = Color( 1.0, 1.0, 1.0 )
var douleur = 0.0
var trauma = 0.0
var oubli = 0.0
func _init( p_pseudonym = "Créature" ):
self.type = "ra"
self.pseudonym = p_pseudonym
func to_dictionary():
var dictionary = Dictionary()
dictionary[ "type" ] = self.type
dictionary[ "pseudonym" ] = self.pseudonym
dictionary[ "sex" ] = var2str( self.sex )
dictionary[ "female_boobs" ] = var2str( self.female_boobs )
dictionary[ "female_hip" ] = var2str( self.female_hip )
dictionary[ "male_pack" ] = var2str( self.male_pack )
dictionary[ "male_throat" ] = var2str( self.male_throat )
dictionary[ "female_pregnant" ] = var2str( self.female_pregnant )
dictionary[ "color" ] = var2str( self.color )
return dictionary
func from_dictionary( dictionary ):
self.pseudonym = dictionary.get( "pseudonym", self.pseudonym )
self.sex = dictionary.get( "sex", self.sex )
self.female_boobs = dictionary.get( "female_boobs", self.female_boobs )
self.female_hip = dictionary.get( "female_hip", self.female_hip )
self.male_pack = dictionary.get( "male_pack", self.male_pack )
self.male_throat = dictionary.get( "male_throat", self.male_throat )
self.female_pregnant = dictionary.get( "female_pregnant", self.female_pregnant )
self.color = dictionary.get( "color", self.color )
func from_file( filename ):
var file = File.new()
if file.file_exists( "user://creatures/" + filename ):
file.open( "user://creatures/" + filename, File.READ )
var lines = ""
while not file.eof_reached():
var current_line = file.get_line()
lines += current_line
var json = JSON.parse( lines ).result
var dict = {}
for data in json:
dict[ data ] = str2var( json[data] )
self.from_dictionary( dict )
file.close()

View file

@ -7,29 +7,29 @@ var player_name = null
var ressource_queue = preload("res://ressources/scripts/resource_queue.gd").new()
enum RACE {
human
human
}
var race_label = [ "Humain" ]
func get_race_id( p_label ):
return race_label.find( p_label )
return race_label.find( p_label )
enum SEX {
female,
male
female,
male
}
var sex_label = [ "Femme", "Homme" ]
func get_sex_id( p_label ):
return race_label.find( p_label )
return race_label.find( p_label )
enum CREATURES_EDITOR_MODE {
player,
npc
player,
npc
}
var creatures_editor_mode = CREATURES_EDITOR_MODE.player
func goto_scene( path ):
self.get_tree().get_root().get_node("main").goto_scene( path )
self.get_tree().get_root().get_node("main").goto_scene( path )

View file

@ -1,30 +1,30 @@
class nel_login_message:
var _cmd;
var _login;
var _password;
var _clientApplication;
var _cp;
var _lg;
var _cmd;
var _login;
var _password;
var _clientApplication;
var _cp;
var _lg;
func _init(cmd, login, password, clientApplication, cp, lg):
self._cmd = cmd;
self._login = login;
self._password = password;
self._clientApplication = clientApplication;
self._cp = cp;
self._lg = lg;
func _init(cmd, login, password, clientApplication, cp, lg):
self._cmd = cmd;
self._login = login;
self._password = password;
self._clientApplication = clientApplication;
self._cp = cp;
self._lg = lg;
func get_request_string():
var request_string = "cmd=" + self._cmd;
if self._login != "":
request_string += "&login=" + self._login;
if self._password != "":
request_string += "&password=" + self._password;
if self._clientApplication != "":
request_string += "&clientApplication=" + self._clientApplication;
if self._cp != "":
request_string += "&cp=" + self._cp;
if self._lg != "":
request_string += "&lg=" + self._lg;
func get_request_string():
var request_string = "cmd=" + self._cmd;
if self._login != "":
request_string += "&login=" + self._login;
if self._password != "":
request_string += "&password=" + self._password;
if self._clientApplication != "":
request_string += "&clientApplication=" + self._clientApplication;
if self._cp != "":
request_string += "&cp=" + self._cp;
if self._lg != "":
request_string += "&lg=" + self._lg;
return request_string;
return request_string;

View file

@ -1,19 +1,19 @@
class nel_server_info:
var _cookie;
var _shardIp;
var _ringStartAdress;
var _ringAddress;
var _patchVersion
var _backupPatchUrls;
var _patchUrls;
var _cookie;
var _shardIp;
var _ringStartAdress;
var _ringAddress;
var _patchVersion
var _backupPatchUrls;
var _patchUrls;
func _init(connexionResultString):
var params = connexionResultString.split('#');
var temp = params[4].split('\n')
self._cookie = params[1];
self._shardIp = params[2];
self._ringStartAdress = params[3];
self._ringAddress = temp[0];
self._patchVersion = temp[1];
self._backupPatchUrls = params[5];
self._patchUrls = params[6];
func _init(connexionResultString):
var params = connexionResultString.split('#');
var temp = params[4].split('\n')
self._cookie = params[1];
self._shardIp = params[2];
self._ringStartAdress = params[3];
self._ringAddress = temp[0];
self._patchVersion = temp[1];
self._backupPatchUrls = params[5];
self._patchUrls = params[6];

View file

@ -8,138 +8,138 @@ var queue = []
var pending = {}
func _lock(_caller):
mutex.lock()
mutex.lock()
func _unlock(_caller):
mutex.unlock()
mutex.unlock()
func _post(_caller):
sem.post()
sem.post()
func _wait(_caller):
sem.wait()
sem.wait()
func queue_resource(path, p_in_front = false):
_lock("queue_resource")
if path in pending:
_unlock("queue_resource")
return
elif ResourceLoader.has_cached(path):
var res = ResourceLoader.load(path)
pending[path] = res
_unlock("queue_resource")
return
else:
var res = ResourceLoader.load_interactive(path)
res.set_meta("path", path)
if p_in_front:
queue.insert(0, res)
else:
queue.push_back(res)
pending[path] = res
_post("queue_resource")
_unlock("queue_resource")
return
_lock("queue_resource")
if path in pending:
_unlock("queue_resource")
return
elif ResourceLoader.has_cached(path):
var res = ResourceLoader.load(path)
pending[path] = res
_unlock("queue_resource")
return
else:
var res = ResourceLoader.load_interactive(path)
res.set_meta("path", path)
if p_in_front:
queue.insert(0, res)
else:
queue.push_back(res)
pending[path] = res
_post("queue_resource")
_unlock("queue_resource")
return
func cancel_resource(path):
_lock("cancel_resource")
if path in pending:
if pending[path] is ResourceInteractiveLoader:
queue.erase(pending[path])
pending.erase(path)
_unlock("cancel_resource")
_lock("cancel_resource")
if path in pending:
if pending[path] is ResourceInteractiveLoader:
queue.erase(pending[path])
pending.erase(path)
_unlock("cancel_resource")
func get_progress(path):
_lock("get_progress")
var ret = -1
if path in pending:
if pending[path] is ResourceInteractiveLoader:
ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
else:
ret = 1.0
_unlock("get_progress")
return ret
_lock("get_progress")
var ret = -1
if path in pending:
if pending[path] is ResourceInteractiveLoader:
ret = float(pending[path].get_stage()) / float(pending[path].get_stage_count())
else:
ret = 1.0
_unlock("get_progress")
return ret
func is_ready(path):
var ret
_lock("is_ready")
if path in pending:
ret = !(pending[path] is ResourceInteractiveLoader)
else:
ret = false
_unlock("is_ready")
return ret
var ret
_lock("is_ready")
if path in pending:
ret = !(pending[path] is ResourceInteractiveLoader)
else:
ret = false
_unlock("is_ready")
return ret
func _wait_for_resource(res, path):
_unlock("wait_for_resource")
while true:
VisualServer.sync()
OS.delay_usec(16000) # Wait approximately 1 frame.
_lock("wait_for_resource")
if queue.size() == 0 || queue[0] != res:
return pending[path]
_unlock("wait_for_resource")
_unlock("wait_for_resource")
while true:
VisualServer.sync()
OS.delay_usec(16000) # Wait approximately 1 frame.
_lock("wait_for_resource")
if queue.size() == 0 || queue[0] != res:
return pending[path]
_unlock("wait_for_resource")
func get_resource(path):
_lock("get_resource")
if path in pending:
if pending[path] is ResourceInteractiveLoader:
var res = pending[path]
if res != queue[0]:
var pos = queue.find(res)
queue.remove(pos)
queue.insert(0, res)
_lock("get_resource")
if path in pending:
if pending[path] is ResourceInteractiveLoader:
var res = pending[path]
if res != queue[0]:
var pos = queue.find(res)
queue.remove(pos)
queue.insert(0, res)
res = _wait_for_resource(res, path)
pending.erase(path)
_unlock("return")
return res
else:
var res = pending[path]
pending.erase(path)
_unlock("return")
return res
else:
_unlock("return")
return ResourceLoader.load(path)
res = _wait_for_resource(res, path)
pending.erase(path)
_unlock("return")
return res
else:
var res = pending[path]
pending.erase(path)
_unlock("return")
return res
else:
_unlock("return")
return ResourceLoader.load(path)
func thread_process():
_wait("thread_process")
_lock("process")
_wait("thread_process")
_lock("process")
while queue.size() > 0:
var res = queue[0]
_unlock("process_poll")
var ret = res.poll()
_lock("process_check_queue")
while queue.size() > 0:
var res = queue[0]
_unlock("process_poll")
var ret = res.poll()
_lock("process_check_queue")
if ret == ERR_FILE_EOF || ret != OK:
var path = res.get_meta("path")
if path in pending: # Else, it was already retrieved.
pending[res.get_meta("path")] = res.get_resource()
# Something might have been put at the front of the queue while
# we polled, so use erase instead of remove.
queue.erase(res)
_unlock("process")
if ret == ERR_FILE_EOF || ret != OK:
var path = res.get_meta("path")
if path in pending: # Else, it was already retrieved.
pending[res.get_meta("path")] = res.get_resource()
# Something might have been put at the front of the queue while
# we polled, so use erase instead of remove.
queue.erase(res)
_unlock("process")
func thread_func(_u):
while true:
thread_process()
while true:
thread_process()
func start():
mutex = Mutex.new()
sem = Semaphore.new()
thread = Thread.new()
thread.start(self, "thread_func", 0)
mutex = Mutex.new()
sem = Semaphore.new()
thread = Thread.new()
thread.start(self, "thread_func", 0)

View file

@ -35,268 +35,268 @@ var direction = Vector3.ZERO
var orientation = 0.0
enum PLAYER_RELATION {
neutre,
friend,
ennemy
neutre,
friend,
ennemy
}
export( PLAYER_RELATION ) var player_relation = PLAYER_RELATION.neutre
export( String ) var creature_filename = null setget set_creature_filename
func set_creature_filename( p_filename ):
creature_filename = p_filename
self.load_from_name( p_filename )
creature_filename = p_filename
self.load_from_name( p_filename )
func _process( delta ):
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = $look_at.global_transform.basis.z * direction.z
var right: Vector3 = $look_at.global_transform.basis.x * direction.x
if forwards:
right = Vector3.ZERO
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = $look_at.global_transform.basis.z * direction.z
var right: Vector3 = $look_at.global_transform.basis.x * direction.x
if forwards:
right = Vector3.ZERO
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# Rotation.
if (self.has_node( "creature" ) and $creature.can_turn()) or self.is_readying_weapon or self.is_weapon_ready:
self.rotate_y( rotation_speed_factor * orientation )
# Rotation.
if (self.has_node( "creature" ) and $creature.can_turn()) or self.is_readying_weapon or self.is_weapon_ready:
self.rotate_y( rotation_speed_factor * orientation )
# Movement.
velocity = self.calculate_velocity(velocity, move_direction, delta)
if not self.is_readying_weapon and not self.is_weapon_ready:
if not self.is_jumping and not self.is_jump_started and not self.is_falling:
velocity = self.move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true)
else:
velocity = self.move_and_slide(velocity, Vector3.UP, true)
# Animation.
if self.has_node( "creature" ):
if self.is_dead:
$creature.play( "dead_loop" )
elif self.is_dying:
$creature.play( "dying", 2.0 )
elif self.is_readying_weapon:
$creature.play( "1h_pistol_ready_start" )
elif self.is_weapon_ready:
$creature.play( "1h_pistol_ready_loop" )
elif direction and not self.is_jump_started and not self.is_jumping and not self.is_falling:
if direction.z < 0.0:
if self.is_running:
$creature.play( "run" , 2.0 )
else:
$creature.play( "walk" )
elif direction.z > 0.0:
if self.is_running:
$creature.play_backwards( "run", 2.0 )
else:
$creature.play_backwards( "walk" )
elif direction.x > 0.0:
$creature.play( "strafe_right" )
elif direction.x < 0.0:
$creature.play( "strafe_left" )
elif self.is_jump_started and not self.is_jumping:
$creature.play( "jump_start" )
elif self.is_jumping or self.is_falling:
if not self.is_on_ground:
$creature.play( "jump_loop" )
else:
$creature.play( "jump_end", 2 )
elif not self.orientation == 0.0:
if self.orientation < 0.0:
$creature.play( "turn_right", 2.0 )
elif self.orientation > 0.0:
$creature.play( "turn_left", 2.0 )
else:
$creature.play( "idle" )
# Movement.
velocity = self.calculate_velocity(velocity, move_direction, delta)
if not self.is_readying_weapon and not self.is_weapon_ready:
if not self.is_jumping and not self.is_jump_started and not self.is_falling:
velocity = self.move_and_slide_with_snap(velocity, Vector3.DOWN, Vector3.UP, true)
else:
velocity = self.move_and_slide(velocity, Vector3.UP, true)
# Animation.
if self.has_node( "creature" ):
if self.is_dead:
$creature.play( "dead_loop" )
elif self.is_dying:
$creature.play( "dying", 2.0 )
elif self.is_readying_weapon:
$creature.play( "1h_pistol_ready_start" )
elif self.is_weapon_ready:
$creature.play( "1h_pistol_ready_loop" )
elif direction and not self.is_jump_started and not self.is_jumping and not self.is_falling:
if direction.z < 0.0:
if self.is_running:
$creature.play( "run" , 2.0 )
else:
$creature.play( "walk" )
elif direction.z > 0.0:
if self.is_running:
$creature.play_backwards( "run", 2.0 )
else:
$creature.play_backwards( "walk" )
elif direction.x > 0.0:
$creature.play( "strafe_right" )
elif direction.x < 0.0:
$creature.play( "strafe_left" )
elif self.is_jump_started and not self.is_jumping:
$creature.play( "jump_start" )
elif self.is_jumping or self.is_falling:
if not self.is_on_ground:
$creature.play( "jump_loop" )
else:
$creature.play( "jump_end", 2 )
elif not self.orientation == 0.0:
if self.orientation < 0.0:
$creature.play( "turn_right", 2.0 )
elif self.orientation > 0.0:
$creature.play( "turn_left", 2.0 )
else:
$creature.play( "idle" )
func calculate_velocity(
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
# var velocity_new := move_direction
var velocity_new = Vector3.ZERO
if not self.is_jump_started:
velocity_new = move_direction
var velocity_new = Vector3.ZERO
if not self.is_jump_started:
velocity_new = move_direction
if self.is_running:
velocity_new *= run_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
if self.is_jumping:
velocity_new.y += self.jump_strength * delta
self.is_jumping = false
self.is_falling = true
if self.is_falling:
velocity_new.x *= 2.0
velocity_new.z *= 2.0
if self.is_running:
velocity_new *= run_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
if self.is_jumping:
velocity_new.y += self.jump_strength * delta
self.is_jumping = false
self.is_falling = true
if self.is_falling:
velocity_new.x *= 2.0
velocity_new.z *= 2.0
return velocity_new
return velocity_new
func load_from_name( p_name, p_emplacement = null ):
var creature = Datas.Creature.new()
creature.set_data( "name", p_name )
creature.load( null, p_emplacement )
if creature.get_data( "race" ) == Globals.RACE.human:
if creature.get_data( "sex" ) == Globals.SEX.female:
self.change_creature( "res://scenes/creatures/human/human_female.tscn" )
elif creature.get_data( "sex" ) == Globals.SEX.male:
self.change_creature( "res://scenes/creatures/human/human_male.tscn" )
if $creature:
$creature.load_from_name( p_name, p_emplacement )
var creature = Datas.Creature.new()
creature.set_data( "name", p_name )
creature.load( null, p_emplacement )
if creature.get_data( "race" ) == Globals.RACE.human:
if creature.get_data( "sex" ) == Globals.SEX.female:
self.change_creature( "res://scenes/creatures/human/human_female.tscn" )
elif creature.get_data( "sex" ) == Globals.SEX.male:
self.change_creature( "res://scenes/creatures/human/human_male.tscn" )
if $creature:
$creature.load_from_name( p_name, p_emplacement )
func change_creature( new_model_path ):
if $creature:
var old_model = $creature
self.remove_child( old_model )
old_model.queue_free()
var new_model = load( new_model_path )
if new_model:
new_model = new_model.instance()
new_model.name = "creature"
self.add_child( new_model )
new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
new_model.duplicate_meshes()
if $creature:
var old_model = $creature
self.remove_child( old_model )
old_model.queue_free()
var new_model = load( new_model_path )
if new_model:
new_model = new_model.instance()
new_model.name = "creature"
self.add_child( new_model )
new_model.connect( "animation_finished", self, "_on_creature_animation_finished" )
new_model.duplicate_meshes()
func set_blend_shape( p_blend_shape_name, p_value ):
$creature.set_blend_shape( p_blend_shape_name, p_value )
$creature.set_blend_shape( p_blend_shape_name, p_value )
func _on_ground_area_body_entered(body):
if not body == self:
self.ground_contacts += 1
if self.ground_contacts > 0:
if not body == self:
self.ground_contacts += 1
if self.ground_contacts > 0:
# self.is_falling = false
self.is_on_ground = true
self.is_on_ground = true
func _on_ground_area_body_exited(body):
if not body == self:
self.ground_contacts -= 1
if self.ground_contacts <= 0:
self.is_falling = true
self.is_on_ground = false
if not body == self:
self.ground_contacts -= 1
if self.ground_contacts <= 0:
self.is_falling = true
self.is_on_ground = false
func _on_creature_animation_finished(anim_name):
if anim_name == "jump_start":
self.is_jump_started = false
self.is_jumping = true
elif anim_name == "jump_end":
self.is_falling = false
elif anim_name == "turn_right":
self.can_turn = false
elif anim_name == "turn_left":
self.can_turn = false
elif anim_name == "1h_pistol_ready_start":
self.is_readying_weapon = false
self.is_weapon_ready = true
elif anim_name == "dying":
self.is_dying = false
self.is_dead = true
if anim_name == "jump_start":
self.is_jump_started = false
self.is_jumping = true
elif anim_name == "jump_end":
self.is_falling = false
elif anim_name == "turn_right":
self.can_turn = false
elif anim_name == "turn_left":
self.can_turn = false
elif anim_name == "1h_pistol_ready_start":
self.is_readying_weapon = false
self.is_weapon_ready = true
elif anim_name == "dying":
self.is_dying = false
self.is_dead = true
func set_focus( p_focus = true ):
if p_focus:
$focus.show()
if self.player_relation == PLAYER_RELATION.neutre:
$focus.get_surface_material( 0 ).albedo_color = Color.white
elif self.player_relation == PLAYER_RELATION.friend:
$focus.get_surface_material( 0 ).albedo_color = Color.green
elif self.player_relation == PLAYER_RELATION.ennemy:
$focus.get_surface_material( 0 ).albedo_color = Color.red
else:
$focus.hide()
if p_focus:
$focus.show()
if self.player_relation == PLAYER_RELATION.neutre:
$focus.get_surface_material( 0 ).albedo_color = Color.white
elif self.player_relation == PLAYER_RELATION.friend:
$focus.get_surface_material( 0 ).albedo_color = Color.green
elif self.player_relation == PLAYER_RELATION.ennemy:
$focus.get_surface_material( 0 ).albedo_color = Color.red
else:
$focus.hide()
func get_weapons():
var weapons = []
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item )
var weapons = []
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item )
if not weapons.size() > 0:
if Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item )
if Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item )
return weapons
if not weapons.size() > 0:
if Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item )
if Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
weapons.push_back( $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item )
return weapons
func get_main_weapon_node():
var weapon = null
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
if $creature/body_parts/body/skeleton/attachment_hand_L/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
return weapon
var weapon = null
if Datas.Equipment.SLOT.weapon_hands in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_right in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item:
if $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
if not weapon and Datas.Equipment.SLOT.weapon_hand_left in $creature.slots:
if $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item:
if $creature/body_parts/body/skeleton/attachment_hand_L/handle.get_children().size() > 0:
weapon = $creature/body_parts/body/skeleton/attachment_hand_R/handle.get_children()[0]
return weapon
func attack():
if self.can_attack:
var weapon = null
var attachment = null
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].attachment
if self.can_attack:
var weapon = null
var attachment = null
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_right ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hand_left ].attachment
if not weapon:
weapon = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].item
attachment = $creature.slots[ Datas.Equipment.SLOT.weapon_hands ].attachment
if weapon:
print( "pan " + str(weapon.get_data( "damage" )) )
if weapon:
print( "pan " + str(weapon.get_data( "damage" )) )
var weapon_node = $creature/body_parts/body/skeleton.get_node( attachment )
if weapon_node:
weapon_node = weapon_node.get_node( "handle" ).get_children()[0]
var weapon_node = $creature/body_parts/body/skeleton.get_node( attachment )
if weapon_node:
weapon_node = weapon_node.get_node( "handle" ).get_children()[0]
# if weapon_node is preload( "res://scenes/items/equipments/weapons/firearm.gd" ):
# weapon_node.fire( self, [self] )
#
self.can_attack = false
$attack_delay.start()
self.can_attack = false
$attack_delay.start()
func hit( p_damage, p_from = null ):
$creature.creature.set_data( "current_life", $creature.creature.get_data( "current_life" )-p_damage )
$head_infos_viewport/head_infos/bars/life.max_value = $creature.creature.get_max_life()
$head_infos_viewport/head_infos/bars/life.value = $creature.creature.get_data( "current_life", 0 )
$creature.creature.set_data( "current_life", $creature.creature.get_data( "current_life" )-p_damage )
$head_infos_viewport/head_infos/bars/life.max_value = $creature.creature.get_max_life()
$head_infos_viewport/head_infos/bars/life.value = $creature.creature.get_data( "current_life", 0 )
func die():
self.is_dying = true
self.is_dying = true
func _on_creature_equip(p_slot, p_item):
var weapons = self.get_weapons()
if weapons.size() > 0:
var max_delay = null
for weapon in weapons:
if not max_delay:
max_delay = weapon.get_data( "attack_delay" )
else:
max_delay = max( max_delay, weapon.get_data( "attack_delay" ) )
$attack_delay.wait_time = max_delay
emit_signal( "equip", p_slot, p_item )
var weapons = self.get_weapons()
if weapons.size() > 0:
var max_delay = null
for weapon in weapons:
if not max_delay:
max_delay = weapon.get_data( "attack_delay" )
else:
max_delay = max( max_delay, weapon.get_data( "attack_delay" ) )
$attack_delay.wait_time = max_delay
emit_signal( "equip", p_slot, p_item )
func _on_creature_unequip(p_slot):
emit_signal( "unequip", p_slot )
emit_signal( "unequip", p_slot )
func _on_attack_delay_timeout():
self.can_attack = true
self.can_attack = true
func _on_creature_is_dead():
self.die()
self.die()

View file

@ -4,31 +4,31 @@ signal connection_ok
signal connection_error( message )
func do_request(username, password):
var message = load("res://ressources/scripts/nel/nel_login_message.gd")
if message:
message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en");
# $http_request.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string());
$http_request.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string());
var message = load("res://ressources/scripts/nel/nel_login_message.gd")
if message:
message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en");
# $http_request.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string());
$http_request.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string());
func _make_post_request(url, data_to_send, use_ssl):
# Convert data to json string:
var query = JSON.print(data_to_send)
# Add 'Content-Type' header:
var headers = ["Content-Type: application/json"]
$http_request.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)
# Convert data to json string:
var query = JSON.print(data_to_send)
# Add 'Content-Type' header:
var headers = ["Content-Type: application/json"]
$http_request.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)
func _on_http_request_request_completed(result, response_code, headers, body):
print( response_code )
if ProjectSettings.get_setting("khanat/debug_mode"):
emit_signal( "connection_ok" )
elif not response_code == 200:
emit_signal( "connection_error", "Erreur de connexion." )
else:
var s = body.get_string_from_utf8().split(":")
if(s[0] != "0"):
var server_info_script = load("res://ressources/scripts/nel/nel_server_infos.gd");
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
emit_signal( "connection_ok" )
# No error so login was successful.
print( response_code )
if ProjectSettings.get_setting("khanat/debug_mode"):
emit_signal( "connection_ok" )
elif not response_code == 200:
emit_signal( "connection_error", "Erreur de connexion." )
else:
var s = body.get_string_from_utf8().split(":")
if(s[0] != "0"):
var server_info_script = load("res://ressources/scripts/nel/nel_server_infos.gd");
var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8());
emit_signal( "connection_ok" )
# No error so login was successful.

View file

@ -11,407 +11,407 @@ var eye_color_list = [ "blue_eye", "bluegreen_eye","brown_eye","deepblue_eye","g
class Slot:
var item = null
var attachment = null
func _init( p_attachment = null ):
self.attachment = p_attachment
var item = null
var attachment = null
func _init( p_attachment = null ):
self.attachment = p_attachment
var slots = { Datas.Equipment.SLOT.cloth_hand: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_face: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_head: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_torso: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_legs: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_feet: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_back: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.weapon_hand_right: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hand_left: Slot.new( "attachment_hand_L" )\
, Datas.Equipment.SLOT.weapon_hands: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hip_right: Slot.new( "attachment_hips_R" )\
, Datas.Equipment.SLOT.weapon_hip_left: Slot.new( "attachment_hips_L" )\
, Datas.Equipment.SLOT.weapon_back_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_back_left: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_left: Slot.new() }
, Datas.Equipment.SLOT.cloth_face: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_head: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_torso: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_legs: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_feet: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.cloth_back: Slot.new( "cloths" )\
, Datas.Equipment.SLOT.weapon_hand_right: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hand_left: Slot.new( "attachment_hand_L" )\
, Datas.Equipment.SLOT.weapon_hands: Slot.new( "attachment_hand_R" )\
, Datas.Equipment.SLOT.weapon_hip_right: Slot.new( "attachment_hips_R" )\
, Datas.Equipment.SLOT.weapon_hip_left: Slot.new( "attachment_hips_L" )\
, Datas.Equipment.SLOT.weapon_back_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_back_left: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_right: Slot.new()\
, Datas.Equipment.SLOT.weapon_holster_left: Slot.new() }
func _ready():
self.duplicate_meshes()
self.duplicate_meshes()
func duplicate_meshes():
for body in $body_parts.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
for body in $hair_parts.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
for body in $cloths.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
self.update()
for body in $body_parts.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
for body in $hair_parts.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
for body in $cloths.get_children():
for mesh in body.get_node( "skeleton" ).get_children():
if mesh is MeshInstance:
var new_mat = mesh.get( "material/0" ).duplicate()
var new_mesh = mesh.mesh.duplicate()
mesh.mesh = new_mesh
mesh.set( "material/0", new_mat )
self.update()
func set_blend_shape( p_blend_shape_name, p_value ):
for child in $body_parts.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
for child in $hair_parts.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
for child in $cloths.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
for child in $body_parts.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
for child in $hair_parts.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
for child in $cloths.get_children():
var skeleton = child.get_node( "skeleton" )
for node in skeleton.get_children():
if node is MeshInstance:
node.set( "blend_shapes/"+p_blend_shape_name, p_value )
func load_from_name( p_name, p_emplacement = "usr" ):
var new_creature = Datas.Human.new()
var name_split = p_name.split( "_" )
new_creature.set_data( "first_name", name_split[0] )
new_creature.set_data( "last_name", name_split[1] )
new_creature.load( null, p_emplacement )
self.creature = new_creature
self.update()
var new_creature = Datas.Human.new()
var name_split = p_name.split( "_" )
new_creature.set_data( "first_name", name_split[0] )
new_creature.set_data( "last_name", name_split[1] )
new_creature.load( null, p_emplacement )
self.creature = new_creature
self.update()
func update():
if self.creature:
if self.creature:
self.scale = Vector3( self.creature.get_data( "size" ), self.creature.get_data( "size" ), self.creature.get_data( "size" ) )
self.scale = Vector3( self.creature.get_data( "size" ), self.creature.get_data( "size" ), self.creature.get_data( "size" ) )
self.set_blend_shape( "caucasian", self.creature.get_data( "caucasian" ) )
self.set_blend_shape( "african", self.creature.get_data( "african" ) )
self.set_blend_shape( "asian", self.creature.get_data( "asian" ) )
self.set_blend_shape( "caucasian", self.creature.get_data( "caucasian" ) )
self.set_blend_shape( "african", self.creature.get_data( "african" ) )
self.set_blend_shape( "asian", self.creature.get_data( "asian" ) )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
if self.creature.get_data( "skin" ) == 0:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse.png" ) )
elif self.creature.get_data( "skin" ) == 1:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse3.png" ) )
elif self.creature.get_data( "skin" ) == 2:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_female_diffuse.png" ) )
elif self.creature.get_data( "sex" ) == Globals.SEX.male:
if self.creature.get_data( "skin" ) == 0:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse2.png" ) )
elif self.creature.get_data( "skin" ) == 1:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse3.png" ) )
elif self.creature.get_data( "skin" ) == 2:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_male_diffuse.png" ) )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
if self.creature.get_data( "skin" ) == 0:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse.png" ) )
elif self.creature.get_data( "skin" ) == 1:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_female_diffuse3.png" ) )
elif self.creature.get_data( "skin" ) == 2:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_female_diffuse.png" ) )
elif self.creature.get_data( "sex" ) == Globals.SEX.male:
if self.creature.get_data( "skin" ) == 0:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse2.png" ) )
elif self.creature.get_data( "skin" ) == 1:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_lightskinned_male_diffuse3.png" ) )
elif self.creature.get_data( "skin" ) == 2:
self.get_node( "body_parts/body/skeleton/body" ).get_surface_material( 0 ).set_shader_param( "texture_albedo", preload( "res://assets/creatures/human/textures/young_darkskinned_male_diffuse.png" ) )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
if self.creature.get_data( "hair" ) == 0:
self.get_node( "hair_parts/mh_human_female_hair" ).hide()
elif self.creature.get_data( "hair" ) == 1:
self.get_node( "hair_parts/mh_human_female_hair" ).show()
self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_001.png" )
elif self.creature.get_data( "hair" ) == 2:
self.get_node( "hair_parts/mh_human_female_hair" ).show()
self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_002.png" )
elif self.creature.get_data( "sex" ) == Globals.SEX.male:
if self.creature.get_data( "hair" ) == 0:
self.get_node( "hair_parts/mh_human_male_hair" ).hide()
elif self.creature.get_data( "hair" ) == 1:
self.get_node( "hair_parts/mh_human_male_hair" ).show()
self.get_node( "hair_parts/mh_human_male_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_male_hair.png" )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
if self.creature.get_data( "hair" ) == 0:
self.get_node( "hair_parts/mh_human_female_hair" ).hide()
elif self.creature.get_data( "hair" ) == 1:
self.get_node( "hair_parts/mh_human_female_hair" ).show()
self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_001.png" )
elif self.creature.get_data( "hair" ) == 2:
self.get_node( "hair_parts/mh_human_female_hair" ).show()
self.get_node( "hair_parts/mh_human_female_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_female_hair_002.png" )
elif self.creature.get_data( "sex" ) == Globals.SEX.male:
if self.creature.get_data( "hair" ) == 0:
self.get_node( "hair_parts/mh_human_male_hair" ).hide()
elif self.creature.get_data( "hair" ) == 1:
self.get_node( "hair_parts/mh_human_male_hair" ).show()
self.get_node( "hair_parts/mh_human_male_hair/skeleton/hair" ).get_surface_material( 0 ).albedo_texture = preload( "res://assets/creatures/human/textures/human_male_hair.png" )
for hair in $hair_parts.get_children():
if hair.has_node( "skeleton/hair" ) and hair.get_node( "skeleton/hair" ).get_surface_material( 0 ):
hair.get_node( "skeleton/hair" ).get_surface_material( 0 ).albedo_color = self.creature.get_data( "hair_color" )
for hair in $hair_parts.get_children():
if hair.has_node( "skeleton/hair" ) and hair.get_node( "skeleton/hair" ).get_surface_material( 0 ):
hair.get_node( "skeleton/hair" ).get_surface_material( 0 ).albedo_color = self.creature.get_data( "hair_color" )
if self.creature.get_data( "muscles" ) > 0.0:
self.set_blend_shape( "muscles_min", 0.0 )
self.set_blend_shape( "muscles_max", self.creature.get_data( "muscles" ) )
elif self.creature.get_data( "muscles" ) < 0.0:
self.set_blend_shape( "muscles_min", -self.creature.get_data( "muscles" ) )
self.set_blend_shape( "muscles_max", 0.0 )
else:
self.set_blend_shape( "muscles_min", 0.0 )
self.set_blend_shape( "muscles_max", 0.0 )
if self.creature.get_data( "muscles" ) > 0.0:
self.set_blend_shape( "muscles_min", 0.0 )
self.set_blend_shape( "muscles_max", self.creature.get_data( "muscles" ) )
elif self.creature.get_data( "muscles" ) < 0.0:
self.set_blend_shape( "muscles_min", -self.creature.get_data( "muscles" ) )
self.set_blend_shape( "muscles_max", 0.0 )
else:
self.set_blend_shape( "muscles_min", 0.0 )
self.set_blend_shape( "muscles_max", 0.0 )
if self.creature.get_data( "fat" ) > 0.0:
self.set_blend_shape( "fat_min", 0.0 )
self.set_blend_shape( "fat_max", self.creature.get_data( "fat" ) )
elif self.creature.get_data( "fat" ) < 0.0:
self.set_blend_shape( "fat_min", -self.creature.get_data( "fat" ) )
self.set_blend_shape( "fat_max", 0.0 )
else:
self.set_blend_shape( "fat_min", 0.0 )
self.set_blend_shape( "fat_max", 0.0 )
if self.creature.get_data( "fat" ) > 0.0:
self.set_blend_shape( "fat_min", 0.0 )
self.set_blend_shape( "fat_max", self.creature.get_data( "fat" ) )
elif self.creature.get_data( "fat" ) < 0.0:
self.set_blend_shape( "fat_min", -self.creature.get_data( "fat" ) )
self.set_blend_shape( "fat_max", 0.0 )
else:
self.set_blend_shape( "fat_min", 0.0 )
self.set_blend_shape( "fat_max", 0.0 )
if self.creature.get_data( "proportion" ) > 0.0:
self.set_blend_shape( "proportion_min", 0.0 )
self.set_blend_shape( "proportion_max", self.creature.get_data( "proportion" ) )
elif self.creature.get_data( "proportion" ) < 0.0:
self.set_blend_shape( "proportion_min", -self.creature.get_data( "proportion" ) )
self.set_blend_shape( "proportion_max", 0.0 )
else:
self.set_blend_shape( "proportion_min", 0.0 )
self.set_blend_shape( "proportion_max", 0.0 )
if self.creature.get_data( "proportion" ) > 0.0:
self.set_blend_shape( "proportion_min", 0.0 )
self.set_blend_shape( "proportion_max", self.creature.get_data( "proportion" ) )
elif self.creature.get_data( "proportion" ) < 0.0:
self.set_blend_shape( "proportion_min", -self.creature.get_data( "proportion" ) )
self.set_blend_shape( "proportion_max", 0.0 )
else:
self.set_blend_shape( "proportion_min", 0.0 )
self.set_blend_shape( "proportion_max", 0.0 )
if self.creature.get_data( "breast" ) > 0.0:
self.set_blend_shape( "breast_min", 0.0 )
self.set_blend_shape( "breast_max", self.creature.get_data( "breast" ) )
elif self.creature.get_data( "breast" ) < 0.0:
self.set_blend_shape( "breast_min", -self.creature.get_data( "breast" ) )
self.set_blend_shape( "breast_max", 0.0 )
else:
self.set_blend_shape( "breast_min", 0.0 )
self.set_blend_shape( "breast_max", 0.0 )
if self.creature.get_data( "breast" ) > 0.0:
self.set_blend_shape( "breast_min", 0.0 )
self.set_blend_shape( "breast_max", self.creature.get_data( "breast" ) )
elif self.creature.get_data( "breast" ) < 0.0:
self.set_blend_shape( "breast_min", -self.creature.get_data( "breast" ) )
self.set_blend_shape( "breast_max", 0.0 )
else:
self.set_blend_shape( "breast_min", 0.0 )
self.set_blend_shape( "breast_max", 0.0 )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
self.set_blend_shape( "pregnancy", self.creature.get_data( "pregnancy" ) )
if self.creature.get_data( "sex" ) == Globals.SEX.female:
self.set_blend_shape( "pregnancy", self.creature.get_data( "pregnancy" ) )
# Skin tone.
if self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) and self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) is ShaderMaterial:
var color = self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).get_shader_param( "albedo" )
color.v = 1.0 - self.creature.get_data( "skin_tone" )
self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).set_shader_param( "albedo", color )
# Skin tone.
if self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) and self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ) is ShaderMaterial:
var color = self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).get_shader_param( "albedo" )
color.v = 1.0 - self.creature.get_data( "skin_tone" )
self.get_node( "body_parts/body/skeleton/body" ).get( "material/0" ).set_shader_param( "albedo", color )
self.set_blend_shape( "cleft_chin", self.creature.get_data( "cleft_chin" ) )
self.set_blend_shape( "chin_angle", self.creature.get_data( "chin_angle" ) )
self.set_blend_shape( "cleft_chin", self.creature.get_data( "cleft_chin" ) )
self.set_blend_shape( "chin_angle", self.creature.get_data( "chin_angle" ) )
if self.creature.get_data( "mouth_horiz" ) > 0.0:
self.set_blend_shape( "mouth_horiz_min", 0.0 )
self.set_blend_shape( "mouth_horiz_max", self.creature.get_data( "mouth_horiz" ) )
elif self.creature.get_data( "mouth_horiz" ) < 0.0:
self.set_blend_shape( "mouth_horiz_min", -self.creature.get_data( "mouth_horiz" ) )
self.set_blend_shape( "mouth_horiz_max", 0.0 )
else:
self.set_blend_shape( "mouth_horiz_min", 0.0 )
self.set_blend_shape( "mouth_horiz_max", 0.0 )
if self.creature.get_data( "mouth_horiz" ) > 0.0:
self.set_blend_shape( "mouth_horiz_min", 0.0 )
self.set_blend_shape( "mouth_horiz_max", self.creature.get_data( "mouth_horiz" ) )
elif self.creature.get_data( "mouth_horiz" ) < 0.0:
self.set_blend_shape( "mouth_horiz_min", -self.creature.get_data( "mouth_horiz" ) )
self.set_blend_shape( "mouth_horiz_max", 0.0 )
else:
self.set_blend_shape( "mouth_horiz_min", 0.0 )
self.set_blend_shape( "mouth_horiz_max", 0.0 )
if self.creature.get_data( "mouth_vert" ) > 0.0:
self.set_blend_shape( "mouth_vert_min", 0.0 )
self.set_blend_shape( "mouth_vert_max", self.creature.get_data( "mouth_vert" ) )
elif self.creature.get_data( "mouth_vert" ) < 0.0:
self.set_blend_shape( "mouth_vert_min", -self.creature.get_data( "mouth_vert" ) )
self.set_blend_shape( "mouth_vert_max", 0.0 )
else:
self.set_blend_shape( "mouth_vert_min", 0.0 )
self.set_blend_shape( "mouth_vert_max", 0.0 )
if self.creature.get_data( "mouth_vert" ) > 0.0:
self.set_blend_shape( "mouth_vert_min", 0.0 )
self.set_blend_shape( "mouth_vert_max", self.creature.get_data( "mouth_vert" ) )
elif self.creature.get_data( "mouth_vert" ) < 0.0:
self.set_blend_shape( "mouth_vert_min", -self.creature.get_data( "mouth_vert" ) )
self.set_blend_shape( "mouth_vert_max", 0.0 )
else:
self.set_blend_shape( "mouth_vert_min", 0.0 )
self.set_blend_shape( "mouth_vert_max", 0.0 )
if self.creature.get_data( "nose_galbe" ) > 0.0:
self.set_blend_shape( "nose_galbe_min", 0.0 )
self.set_blend_shape( "nose_galbe_max", self.creature.get_data( "nose_galbe" ) )
elif self.creature.get_data( "nose_galbe" ) < 0.0:
self.set_blend_shape( "nose_galbe_min", -self.creature.get_data( "nose_galbe" ) )
self.set_blend_shape( "nose_galbe_max", 0.0 )
else:
self.set_blend_shape( "nose_galbe_min", 0.0 )
self.set_blend_shape( "nose_galbe_max", 0.0 )
if self.creature.get_data( "nose_galbe" ) > 0.0:
self.set_blend_shape( "nose_galbe_min", 0.0 )
self.set_blend_shape( "nose_galbe_max", self.creature.get_data( "nose_galbe" ) )
elif self.creature.get_data( "nose_galbe" ) < 0.0:
self.set_blend_shape( "nose_galbe_min", -self.creature.get_data( "nose_galbe" ) )
self.set_blend_shape( "nose_galbe_max", 0.0 )
else:
self.set_blend_shape( "nose_galbe_min", 0.0 )
self.set_blend_shape( "nose_galbe_max", 0.0 )
if self.creature.get_data( "nose_grec" ) > 0.0:
self.set_blend_shape( "nose_grec_min", 0.0 )
self.set_blend_shape( "nose_grec_max", self.creature.get_data( "nose_grec" ) )
elif self.creature.get_data( "nose_grec" ) < 0.0:
self.set_blend_shape( "nose_grec_min", -self.creature.get_data( "nose_grec" ) )
self.set_blend_shape( "nose_grec_max", 0.0 )
else:
self.set_blend_shape( "nose_grec_min", 0.0 )
self.set_blend_shape( "nose_grec_max", 0.0 )
if self.creature.get_data( "nose_grec" ) > 0.0:
self.set_blend_shape( "nose_grec_min", 0.0 )
self.set_blend_shape( "nose_grec_max", self.creature.get_data( "nose_grec" ) )
elif self.creature.get_data( "nose_grec" ) < 0.0:
self.set_blend_shape( "nose_grec_min", -self.creature.get_data( "nose_grec" ) )
self.set_blend_shape( "nose_grec_max", 0.0 )
else:
self.set_blend_shape( "nose_grec_min", 0.0 )
self.set_blend_shape( "nose_grec_max", 0.0 )
if self.creature.get_data( "nose_horiz" ) > 0.0:
self.set_blend_shape( "nose_horiz_min", 0.0 )
self.set_blend_shape( "nose_horiz_max", self.creature.get_data( "nose_horiz" ) )
elif self.creature.get_data( "nose_horiz" ) < 0.0:
self.set_blend_shape( "nose_horiz_min", -self.creature.get_data( "nose_horiz" ) )
self.set_blend_shape( "nose_horiz_max", 0.0 )
else:
self.set_blend_shape( "nose_horiz_min", 0.0 )
self.set_blend_shape( "nose_horiz_max", 0.0 )
if self.creature.get_data( "nose_horiz" ) > 0.0:
self.set_blend_shape( "nose_horiz_min", 0.0 )
self.set_blend_shape( "nose_horiz_max", self.creature.get_data( "nose_horiz" ) )
elif self.creature.get_data( "nose_horiz" ) < 0.0:
self.set_blend_shape( "nose_horiz_min", -self.creature.get_data( "nose_horiz" ) )
self.set_blend_shape( "nose_horiz_max", 0.0 )
else:
self.set_blend_shape( "nose_horiz_min", 0.0 )
self.set_blend_shape( "nose_horiz_max", 0.0 )
if self.creature.get_data( "nose_depth" ) > 0.0:
self.set_blend_shape( "nose_depth_min", 0.0 )
self.set_blend_shape( "nose_depth_max", self.creature.get_data( "nose_depth" ) )
elif self.creature.get_data( "nose_depth" ) < 0.0:
self.set_blend_shape( "nose_depth_min", -self.creature.get_data( "nose_depth" ) )
self.set_blend_shape( "nose_depth_max", 0.0 )
else:
self.set_blend_shape( "nose_depth_min", 0.0 )
self.set_blend_shape( "nose_depth_max", 0.0 )
if self.creature.get_data( "nose_depth" ) > 0.0:
self.set_blend_shape( "nose_depth_min", 0.0 )
self.set_blend_shape( "nose_depth_max", self.creature.get_data( "nose_depth" ) )
elif self.creature.get_data( "nose_depth" ) < 0.0:
self.set_blend_shape( "nose_depth_min", -self.creature.get_data( "nose_depth" ) )
self.set_blend_shape( "nose_depth_max", 0.0 )
else:
self.set_blend_shape( "nose_depth_min", 0.0 )
self.set_blend_shape( "nose_depth_max", 0.0 )
self.get_node( "body_parts/body/skeleton/eyes" ).get_surface_material( 0 ).albedo_texture = load( "res://assets/creatures/human/textures/"+self.eye_color_list[ self.creature.get_data( "eyes_color", 0 ) ]+".png" )
self.get_node( "body_parts/body/skeleton/eyes" ).get_surface_material( 0 ).albedo_texture = load( "res://assets/creatures/human/textures/"+self.eye_color_list[ self.creature.get_data( "eyes_color", 0 ) ]+".png" )
if self.creature.get_data( "eyes_vert" ) > 0.0:
self.set_blend_shape( "eyes_vert_min", 0.0 )
self.set_blend_shape( "eyes_vert_max", self.creature.get_data( "eyes_vert" ) )
elif self.creature.get_data( "eyes_vert" ) < 0.0:
self.set_blend_shape( "eyes_vert_min", -self.creature.get_data( "eyes_vert" ) )
self.set_blend_shape( "eyes_vert_max", 0.0 )
else:
self.set_blend_shape( "eyes_vert_min", 0.0 )
self.set_blend_shape( "eyes_vert_max", 0.0 )
if self.creature.get_data( "eyes_vert" ) > 0.0:
self.set_blend_shape( "eyes_vert_min", 0.0 )
self.set_blend_shape( "eyes_vert_max", self.creature.get_data( "eyes_vert" ) )
elif self.creature.get_data( "eyes_vert" ) < 0.0:
self.set_blend_shape( "eyes_vert_min", -self.creature.get_data( "eyes_vert" ) )
self.set_blend_shape( "eyes_vert_max", 0.0 )
else:
self.set_blend_shape( "eyes_vert_min", 0.0 )
self.set_blend_shape( "eyes_vert_max", 0.0 )
if self.creature.get_data( "eyes_gap" ) > 0.0:
self.set_blend_shape( "eyes_gap_min", 0.0 )
self.set_blend_shape( "eyes_gap_max", self.creature.get_data( "eyes_gap" ) )
elif self.creature.get_data( "eyes_gap" ) < 0.0:
self.set_blend_shape( "eyes_gap_min", -self.creature.get_data( "eyes_gap" ) )
self.set_blend_shape( "eyes_gap_max", 0.0 )
else:
self.set_blend_shape( "eyes_gap_min", 0.0 )
self.set_blend_shape( "eyes_gap_max", 0.0 )
if self.creature.get_data( "eyes_gap" ) > 0.0:
self.set_blend_shape( "eyes_gap_min", 0.0 )
self.set_blend_shape( "eyes_gap_max", self.creature.get_data( "eyes_gap" ) )
elif self.creature.get_data( "eyes_gap" ) < 0.0:
self.set_blend_shape( "eyes_gap_min", -self.creature.get_data( "eyes_gap" ) )
self.set_blend_shape( "eyes_gap_max", 0.0 )
else:
self.set_blend_shape( "eyes_gap_min", 0.0 )
self.set_blend_shape( "eyes_gap_max", 0.0 )
self.set_blend_shape( "earlobes", self.creature.get_data( "earlobes" ) )
self.set_blend_shape( "ears_wing", self.creature.get_data( "ears_wing" ) )
self.set_blend_shape( "earlobes", self.creature.get_data( "earlobes" ) )
self.set_blend_shape( "ears_wing", self.creature.get_data( "ears_wing" ) )
if self.creature.get_data( "lips_up_shape" ) > 0.0:
self.set_blend_shape( "lips_up_shape_min", 0.0 )
self.set_blend_shape( "lips_up_shape_max", self.creature.get_data( "lips_up_shape" ) )
elif self.creature.get_data( "lips_up_shape" ) < 0.0:
self.set_blend_shape( "lips_up_shape_min", -self.creature.get_data( "lips_up_shape" ) )
self.set_blend_shape( "lips_up_shape_max", 0.0 )
else:
self.set_blend_shape( "lips_up_shape_min", 0.0 )
self.set_blend_shape( "lips_up_shape_max", 0.0 )
if self.creature.get_data( "lips_up_shape" ) > 0.0:
self.set_blend_shape( "lips_up_shape_min", 0.0 )
self.set_blend_shape( "lips_up_shape_max", self.creature.get_data( "lips_up_shape" ) )
elif self.creature.get_data( "lips_up_shape" ) < 0.0:
self.set_blend_shape( "lips_up_shape_min", -self.creature.get_data( "lips_up_shape" ) )
self.set_blend_shape( "lips_up_shape_max", 0.0 )
else:
self.set_blend_shape( "lips_up_shape_min", 0.0 )
self.set_blend_shape( "lips_up_shape_max", 0.0 )
if self.creature.get_data( "lips_up_shape_2" ) > 0.0:
self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
self.set_blend_shape( "lips_up_shape_2_max", self.creature.get_data( "lips_up_shape_2" ) )
elif self.creature.get_data( "lips_up_shape_2" ) < 0.0:
self.set_blend_shape( "lips_up_shape_2_min", -self.creature.get_data( "lips_up_shape_2" ) )
self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
else:
self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
if self.creature.get_data( "lips_up_shape_2" ) > 0.0:
self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
self.set_blend_shape( "lips_up_shape_2_max", self.creature.get_data( "lips_up_shape_2" ) )
elif self.creature.get_data( "lips_up_shape_2" ) < 0.0:
self.set_blend_shape( "lips_up_shape_2_min", -self.creature.get_data( "lips_up_shape_2" ) )
self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
else:
self.set_blend_shape( "lips_up_shape_2_min", 0.0 )
self.set_blend_shape( "lips_up_shape_2_max", 0.0 )
self.set_blend_shape( "nipple_flat", 1.0 )
self.set_blend_shape( "nipple_flat", 1.0 )
func play( anim_name, speed = 1.0 ):
for child in $body_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
for child in $hair_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
for child in $cloths.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
for child in $body_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
for child in $hair_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
for child in $cloths.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play( anim_name )
func play_backwards( anim_name, speed = 1.0 ):
for child in $body_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
for child in $hair_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
for child in $cloths.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
for child in $body_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
for child in $hair_parts.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
for child in $cloths.get_children():
child.get_node( "skeleton/AnimationPlayer" ).playback_speed = speed
if child.get_node( "skeleton/AnimationPlayer" ).has_animation( anim_name ):
child.get_node( "skeleton/AnimationPlayer" ).play_backwards( anim_name )
func can_turn():
var animation_player = $body_parts/body/skeleton/AnimationPlayer
return (animation_player.current_animation.begins_with( "turn_") and animation_player.current_animation_position >= 1.2) or (not animation_player.current_animation.begins_with( "turn_") and not animation_player.current_animation.begins_with( "idle"))
var animation_player = $body_parts/body/skeleton/AnimationPlayer
return (animation_player.current_animation.begins_with( "turn_") and animation_player.current_animation_position >= 1.2) or (not animation_player.current_animation.begins_with( "turn_") and not animation_player.current_animation.begins_with( "idle"))
func equip( p_item, p_slot = null ):
var model = load( p_item.get_data( "model_equiped", "") )
if not model:
model = load( p_item.get_data( "model", "") )
if model:
model = model.instance()
var attachment = null
if not p_slot:
p_slot = p_item.get_data( "default_slot" )
if p_slot and int(p_slot) in self.slots:
self.unequip( p_slot )
attachment = self.slots[ int(p_slot) ].attachment
self.slots[ int(p_slot) ].item = p_item
if attachment:
if attachment == "cloths":
model.name = str(int(p_slot))
$cloths.add_child( model )
var animation = $body_parts/body/skeleton/AnimationPlayer.current_animation
var animation_position = $body_parts/body/skeleton/AnimationPlayer.current_animation_position
var animation_speed = $body_parts/body/skeleton/AnimationPlayer.playback_speed
model.get_node( "skeleton/AnimationPlayer" ).stop()
model.get_node( "skeleton/AnimationPlayer" ).set( "playback_speed", animation_speed )
model.get_node( "skeleton/AnimationPlayer" ).play( animation )
model.get_node( "skeleton/AnimationPlayer" ).advance( animation_position )
else:
if $body_parts/body/skeleton.has_node( attachment ):
$body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).add_child( model )
var model = load( p_item.get_data( "model_equiped", "") )
if not model:
model = load( p_item.get_data( "model", "") )
if model:
model = model.instance()
var attachment = null
if not p_slot:
p_slot = p_item.get_data( "default_slot" )
if p_slot and int(p_slot) in self.slots:
self.unequip( p_slot )
attachment = self.slots[ int(p_slot) ].attachment
self.slots[ int(p_slot) ].item = p_item
if attachment:
if attachment == "cloths":
model.name = str(int(p_slot))
$cloths.add_child( model )
var animation = $body_parts/body/skeleton/AnimationPlayer.current_animation
var animation_position = $body_parts/body/skeleton/AnimationPlayer.current_animation_position
var animation_speed = $body_parts/body/skeleton/AnimationPlayer.playback_speed
model.get_node( "skeleton/AnimationPlayer" ).stop()
model.get_node( "skeleton/AnimationPlayer" ).set( "playback_speed", animation_speed )
model.get_node( "skeleton/AnimationPlayer" ).play( animation )
model.get_node( "skeleton/AnimationPlayer" ).advance( animation_position )
else:
if $body_parts/body/skeleton.has_node( attachment ):
$body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).add_child( model )
emit_signal( "equip", int(p_slot), p_item )
emit_signal( "equip", int(p_slot), p_item )
func unequip( p_slot ):
if p_slot and int(p_slot) in self.slots:
if self.slots[ int(p_slot) ].item:
var attachment = self.slots[ int(p_slot) ].attachment
self.slots[ int(p_slot) ].item = null
if attachment:
if attachment == "cloths":
var node = $cloths.get_node( str(p_slot) )
if node:
$cloths.remove_child( node )
node.queue_free()
else:
for child in $body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).get_children():
$body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).remove_child( child )
child.queue_free()
emit_signal( "unequip", int(p_slot) )
if p_slot and int(p_slot) in self.slots:
if self.slots[ int(p_slot) ].item:
var attachment = self.slots[ int(p_slot) ].attachment
self.slots[ int(p_slot) ].item = null
if attachment:
if attachment == "cloths":
var node = $cloths.get_node( str(p_slot) )
if node:
$cloths.remove_child( node )
node.queue_free()
else:
for child in $body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).get_children():
$body_parts/body/skeleton.get_node( attachment ).get_node( "handle" ).remove_child( child )
child.queue_free()
emit_signal( "unequip", int(p_slot) )
func drop_item( p_item ):
var new_inventory = self.creature.get_data( "inventory" )
var item_index = new_inventory.find( p_item )
if item_index != -1:
if new_inventory[ item_index ].get_data( "dropable", true ):
new_inventory[ item_index ].set_data( "number", new_inventory[ item_index ].get_data( "number" )-1 )
var new_inventory = self.creature.get_data( "inventory" )
var item_index = new_inventory.find( p_item )
if item_index != -1:
if new_inventory[ item_index ].get_data( "dropable", true ):
new_inventory[ item_index ].set_data( "number", new_inventory[ item_index ].get_data( "number" )-1 )
if new_inventory[ item_index ].get_data( "number" ) <= 0:
new_inventory.remove( item_index )
if new_inventory[ item_index ].get_data( "number" ) <= 0:
new_inventory.remove( item_index )
var pickup_item_node = preload( "res://scenes/items/pickup_item.tscn" ).instance()
pickup_item_node.item_filename = p_item.get_filename()
pickup_item_node.global_transform = $drop_point.global_transform
var pickup_item_node = preload( "res://scenes/items/pickup_item.tscn" ).instance()
pickup_item_node.item_filename = p_item.get_filename()
pickup_item_node.global_transform = $drop_point.global_transform
var pickup_item = Datas.PickupItem.new( p_item.get_filename(), $drop_point.global_transform, p_item )
pickup_item_node.item = pickup_item
var pickup_item = Datas.PickupItem.new( p_item.get_filename(), $drop_point.global_transform, p_item )
pickup_item_node.item = pickup_item
if self.get_tree().get_root().has_node( "main/scene/game" ):
self.get_tree().get_root().get_node( "main/scene/game" ).get_node( "pickups" ).add_child( pickup_item_node )
if self.get_tree().get_root().has_node( "main/scene/game" ):
self.get_tree().get_root().get_node( "main/scene/game" ).get_node( "pickups" ).add_child( pickup_item_node )
func _on_body_animation_finished( anim_name ):
emit_signal( "animation_finished", anim_name )
emit_signal( "animation_finished", anim_name )
func _on_body_limb_body_entered(limb, body):
if body.is_in_group( "bullet" ):
if limb == Datas.Cloth.LIMB.head:
var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
$body_parts/body/skeleton/limb_head.add_child( blood_particle )
blood_particle.emit()
emit_signal( "is_dead" )
self.creature.set_data( "current_life", 0.0 )
else:
var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
$body_parts/body/skeleton/limb_torso_1.add_child( blood_particle )
blood_particle.emit()
if body.is_in_group( "bullet" ):
if limb == Datas.Cloth.LIMB.head:
var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
$body_parts/body/skeleton/limb_head.add_child( blood_particle )
blood_particle.emit()
emit_signal( "is_dead" )
self.creature.set_data( "current_life", 0.0 )
else:
var blood_particle = preload( "res://scenes/fx/blood_particles.tscn" ).instance()
$body_parts/body/skeleton/limb_torso_1.add_child( blood_particle )
blood_particle.emit()

View file

@ -16,28 +16,28 @@ var is_moving: = false setget set_is_moving
func _ready() -> void:
animation_tree.active = true
animation_tree.active = true
func set_move_direction(direction: Vector3) -> void:
move_direction = direction
animation_tree["parameters/walk/blend_position"] = direction.length()
move_direction = direction
animation_tree["parameters/walk/blend_position"] = direction.length()
func set_is_moving(value: bool) -> void:
is_moving = value
is_moving = value
# animation_tree["parameters/conditions/is_moving"] = value
func transition_to(state_id: int) -> void:
match state_id:
States.IDLE:
_playback.travel("idle")
States.LAND:
_playback.travel("land")
States.RUN:
_playback.travel("walk")
States.AIR:
_playback.travel("jump")
_:
_playback.travel("idle")
match state_id:
States.IDLE:
_playback.travel("idle")
States.LAND:
_playback.travel("land")
States.RUN:
_playback.travel("walk")
States.AIR:
_playback.travel("jump")
_:
_playback.travel("idle")

View file

@ -16,12 +16,12 @@ var is_on_ui = false
func _ready():
var player_ra = Ra.new()
var file = File.new()
if file.open("res://ressources/files/creatures/test.creature", File.READ) == OK:
player_ra.from_dict( JSON.parse( file.get_as_text() ).result )
var player_ra = Ra.new()
var file = File.new()
if file.open("res://ressources/files/creatures/test.creature", File.READ) == OK:
player_ra.from_dict( JSON.parse( file.get_as_text() ).result )
$game_ui/inventory_window.get_content_child( "content_box/inventory_box" ).set_inventory( player_ra.inventory )
$game_ui/inventory_window.get_content_child( "content_box/inventory_box" ).set_inventory( player_ra.inventory )
@ -33,10 +33,10 @@ func _input( event ):
# $screen_box/pause_menu.show()
# self.get_tree().paused = true
if event.is_action_pressed( "ui_show_head_infos" ):
$creatures/player/character/head_infos_frame.visible = not $player/character/head_infos_frame.visible
for npc in $creatures/npcs.get_children():
npc.get_node( "head_infos_frame" ).visible = not npc.get_node( "head_infos_frame" ).visible
if event.is_action_pressed( "ui_show_head_infos" ):
$creatures/player/character/head_infos_frame.visible = not $player/character/head_infos_frame.visible
for npc in $creatures/npcs.get_children():
npc.get_node( "head_infos_frame" ).visible = not npc.get_node( "head_infos_frame" ).visible
#
@ -99,44 +99,44 @@ func _process( delta ):
# self.camera_zoom = 0.0
# self.mouse_delta = Vector2( 0.0, 0.0 )
# Water fx.
if $creatures/player/character.global_transform.origin.y <= ($level/demo/water.translation.y-2.5):
$water_fx.get_surface_material( 0 ).set_shader_param( "mist_level", 1.0 )
else:
$water_fx.get_surface_material( 0 ).set_shader_param( "mist_level", 0.0 )
# Water fx.
if $creatures/player/character.global_transform.origin.y <= ($level/demo/water.translation.y-2.5):
$water_fx.get_surface_material( 0 ).set_shader_param( "mist_level", 1.0 )
else:
$water_fx.get_surface_material( 0 ).set_shader_param( "mist_level", 0.0 )
var trauma_value = ($game_ui/stats_window.get_content_child( "trauma" ).value / 6.0)
$trauma_fx.get_surface_material( 0 ).set_shader_param( "mist_level", trauma_value )
var trauma_value = ($game_ui/stats_window.get_content_child( "trauma" ).value / 6.0)
$trauma_fx.get_surface_material( 0 ).set_shader_param( "mist_level", trauma_value )
$sky/viewport/sky.day_time_hours += delta*((6.0/24.0)/3600.0)
if $sky/viewport/sky.day_time_hours >= 24.0:
$sky/viewport/sky.day_time_hours = $sky/viewport/sky.day_time_hours-24.0
$sky/viewport/sky.day_time_hours += delta*((6.0/24.0)/3600.0)
if $sky/viewport/sky.day_time_hours >= 24.0:
$sky/viewport/sky.day_time_hours = $sky/viewport/sky.day_time_hours-24.0
func load_player( filename ):
$creatures/player.load_creature( filename )
$creatures/player.load_creature( filename )
func _on_debug_window_time_of_day_changed(value):
$sky/viewport/sky.set_day_time_hours(( value ))
$sky/viewport/sky.set_day_time_hours(( value ))
func _on_debug_window_mist_level_changed(value):
$mist_fx.get_surface_material( 0 ).set_shader_param( "mist_level", value )
$mist_fx.get_surface_material( 0 ).set_shader_param( "mist_level", value )
func _on_debug_window_douleur_minus_pressed():
$game_ui.change_douleur( -1 )
$game_ui.change_douleur( -1 )
func _on_debug_window_douleur_plus_pressed():
$game_ui.change_douleur( 1 )
$game_ui.change_douleur( 1 )
func _on_debug_window_oubli_minus_pressed():
$game_ui.change_oubli( -1 )
$game_ui.change_oubli( -1 )
func _on_debug_window_oubli_plus_pressed():
$game_ui.change_oubli( 1 )
$game_ui.change_oubli( 1 )

View file

@ -7,8 +7,8 @@ export(float, 0.0, 24.0) var day_time_hours = 12.0 setget set_day_time_hours
export(NodePath) var directional_light_node_path
func _ready():
if !Engine.is_editor_hint():
editor_clouds_playing = true
if !Engine.is_editor_hint():
editor_clouds_playing = true
var iTime = 0.0
var iFrame = 0
@ -16,12 +16,12 @@ var iFrame = 0
func _process( delta ):
iTime+=delta
iFrame+=1
iTime+=delta
iFrame+=1
if (Engine.is_editor_hint() and self.editor_clouds_playing) or !Engine.is_editor_hint():
self.material.set("shader_param/iTime", iTime)
self.material.set("shader_param/iFrame", iFrame)
if (Engine.is_editor_hint() and self.editor_clouds_playing) or !Engine.is_editor_hint():
self.material.set("shader_param/iTime", iTime)
self.material.set("shader_param/iFrame", iFrame)
# self.set_day_time_hours( self.day_time_hours + delta )
# if day_time_hours >= 24:
@ -29,43 +29,43 @@ func _process( delta ):
func cov_scb(value):
self.material.set("shader_param/COVERAGE",float(value))
self.material.set("shader_param/COVERAGE",float(value))
func thick_scb(value):
self.material.set("shader_param/THICKNESS",value)
self.material.set("shader_param/THICKNESS",value)
func absb_scb(value):
self.material.set("shader_param/ABSORPTION",float(value))
self.material.set("shader_param/ABSORPTION",float(value))
func step_scb(value):
self.material.set("shader_param/STEPS",value)
self.material.set("shader_param/STEPS",value)
export var sun_position = Vector3(0.0, 1.0, 0.0) setget set_sun_position, get_sun_position
func set_sun_position(new_position):
sun_position = new_position
if self.material:
self.material.set_shader_param("sun_pos", sun_position)
sun_position = new_position
if self.material:
self.material.set_shader_param("sun_pos", sun_position)
# _trigger_update_sky()
func get_sun_position():
return sun_position
return sun_position
func set_time_of_day(hours, directional_light, horizontal_angle = 0.0):
var sun_position = Vector3(0.0, -100.0, 0.0)
sun_position = sun_position.rotated(Vector3(1.0, 0.0, 0.0), hours * PI / 12.0)
sun_position = sun_position.rotated(Vector3(0.0, 1.0, 0.0), horizontal_angle)
var new_position = Vector3(0.0, -100.0, 0.0)
new_position = new_position.rotated(Vector3(1.0, 0.0, 0.0), hours * PI / 12.0)
new_position = new_position.rotated(Vector3(0.0, 1.0, 0.0), horizontal_angle)
if directional_light:
var t = directional_light.transform
t.origin = sun_position
directional_light.transform = t.looking_at(Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0))
directional_light.light_energy = 1.0 - clamp(abs(hours - 12.0) / 6.0, 0.0, 1.0)
if directional_light:
var t = directional_light.transform
t.origin = new_position
directional_light.transform = t.looking_at(Vector3(0.0, 0.0, 0.0), Vector3(0.0, 1.0, 0.0))
directional_light.light_energy = 1.0 - clamp(abs(hours - 12.0) / 6.0, 0.0, 1.0)
# and update our sky
set_sun_position(sun_position)
# and update our sky
set_sun_position(new_position)
func set_day_time_hours(hours):
if directional_light_node_path:
set_time_of_day(hours, get_node(directional_light_node_path), 25.0)
day_time_hours = hours
if directional_light_node_path:
set_time_of_day(hours, get_node(directional_light_node_path), 25.0)
day_time_hours = hours

View file

@ -22,95 +22,95 @@ var ra = Creatures.Ra_old.new()
var slot = null
func _ready():
$viewport/spring_arm/camera.make_current()
$viewport/spring_arm/camera.make_current()
func _input( event ):
if event is InputEventMouseButton:
if event is InputEventMouseButton:
if event.is_action_pressed( "creatures_editor_rotate_view_y" ):
self.mouse_old_position = event.position
elif event.is_action_released( "creatures_editor_rotate_view_y" ):
self.mouse_old_position = null
self.mouse_delta = null
if event.is_action_pressed( "creatures_editor_rotate_view_y" ):
self.mouse_old_position = event.position
elif event.is_action_released( "creatures_editor_rotate_view_y" ):
self.mouse_old_position = null
self.mouse_delta = null
if event.is_action( "creatures_editor_zoom_in" ):
self.camera_zoom += self.camera_zoom_speed
elif event.is_action( "creatures_editor_zoom_out" ):
self.camera_zoom -= self.camera_zoom_speed
if event.is_action( "creatures_editor_zoom_in" ):
self.camera_zoom += self.camera_zoom_speed
elif event.is_action( "creatures_editor_zoom_out" ):
self.camera_zoom -= self.camera_zoom_speed
if event is InputEventMouseMotion:
if not mouse_old_position == null:
self.mouse_delta = mouse_old_position - event.position
self.mouse_old_position = event.position
if event is InputEventMouseMotion:
if not mouse_old_position == null:
self.mouse_delta = mouse_old_position - event.position
self.mouse_old_position = event.position
func _process( delta ):
if self.mouse_delta:
$viewport/model/ra.rotate( Vector3( 0.0, 1.0, 0.0 ), deg2rad( -self.mouse_delta.x ) )
self.mouse_delta = Vector2( 0.0, 0.0 )
if self.mouse_delta:
$viewport/model/ra.rotate( Vector3( 0.0, 1.0, 0.0 ), deg2rad( -self.mouse_delta.x ) )
self.mouse_delta = Vector2( 0.0, 0.0 )
if self.camera_zoom:
$viewport/spring_arm/camera.size += self.camera_zoom
self.camera_zoom = 0.0
if self.camera_zoom:
$viewport/spring_arm/camera.size += self.camera_zoom
self.camera_zoom = 0.0
func set_creature( p_creature ):
if p_creature is Creatures.Ra:
self.ra = p_creature
$screen_box/tools_box/boobs/value.value = p_creature.female_boobs
$screen_box/tools_box/hip/value.value = p_creature.female_hip
$screen_box/tools_box/male_scrotch/value.value = p_creature.male_pack
$screen_box/tools_box/male_throat/value.value = p_creature.male_throat
$screen_box/tools_box/pregnant/value.value = p_creature.female_pregnant
$screen_box/tools_box/color/value.value = p_creature.color
if p_creature is Creatures.Ra:
self.ra = p_creature
$screen_box/tools_box/boobs/value.value = p_creature.female_boobs
$screen_box/tools_box/hip/value.value = p_creature.female_hip
$screen_box/tools_box/male_scrotch/value.value = p_creature.male_pack
$screen_box/tools_box/male_throat/value.value = p_creature.male_throat
$screen_box/tools_box/pregnant/value.value = p_creature.female_pregnant
$screen_box/tools_box/color/value.value = p_creature.color
func _on_name_text_changed( new_text ):
self.ra.pseudonym = new_text
self.ra.pseudonym = new_text
func _on_boobs_value_changed( value ):
$viewport/model/ra/model/body.set( "blend_shapes/Boobs", value )
self.ra.female_boobs = value
$viewport/model/ra/model/body.set( "blend_shapes/Boobs", value )
self.ra.female_boobs = value
func _on_hip_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Female_hip", value )
self.ra.female_hip = value
$viewport/model/ra/model/body.set( "blend_shapes/Female_hip", value )
self.ra.female_hip = value
func _on_male_scrotch_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Male_Pack", value )
self.ra.male_pack = value
$viewport/model/ra/model/body.set( "blend_shapes/Male_Pack", value )
self.ra.male_pack = value
func _on_male_throat_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Male_Throat", value )
self.ra.male_throat = value
$viewport/model/ra/model/body.set( "blend_shapes/Male_Throat", value )
self.ra.male_throat = value
func _on_pregnant_value_changed(value):
$viewport/model/ra/model/body.set( "blend_shapes/Pregnant", value )
self.ra.female_pregnant = value
$viewport/model/ra/model/body.set( "blend_shapes/Pregnant", value )
self.ra.female_pregnant = value
func _on_valid_pressed():
if not self.slot == null:
var directory = Directory.new()
if not directory.dir_exists( "user://creatures/" ):
directory.make_dir_recursive( "user://creatures/" )
if not self.slot == null:
var directory = Directory.new()
if not directory.dir_exists( "user://creatures/" ):
directory.make_dir_recursive( "user://creatures/" )
var creature_file = File.new()
creature_file.open("user://creatures/slot_"+str(self.slot)+".creature", File.WRITE)
creature_file.store_line(to_json(self.ra.to_dictionary()))
creature_file.close()
var creature_file = File.new()
creature_file.open("user://creatures/slot_"+str(self.slot)+".creature", File.WRITE)
creature_file.store_line(to_json(self.ra.to_dictionary()))
creature_file.close()
emit_signal( "valid_pressed" )
emit_signal( "valid_pressed" )
func _on_cancel_pressed():
emit_signal( "cancel_pressed" )
emit_signal( "cancel_pressed" )
func _on_color_changed(color):
$viewport/model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", color )
self.ra.color = color
$viewport/model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", color )
self.ra.color = color

View file

@ -7,8 +7,8 @@ var slot = null
var creature_filename = null
func _on_select_pressed():
emit_signal( "select_pressed", self.slot )
emit_signal( "select_pressed", self.slot )
func _on_delete_pressed():
emit_signal( "delete_pressed", self.slot )
emit_signal( "delete_pressed", self.slot )

View file

@ -9,46 +9,46 @@ var slots = {}
func _ready():
var files = []
var directory = Directory.new()
if directory.dir_exists( "user://creatures/" ):
directory.open( "user://creatures/" )
directory.list_dir_begin()
while true:
var file = directory.get_next()
if file == "":
break
elif not file.begins_with( "." ) and not directory.current_is_dir():
files.append( file )
directory.list_dir_end()
var files = []
var directory = Directory.new()
if directory.dir_exists( "user://creatures/" ):
directory.open( "user://creatures/" )
directory.list_dir_begin()
while true:
var file = directory.get_next()
if file == "":
break
elif not file.begins_with( "." ) and not directory.current_is_dir():
files.append( file )
directory.list_dir_end()
for file in files:
var creature_box = preload( "res://scenes/interfaces/creatures_menu/creature_box.tscn" ).instance()
creature_box.get_node( "label" ).text = file
creature_box.slot = self.slots_number
creature_box.creature_filename = file
creature_box.connect( "select_pressed", self, "_on_creature_box_select_pressed" )
creature_box.connect( "delete_pressed", self, "_on_creature_box_delete_pressed" )
$screen_box/scroll_container/v_box_container/creatures_box.add_child( creature_box )
self.slots[ self.slots_number ] = creature_box
self.slots_number += 1
for file in files:
var creature_box = preload( "res://scenes/interfaces/creatures_menu/creature_box.tscn" ).instance()
creature_box.get_node( "label" ).text = file
creature_box.slot = self.slots_number
creature_box.creature_filename = file
creature_box.connect( "select_pressed", self, "_on_creature_box_select_pressed" )
creature_box.connect( "delete_pressed", self, "_on_creature_box_delete_pressed" )
$screen_box/scroll_container/v_box_container/creatures_box.add_child( creature_box )
self.slots[ self.slots_number ] = creature_box
self.slots_number += 1
var creature = Creatures.Ra_old2.new()
creature.from_file( file )
creature_box.get_node( "label" ).text = creature.pseudonym
var creature = Creatures.Ra_old2.new()
creature.from_file( file )
creature_box.get_node( "label" ).text = creature.pseudonym
func _on_new_pressed():
emit_signal( "new_pressed", self.slots_number )
emit_signal( "new_pressed", self.slots_number )
func _on_cancel_pressed():
emit_signal( "cancel_pressed" )
emit_signal( "cancel_pressed" )
func _on_creature_box_select_pressed( slot ):
emit_signal( "select_pressed", self.slots[ slot ].creature_filename )
emit_signal( "select_pressed", self.slots[ slot ].creature_filename )
func _on_creature_box_delete_pressed( slot ):
if self.slots[ slot ].creature_filename:
var dir = Directory.new()
dir.remove( "user://creatures/" + self.slots[ slot ].creature_filename )
self.slots[ slot ].queue_free()
if self.slots[ slot ].creature_filename:
var dir = Directory.new()
dir.remove( "user://creatures/" + self.slots[ slot ].creature_filename )
self.slots[ slot ].queue_free()

View file

@ -5,5 +5,5 @@ class_name focus_reticle
export( Vector2 ) var size = Vector2( 1.0, 1.0 ) setget set_size
func set_size( p_value ):
size = p_value
self.mesh.size = p_value
size = p_value
self.mesh.size = p_value

View file

@ -2,46 +2,46 @@ extends Control
func change_douleur( value ):
$stats_window.get_content_child( "douleur" ).value += value
if value > 0.0:
$stats_window.get_content_child( "oubli" ).value -= value/2
$stats_window.get_content_child( "douleur" ).value += value
if value > 0.0:
$stats_window.get_content_child( "oubli" ).value -= value/2
func change_oubli( value ):
$stats_window.get_content_child( "oubli" ).value += value
if value > 0.0:
$stats_window.get_content_child( "douleur" ).value -= value/2
$stats_window.get_content_child( "oubli" ).value += value
if value > 0.0:
$stats_window.get_content_child( "douleur" ).value -= value/2
func change_trauma( value ):
$stats_window.get_content_child( "trauma" ).self_modulate.a += value/6.0
$stats_window.get_content_child( "trauma" ).self_modulate.a += value/6.0
func set_douleur( value ):
var delta = value - $stats_window.get_content_child( "douleur" ).value
$stats_window.get_content_child( "douleur" ).value = value
if delta > 0.0:
$stats_window.get_content_child( "oubli" ).value -= delta/2
var delta = value - $stats_window.get_content_child( "douleur" ).value
$stats_window.get_content_child( "douleur" ).value = value
if delta > 0.0:
$stats_window.get_content_child( "oubli" ).value -= delta/2
func set_oubli( value ):
var delta = value - $stats_window.get_content_child( "oubli" ).value
$stats_window.get_content_child( "oubli" ).value = value
if delta > 0.0:
$stats_window.get_content_child( "douleur" ).value -= delta/2
var delta = value - $stats_window.get_content_child( "oubli" ).value
$stats_window.get_content_child( "oubli" ).value = value
if delta > 0.0:
$stats_window.get_content_child( "douleur" ).value -= delta/2
func set_trauma( value ):
$stats_window.get_content_child( "trauma" ).self_modulate.a = value/6.0
$stats_window.get_content_child( "trauma" ).self_modulate.a = value/6.0
func update_trauma():
var trauma_value = (($stats_window.get_content_child( "oubli" ).value+$stats_window.get_content_child( "douleur" ).value)/2)
$stats_window.get_content_child( "trauma" ).value = trauma_value
$stats_window.get_content_child( "trauma" ).self_modulate.a = trauma_value/6.0
var trauma_value = (($stats_window.get_content_child( "oubli" ).value+$stats_window.get_content_child( "douleur" ).value)/2)
$stats_window.get_content_child( "trauma" ).value = trauma_value
$stats_window.get_content_child( "trauma" ).self_modulate.a = trauma_value/6.0
func _on_douleur_value_changed(value):
$stats_window.get_content_child( "douleur" ).self_modulate.a = (value / 18.0) * (value / 18.0)
self.update_trauma()
$stats_window.get_content_child( "douleur" ).self_modulate.a = (value / 18.0) * (value / 18.0)
self.update_trauma()
func _on_oubli_value_changed(value):
$stats_window.get_content_child( "oubli" ).self_modulate.a = (value / 18.0) * (value / 18.0)
self.update_trauma()
$stats_window.get_content_child( "oubli" ).self_modulate.a = (value / 18.0) * (value / 18.0)
self.update_trauma()
func _on_trauma_value_changed(value):
$stats_window.get_content_child( "trauma" ).self_modulate.a = (value / 6.0)
$stats_window.get_content_child( "trauma" ).self_modulate.a = (value / 6.0)

View file

@ -4,24 +4,24 @@ signal inventory_item_hovered( item )
signal inventory_item_gui_input( item, event, node )
func _on_inventory_item_hovered( item ):
emit_signal( "inventory_item_hovered", item )
emit_signal( "inventory_item_hovered", item )
func _on_inventory_item_gui_input( item, event, node ):
emit_signal( "inventory_item_gui_input", item, event, node )
emit_signal( "inventory_item_gui_input", item, event, node )
func clean_inventory():
for child in $scroll_item_box/items_box.get_children():
$scroll_item_box/items_box.remove_child( child )
child.queue_free()
for child in $scroll_item_box/items_box.get_children():
$scroll_item_box/items_box.remove_child( child )
child.queue_free()
func set_inventory( p_inventory ):
self.clean_inventory()
if p_inventory:
for item in p_inventory.items:
print( item )
var new_item_box = preload( "res://scenes/interfaces/inventory_window/item_box.tscn").instance()
new_item_box.item = item
new_item_box.update()
$scroll_item_box/items_box.add_child( new_item_box )
self.clean_inventory()
if p_inventory:
for item in p_inventory.items:
print( item )
var new_item_box = preload( "res://scenes/interfaces/inventory_window/item_box.tscn").instance()
new_item_box.item = item
new_item_box.update()
$scroll_item_box/items_box.add_child( new_item_box )

View file

@ -5,11 +5,11 @@ signal play_pressed
signal quit_pressed
func close():
self.hide()
self.hide()
func _on_play_pressed():
emit_signal( "play_pressed" )
emit_signal( "play_pressed" )
func _on_quitter_pressed():
emit_signal( "quit_pressed" )
emit_signal( "quit_pressed" )

View file

@ -5,4 +5,4 @@ signal music_selected( filename )
var music_filename = ""
func _on_music_button_pressed():
emit_signal( "music_selected", self.music_filename )
emit_signal( "music_selected", self.music_filename )

View file

@ -1,41 +1,41 @@
extends WindowDialog
func _ready():
var directory = Directory.new()
var directory = Directory.new()
if not directory.dir_exists( "user://musics/" ):
directory.make_dir_recursive( "user://musics/" )
directory.open( "user://musics/" )
directory.list_dir_begin()
var files = []
while true:
var file = directory.get_next()
if file == "":
break
elif not file.begins_with(".") and not directory.current_is_dir() and not file.ends_with( ".import" ):
files.append(file)
directory.list_dir_end()
if not directory.dir_exists( "user://musics/" ):
directory.make_dir_recursive( "user://musics/" )
directory.open( "user://musics/" )
directory.list_dir_begin()
var files = []
while true:
var file = directory.get_next()
if file == "":
break
elif not file.begins_with(".") and not directory.current_is_dir() and not file.ends_with( ".import" ):
files.append(file)
directory.list_dir_end()
for file in files:
var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance()
button.music_filename = file
button.text = file
button.connect( "music_selected", self, "_on_music_pressed" )
$window_box/scroll_box/musics_box.add_child( button )
for file in files:
var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance()
button.music_filename = file
button.text = file
button.connect( "music_selected", self, "_on_music_pressed" )
$window_box/scroll_box/musics_box.add_child( button )
func open():
self.popup()
self.popup()
func close():
self.hide()
self.hide()
func toggle():
if self.visible:
self.close()
else:
self.open()
if self.visible:
self.close()
else:
self.open()
func _on_music_pressed( p_filename ):
$music.stream = load( "res://assets/musics/" + p_filename )
$music.play()
$music.stream = load( "res://assets/musics/" + p_filename )
$music.play()

View file

@ -5,11 +5,11 @@ var old_mouse_position = Vector2( 0, 0 )
func _on_stats_window_gui_input(event):
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and Input.is_mouse_button_pressed( BUTTON_LEFT ):
self.old_mouse_position = event.position
if event is InputEventMouseButton and event.button_index == BUTTON_LEFT and Input.is_mouse_button_pressed( BUTTON_LEFT ):
self.old_mouse_position = event.position
if event is InputEventMouseMotion and Input.is_mouse_button_pressed( BUTTON_LEFT ):
var delta = self.old_mouse_position - event.position
self.set_position( self.get_position() - delta )
if event is InputEventMouseMotion and Input.is_mouse_button_pressed( BUTTON_LEFT ):
var delta = self.old_mouse_position - event.position
self.set_position( self.get_position() - delta )

View file

@ -3,9 +3,9 @@ extends Spatial
export( String ) var item_filename = "" setget set_item_filename
func set_item_filename( value ):
item_filename = value
if is_ready:
self.update_model()
item_filename = value
if is_ready:
self.update_model()
var item = null
@ -13,64 +13,65 @@ var is_ready = false
func _ready():
self.item = Datas.PickupItem.new( self.item_filename, self.global_transform )
self.item = Datas.PickupItem.new( self.item_filename, self.global_transform )
self.update_model()
self.update_model()
self.is_ready = true
self.is_ready = true
func update_model():
for node in self.get_children():
self.remove_child( node )
node.queue_free()
for node in self.get_children():
self.remove_child( node )
node.queue_free()
if self.item:
if self.item.get_data( "model" ):
var item_node = load( self.item.get_data( "model" ) )
if item_node:
item_node = item_node.instance()
self.add_child( item_node )
if self.item:
if self.item.get_data( "model" ):
var item_node = load( self.item.get_data( "model" ) )
if item_node:
item_node = item_node.instance()
self.add_child( item_node )
func set_focus( p_focus = true ):
if p_focus:
for item in self.get_children():
if item.has_node( "focus" ):
item.get_node( "focus" ).show()
else:
for item in self.get_children():
if item.has_node( "focus" ):
item.get_node( "focus" ).hide()
var _item
if p_focus:
for _item in self.get_children():
if _item.has_node( "focus" ):
_item.get_node( "focus" ).show()
else:
for _item in self.get_children():
if _item.has_node( "focus" ):
_item.get_node( "focus" ).hide()
func interact( p_object ):
if self.item.get_data( "pickable" ):
if p_object is Datas.Creature:
var new_inventory = p_object.get_data( "inventory" )
if self.item.get_data( "pickable" ):
if p_object is Datas.Creature:
var new_inventory = p_object.get_data( "inventory" )
var number = self.item.get_data( "default_num_given" )
var stack = self.item.get_data( "stack" )
if number and stack and number > stack:
var lasting_number = number
while lasting_number > stack:
var inventory_item = Datas.InventoryItem.new( self.item_filename, stack, self.item )
inventory_item.set_data( "name", self.item_filename )
inventory_item.set_data( "number", stack )
new_inventory.push_back( inventory_item )
lasting_number -= stack
if lasting_number > 0:
var inventory_item = Datas.InventoryItem.new( self.item_filename, lasting_number, self.item )
inventory_item.set_data( "name", self.item_filename )
inventory_item.set_data( "number", lasting_number )
new_inventory.push_back( inventory_item )
else:
var inventory_item = Datas.InventoryItem.new( self.item_filename, number, self.item )
inventory_item.set_data( "name", self.item_filename )
new_inventory.push_back( inventory_item )
var number = self.item.get_data( "default_num_given" )
var stack = self.item.get_data( "stack" )
if number and stack and number > stack:
var lasting_number = number
while lasting_number > stack:
var inventory_item = Datas.InventoryItem.new( self.item_filename, stack, self.item )
inventory_item.set_data( "name", self.item_filename )
inventory_item.set_data( "number", stack )
new_inventory.push_back( inventory_item )
lasting_number -= stack
if lasting_number > 0:
var inventory_item = Datas.InventoryItem.new( self.item_filename, lasting_number, self.item )
inventory_item.set_data( "name", self.item_filename )
inventory_item.set_data( "number", lasting_number )
new_inventory.push_back( inventory_item )
else:
var inventory_item = Datas.InventoryItem.new( self.item_filename, number, self.item )
inventory_item.set_data( "name", self.item_filename )
new_inventory.push_back( inventory_item )
p_object.set_data( "inventory", new_inventory )
p_object.set_data( "inventory", new_inventory )
self.get_parent().remove_child( self )
self.queue_free()
return true
return false
self.get_parent().remove_child( self )
self.queue_free()
return true
return false

View file

@ -12,21 +12,22 @@ var creature_selected_slot = null
var creature_selected_filename = null
func _ready():
Connection.connect( "connection_ok", self, "_on_connexion_ok" )
Connection.connect( "connection_error", self, "_on_connection_error" )
Connection.connect( "connection_ok", self, "_on_connexion_ok" )
Connection.connect( "connection_error", self, "_on_connection_error" )
Globals.ressource_queue.start()
Globals.ressource_queue.start()
func _process(_time):
if self.is_scene_loading:
if Globals.ressource_queue.is_ready( self.current_scene_path ):
print( "LOADING FINISHED")
self.set_new_scene( Globals.ressource_queue.get_resource( self.current_scene_path ) )
$loading_screen.hide()
else:
self.update_progress()
$loading_screen.show()
if self.is_scene_loading:
if Globals.ressource_queue.is_ready( self.current_scene_path ):
print( "LOADING FINISHED")
self.set_new_scene( Globals.ressource_queue.get_resource( self.current_scene_path ) )
# $loading_screen.hide()
self.stop_progress()
else:
self.update_progress()
$loading_screen.show()
# if loader == null:
@ -59,8 +60,8 @@ func _process(_time):
func _input( event ):
if event.is_action_released( "music_manager" ):
MusicManager.toggle()
if event.is_action_released( "music_manager" ):
MusicManager.toggle()
#func load_scene( path ):
@ -81,43 +82,56 @@ func _input( event ):
# self.wait_frames = 1
func set_new_scene( scene_resource ):
if scene_resource:
self.current_scene = scene_resource.instance()
self.get_node("scene").add_child(self.current_scene)
self.is_scene_loading = false
$loading_screen.hide()
$main_menu.hide()
if scene_resource:
self.current_scene = scene_resource.instance()
self.get_node("scene").add_child(self.current_scene)
# self.is_scene_loading = false
self.stop_progress()
# $loading_screen.hide()
$main_menu.hide()
if self.has_node( "scene/creatures_menu_ui" ):
self.get_node( "scene/creatures_menu_ui" ).connect( "new_pressed", self, "_on_creatures_menu_ui_new_pressed" )
self.get_node( "scene/creatures_menu_ui" ).connect( "cancel_pressed", self, "_on_creatures_menu_ui_cancel_pressed" )
self.get_node( "scene/creatures_menu_ui" ).connect( "select_pressed", self, "_on_creatures_menu_ui_select_pressed" )
elif self.has_node( "scene/creatures_editor_ui" ):
self.get_node( "scene/creatures_editor_ui" ).connect( "valid_pressed", self, "_on_creature_editor_ui_valid_pressed" )
self.get_node( "scene/creatures_editor_ui" ).connect( "cancel_pressed", self, "_on_creature_editor_ui_cencel_pressed" )
print( "slot: " + str( self.creature_selected_slot ) )
self.get_node( "scene/creatures_editor_ui" ).slot = self.creature_selected_slot
# elif self.has_node( "scene/game" ):
# self.get_node( "scene/game" ).load_player( self.creature_selected_filename )
if self.has_node( "scene/creatures_menu_ui" ):
self.get_node( "scene/creatures_menu_ui" ).connect( "new_pressed", self, "_on_creatures_menu_ui_new_pressed" )
self.get_node( "scene/creatures_menu_ui" ).connect( "cancel_pressed", self, "_on_creatures_menu_ui_cancel_pressed" )
self.get_node( "scene/creatures_menu_ui" ).connect( "select_pressed", self, "_on_creatures_menu_ui_select_pressed" )
elif self.has_node( "scene/creatures_editor_ui" ):
self.get_node( "scene/creatures_editor_ui" ).connect( "valid_pressed", self, "_on_creature_editor_ui_valid_pressed" )
self.get_node( "scene/creatures_editor_ui" ).connect( "cancel_pressed", self, "_on_creature_editor_ui_cencel_pressed" )
print( "slot: " + str( self.creature_selected_slot ) )
self.get_node( "scene/creatures_editor_ui" ).slot = self.creature_selected_slot
# elif self.has_node( "scene/game" ):
# self.get_node( "scene/game" ).load_player( self.creature_selected_filename )
func update_progress():
var progress = float(Globals.ressource_queue.get_progress( self.current_scene_path ))
var progress = float(Globals.ressource_queue.get_progress( self.current_scene_path ))
#self.get_node("loading_screen/background_player").play("loading")
#self.get_node("loading_screen/background_player").stop()
self.get_node("loading_screen/background_player").seek( (progress*13.0)/100.0 )
self.get_node("loading_screen/background_player").play("loading")
self.get_node("loading_screen/background_player").stop()
self.get_node("loading_screen/background_player").seek( (progress*13.0)/100.0 )
func start_progress():
var progress = float(Globals.ressource_queue.get_progress( self.current_scene_path ))
self.get_node("loading_screen/background_player").play("loading")
#self.get_node("loading_screen/background_player").stop()
self.get_node("loading_screen/background_player").seek( 0 )
self.is_scene_loading = true
$loading_screen.show()
func stop_progress():
self.get_node("loading_screen/background_player").stop()
self.is_scene_loading = false
$loading_screen.hide()
func goto_scene( p_path ):
# Clean old scene.
if self.current_scene:
Globals.ressource_queue.cancel_resource( self.current_scene_path )
self.current_scene.queue_free()
# Clean old scene.
if self.current_scene:
Globals.ressource_queue.cancel_resource( self.current_scene_path )
self.current_scene.queue_free()
Globals.ressource_queue.queue_resource( p_path )
self.current_scene_path = p_path
self.is_scene_loading = true
Globals.ressource_queue.queue_resource( p_path )
self.current_scene_path = p_path
#self.is_scene_loading = true
self.start_progress()
#func set_new_scene( scene_resource ):
@ -134,38 +148,38 @@ func goto_scene( p_path ):
func _on_main_menu_play_pressed():
var username = $main_menu/screen_box/login_box/username.text;
var password = $main_menu/screen_box/login_box/password.text;
if username != null and username != "" and password != null and password != "":
Connection.do_request(username, password)
else:
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
var username = $main_menu/screen_box/login_box/username.text;
var password = $main_menu/screen_box/login_box/password.text;
if username != null and username != "" and password != null and password != "":
Connection.do_request(username, password)
else:
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_creatures_menu_ui_new_pressed( slot ):
self.creature_selected_slot = slot
self.creature_selected_slot = slot
# Globals.goto_scene( "res://scenes/interfaces/creatures_editor/creatures_editor_ui.tscn" )
Globals.goto_scene( "res://scenes/creatures/creatures_creation.tscn" )
Globals.goto_scene( "res://scenes/creatures/creatures_creation.tscn" )
func _on_creatures_menu_ui_cancel_pressed():
$main_menu.show()
$main_menu.show()
func _on_creatures_menu_ui_select_pressed( filename ):
self.creature_selected_filename = filename
Globals.goto_scene( "res://scenes/game/game.tscn" )
self.creature_selected_filename = filename
Globals.goto_scene( "res://scenes/game/game.tscn" )
func _on_creature_editor_ui_valid_pressed():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_creature_editor_ui_cencel_pressed():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_main_menu_quit_pressed():
get_tree().quit()
get_tree().quit()
func _on_connexion_ok():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_connection_error( message ):
$main_menu/screen_box/login_box/error.text = message
$main_menu/screen_box/login_box/error.text = message

View file

@ -17,52 +17,52 @@ var focused_object = null
var focus_index = 0
static func get_input_direction() -> Vector3:
return Vector3(
Input.get_action_strength("move_strafe_right") - Input.get_action_strength("move_strafe_left"),
0,
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
return Vector3(
Input.get_action_strength("move_strafe_right") - Input.get_action_strength("move_strafe_left"),
0,
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
func _input( event ):
# Run.
if event.is_action_pressed( "move_toggle_run" ):
$character.is_running = not $character.is_running
# Run.
if event.is_action_pressed( "move_toggle_run" ):
$character.is_running = not $character.is_running
# Camera.
if event.is_action( "camera_zoom_in" ):
self.zoom_level += 1
elif event.is_action( "camera_zoom_out" ):
self.zoom_level -= 1
# Camera.
if event.is_action( "camera_zoom_in" ):
self.zoom_level += 1
elif event.is_action( "camera_zoom_out" ):
self.zoom_level -= 1
if event.is_action_pressed( "camera_reset_view" ):
$character/spring_arm.rotation = Vector3.ZERO
self.zoom_level = 0
if event.is_action_pressed( "camera_reset_view" ):
$character/spring_arm.rotation = Vector3.ZERO
self.zoom_level = 0
if event.is_action_pressed( "camera_switch" ):
if self.camera_tps.current:
self.camera_fps.make_current()
$character/spring_arm.rotation = Vector3.ZERO
if event.is_action_pressed( "camera_switch" ):
if self.camera_tps.current:
self.camera_fps.make_current()
$character/spring_arm.rotation = Vector3.ZERO
# self.hide()
else:
self.camera_tps.make_current()
else:
self.camera_tps.make_current()
# self.show()
if event is InputEventMouseMotion:
self.mouse_delta = event.relative
if event is InputEventMouseMotion:
self.mouse_delta = event.relative
# Jump.
if event.is_action_pressed( "move_jump" ) and not $character.is_falling:
$character.is_jump_started = true
# Jump.
if event.is_action_pressed( "move_jump" ) and not $character.is_falling:
$character.is_jump_started = true
if event.is_action_pressed( "interact" ):
self.interact()
if event.is_action_pressed( "interact" ):
self.interact()
if event.is_action_pressed( "focus_next" ):
self.focus_next()
if event.is_action_pressed( "focus_next" ):
self.focus_next()
# if not self.get_tree().get_root().get_node( "main/scene/game" ).is_on_ui:
# if event.is_action_pressed( "action_ready_weapon" ):
@ -77,19 +77,19 @@ func _input( event ):
func _process( delta ):
$character.direction = self.get_input_direction()
$character.direction = self.get_input_direction()
# Rotation.
if not Input.is_key_pressed( KEY_SHIFT ) and not $character.is_jump_started:
$character.orientation = (Input.get_action_strength("move_turn_left") - Input.get_action_strength("move_turn_right"))
else:
$character.orientation = 0.0
# Rotation.
if not Input.is_key_pressed( KEY_SHIFT ) and not $character.is_jump_started:
$character.orientation = (Input.get_action_strength("move_turn_left") - Input.get_action_strength("move_turn_right"))
else:
$character.orientation = 0.0
# Camera.
if not self.mouse_delta == Vector2.ZERO and self.camera_tps.current:
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
$character/spring_arm.rotate_y( -self.mouse_delta.x * 0.01 )
self.camera_tps.rotate_x( self.mouse_delta.y * 0.01 )
# Camera.
if not self.mouse_delta == Vector2.ZERO and self.camera_tps.current:
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
$character/spring_arm.rotate_y( -self.mouse_delta.x * 0.01 )
self.camera_tps.rotate_x( self.mouse_delta.y * 0.01 )
# if not $character.velocity.x == 0.0 or not $character.velocity.z == 0.0:
# var velocity_without_gravity = $character.velocity
@ -100,125 +100,125 @@ func _process( delta ):
## $crosshair.material.set_shader_param( "spread", 1 )
# $character/target_spring_arm/crosshair.scale = Vector3( 1.0, 1.0, 1.0 )
if $character.is_weapon_ready:
if $character.get_main_weapon_node():
$character/crosshair.show()
# $character/target_spring_arm.global_transform.origin = $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.origin
# $character/target_spring_arm.look_at_from_position( $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.origin, $character.get_main_weapon_node().get_node( "target" ).global_transform.origin, Vector3( 0.0, 0.0, -1.0 ) )
# $character/target_spring_arm.global_transform.basis.y = $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.basis.y
$character/crosshair.global_transform.origin = $character.get_main_weapon_node().get_node( "bullet_exit/target_spring_arm/target" ).global_transform.origin
else:
$character/target_spring_arm.hide()
if $character.is_weapon_ready:
if $character.get_main_weapon_node():
$character/crosshair.show()
# $character/target_spring_arm.global_transform.origin = $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.origin
# $character/target_spring_arm.look_at_from_position( $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.origin, $character.get_main_weapon_node().get_node( "target" ).global_transform.origin, Vector3( 0.0, 0.0, -1.0 ) )
# $character/target_spring_arm.global_transform.basis.y = $character.get_main_weapon_node().get_node( "bullet_exit" ).global_transform.basis.y
$character/crosshair.global_transform.origin = $character.get_main_weapon_node().get_node( "bullet_exit/target_spring_arm/target" ).global_transform.origin
else:
$character/target_spring_arm.hide()
# Values reset.
self.mouse_delta = Vector2.ZERO
# Values reset.
self.mouse_delta = Vector2.ZERO
# Debug.
#var old_collider = null
func _physics_process(delta):
var space_state = get_world().direct_space_state
# Camera.
self.camera_position = Vector3( 0.0, 2 - 0.1*self.zoom_level, -2 + 0.1*self.zoom_level )
$character/spring_arm/camera_position.translation = self.camera_position
var global_camera_position = $character/spring_arm/camera_position.global_transform.origin
var result = space_state.intersect_ray($character/look_at.global_transform.origin, global_camera_position, [self])
var space_state = get_world().direct_space_state
# Camera.
self.camera_position = Vector3( 0.0, 2 - 0.1*self.zoom_level, -2 + 0.1*self.zoom_level )
$character/spring_arm/camera_position.translation = self.camera_position
var global_camera_position = $character/spring_arm/camera_position.global_transform.origin
var result = space_state.intersect_ray($character/look_at.global_transform.origin, global_camera_position, [self])
if result:
self.camera_tps.global_transform.origin = result.position
if result:
self.camera_tps.global_transform.origin = result.position
# self.camera_tps.look_at( $character/look_at.global_transform.origin, Vector3( 0.0, 1.0, 0.0) )
else:
self.camera_tps.translation = self.camera_position
else:
self.camera_tps.translation = self.camera_position
# self.camera_tps.look_at( $character/look_at.global_transform.origin, Vector3( 0.0, 1.0, 0.0) )
func interact( p_object = null ):
if p_object and p_object.has_method( "interact" ):
p_object.interact( $character/creature.creature )
else:
if self.focused_object and self.focused_object.has_method( "interact" ):
self.focused_object.interact( $character/creature.creature )
elif self.focused_object and self.focused_object.get_parent() and self.focused_object.get_parent().has_method( "interact" ):
self.focused_object.get_parent().interact( $character/creature.creature )
if p_object and p_object.has_method( "interact" ):
p_object.interact( $character/creature.creature )
else:
if self.focused_object and self.focused_object.has_method( "interact" ):
self.focused_object.interact( $character/creature.creature )
elif self.focused_object and self.focused_object.get_parent() and self.focused_object.get_parent().has_method( "interact" ):
self.focused_object.get_parent().interact( $character/creature.creature )
if not self.focused_object:
self.proximity_objects.erase( self.focused_object )
self.update_focused_object()
if not self.focused_object:
self.proximity_objects.erase( self.focused_object )
self.update_focused_object()
func focus_next():
self.focus_index += 1
if self.focus_index >= self.proximity_objects.size():
self.focus_index = 0
self.focus_index += 1
if self.focus_index >= self.proximity_objects.size():
self.focus_index = 0
self.update_focused_object()
self.update_focused_object()
func set_focus_on( p_object, p_focus ):
if p_object and p_object.has_method( "set_focus" ):
p_object.set_focus( p_focus )
elif p_object and p_object.get_parent() and p_object.get_parent().has_method( "set_focus" ):
p_object.get_parent().set_focus( p_focus )
if p_object and p_object.has_method( "set_focus" ):
p_object.set_focus( p_focus )
elif p_object and p_object.get_parent() and p_object.get_parent().has_method( "set_focus" ):
p_object.get_parent().set_focus( p_focus )
func update_focused_object():
if self.focus_index >= self.proximity_objects.size():
self.focus_index = 0
if self.focus_index >= self.proximity_objects.size():
self.focus_index = 0
var old_focused_object = self.focused_object
if self.proximity_objects.size() > 0:
self.focused_object = self.proximity_objects[ self.focus_index ]
else:
self.focused_object = null
var old_focused_object = self.focused_object
if self.proximity_objects.size() > 0:
self.focused_object = self.proximity_objects[ self.focus_index ]
else:
self.focused_object = null
if old_focused_object:
self.set_focus_on( old_focused_object, false )
if self.focused_object:
self.set_focus_on( self.focused_object, true )
emit_signal( "new_focused_object", self.focused_object.name )
if old_focused_object:
self.set_focus_on( old_focused_object, false )
if self.focused_object:
self.set_focus_on( self.focused_object, true )
emit_signal( "new_focused_object", self.focused_object.name )
func _on_interact_area_body_entered(body):
if not body == $character:
self.proximity_objects.push_back( body )
self.update_focused_object()
if not body == $character:
self.proximity_objects.push_back( body )
self.update_focused_object()
func _on_interact_area_body_exited(body):
if not body == $character:
self.proximity_objects.erase( body )
self.update_focused_object()
if not body == $character:
self.proximity_objects.erase( body )
self.update_focused_object()
func _on_character_equip(p_slot, p_item):
emit_signal( "equip", p_slot, p_item )
var weapons = $character.get_weapons()
if weapons.size() > 0:
emit_signal( "equip", p_slot, p_item )
var weapons = $character.get_weapons()
if weapons.size() > 0:
var min_range = null
for weapon in weapons:
if not min_range:
min_range = weapon.get_data( "range" )
else:
min_range = min( min_range, weapon.get_data( "range" ) )
$character.get_main_weapon_node().get_node( "bullet_exit/target_spring_arm" ).spring_length = min_range
var min_range = null
for weapon in weapons:
if not min_range:
min_range = weapon.get_data( "range" )
else:
min_range = min( min_range, weapon.get_data( "range" ) )
$character.get_main_weapon_node().get_node( "bullet_exit/target_spring_arm" ).spring_length = min_range
func _on_character_unequip(p_slot):
emit_signal( "unequip", p_slot )
emit_signal( "unequip", p_slot )
func _on_crosshair_area_body_entered(body):
if not body == $character:
if body is preload( "res://scenes/characters/character.gd" ):
if body.player_relation == body.PLAYER_RELATION.ennemy:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.red
elif body.player_relation == body.PLAYER_RELATION.friend:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.green
else:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.white
if not body == $character:
if body is preload( "res://scenes/characters/character.gd" ):
if body.player_relation == body.PLAYER_RELATION.ennemy:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.red
elif body.player_relation == body.PLAYER_RELATION.friend:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.green
else:
$character/crosshair.get_surface_material( 0 ).albedo_color = Color.white
func _on_crosshair_area_body_exited(body):
if not body == $character:
$character/target_spring_arm/crosshair.get_surface_material( 0 ).albedo_color = Color.white
if not body == $character:
$character/target_spring_arm/crosshair.get_surface_material( 0 ).albedo_color = Color.white

View file

@ -16,81 +16,81 @@ var _is_sprinting = false
func _ready():
# $camera.make_current()
$model/ra/spring_arm/camera.make_current()
$model/ra/spring_arm/camera.make_current()
func _input( event ):
if event.is_action_pressed( "toggle_sprint" ):
self._is_sprinting = not self._is_sprinting
if event.is_action_pressed( "toggle_sprint" ):
self._is_sprinting = not self._is_sprinting
func _process( delta ):
var input_direction: = self.get_input_direction()
var input_direction: = self.get_input_direction()
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = self.camera.global_transform.basis.z * input_direction.z
var right: Vector3 = self.camera.global_transform.basis.x * input_direction.x
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# Calculate a move direction vector relative to the camera
# The basis stores the (right, up, -forwards) vectors of our camera.
var forwards: Vector3 = self.camera.global_transform.basis.z * input_direction.z
var right: Vector3 = self.camera.global_transform.basis.x * input_direction.x
var move_direction: = forwards + right
if move_direction.length() > 1.0:
move_direction = move_direction.normalized()
move_direction.y = 0
# skin.move_direction = move_direction
# Rotation
# Rotation
# if move_direction:
# var target_direction = player.transform.looking_at(player.global_transform.origin + move_direction, Vector3.UP)
# player.transform = player.transform.interpolate_with(target_direction, rotation_speed_factor * delta)
player.rotate_y( rotation_speed_factor * (Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")) )
player.rotate_y( rotation_speed_factor * (Input.get_action_strength("turn_left") - Input.get_action_strength("turn_right")) )
# Movement
velocity = self.calculate_velocity(velocity, move_direction, delta)
velocity = player.move_and_slide(velocity, Vector3.UP, true)
# Movement
velocity = self.calculate_velocity(velocity, move_direction, delta)
velocity = player.move_and_slide(velocity, Vector3.UP, true)
if input_direction:
if not input_direction.z == 0.0:
if self.is_sprinting():
$model/ra/model/AnimationPlayer.play( "run" )
else:
$model/ra/model/AnimationPlayer.play( "walk" )
elif input_direction.x > 0.0:
$model/ra/model/AnimationPlayer.play( "strafe_right" )
elif input_direction.x < 0.0:
$model/ra/model/AnimationPlayer.play( "strafe_left" )
if input_direction:
if not input_direction.z == 0.0:
if self.is_sprinting():
$model/ra/model/AnimationPlayer.play( "run" )
else:
$model/ra/model/AnimationPlayer.play( "walk" )
elif input_direction.x > 0.0:
$model/ra/model/AnimationPlayer.play( "strafe_right" )
elif input_direction.x < 0.0:
$model/ra/model/AnimationPlayer.play( "strafe_left" )
else:
$model/ra/model/AnimationPlayer.play( "idle" )
else:
$model/ra/model/AnimationPlayer.play( "idle" )
static func get_input_direction() -> Vector3:
return Vector3(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
0,
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
return Vector3(
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
0,
Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
)
func calculate_velocity(
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
var velocity_new := move_direction
if self.is_sprinting():
velocity_new *= sprint_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
velocity_current: Vector3,
move_direction: Vector3,
delta: float
) -> Vector3:
var velocity_new := move_direction
if self.is_sprinting():
velocity_new *= sprint_speed
else:
velocity_new *= move_speed
if velocity_new.length() > max_speed:
velocity_new = velocity_new.normalized() * max_speed
velocity_new.y = velocity_current.y + gravity * delta
return velocity_new
return velocity_new
func load_creature( filename ):
self.creature = Creatures.Ra_old.new()
self.creature.from_file( filename )
self.creature = Creatures.Ra_old.new()
self.creature.from_file( filename )
# # version statique.
# $model/ra/model/body.set( "blend_shapes/Boobs", self.creature.female_boobs )
@ -101,33 +101,33 @@ func load_creature( filename ):
# $model/ra/model/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
# $model/ra/model/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color )
#
# Version animée.
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Boobs", self.creature.female_boobs )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Female_hip", self.creature.female_hip )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Pack", self.creature.male_pack )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Throat", self.creature.male_throat )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color )
# Version animée.
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Boobs", self.creature.female_boobs )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Female_hip", self.creature.female_hip )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Pack", self.creature.male_pack )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Male_Throat", self.creature.male_throat )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.set( "blend_shapes/Pregnant", self.creature.female_pregnant )
$model/ra/model/metarig/Skeleton/body.get_surface_material( 0 ).set_shader_param( "albedo", self.creature.color )
func is_sprinting():
if (not self._is_sprinting and Input.is_action_pressed( "sprint" )) \
or (self._is_sprinting and not Input.is_action_pressed( "sprint" )) \
:
return true
return false
if (not self._is_sprinting and Input.is_action_pressed( "sprint" )) \
or (self._is_sprinting and not Input.is_action_pressed( "sprint" )) \
:
return true
return false
func rotate_camera_arm( p_axis, p_angle_degree ):
$model/ra/spring_arm.rotate( p_axis, p_angle_degree )
$model/ra/spring_arm.rotate( p_axis, p_angle_degree )
func rotate_camera( p_axis, p_angle_degree ):
$model/ra/spring_arm/camera.rotate( p_axis, p_angle_degree )
$model/ra/spring_arm/camera.rotate( p_axis, p_angle_degree )
func move_camera( p_translation ):
$model/ra/spring_arm/camera.translate( p_translation )
$model/ra/spring_arm/camera.translate( p_translation )
func reset_camera():
$model/ra/spring_arm.translation = Vector3( 0, 2, 2 )
$model/ra/spring_arm.rotation_degrees = Vector3( 0.0, 0.0, 0.0 )
$model/ra/spring_arm/camera.translation = Vector3( 0.0, 0.0, 0.0 )
$model/ra/spring_arm/camera.rotation_degrees = Vector3( -14, 0, 0.328 )
$model/ra/spring_arm.translation = Vector3( 0, 2, 2 )
$model/ra/spring_arm.rotation_degrees = Vector3( 0.0, 0.0, 0.0 )
$model/ra/spring_arm/camera.translation = Vector3( 0.0, 0.0, 0.0 )
$model/ra/spring_arm/camera.rotation_degrees = Vector3( -14, 0, 0.328 )