forked from unfa/liblast
Merge branch 'main' of ssh://git.gieszer.link:2222/unfa/liblast
commit
95dfdad76d
|
@ -0,0 +1,376 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
inkscape:export-ydpi="96"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-filename="/data/Projects/Games/Liblast/Design/Liblast logo bg3.png"
|
||||
sodipodi:docname="Liblast logo 05.svg"
|
||||
inkscape:version="1.1 (c4e8f9ed74, 2021-05-24)"
|
||||
id="svg5"
|
||||
version="1.1"
|
||||
viewBox="0 0 270.93335 270.93335"
|
||||
height="1024"
|
||||
width="1024"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview7"
|
||||
pagecolor="#181818"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.85418262"
|
||||
inkscape:cx="495.21026"
|
||||
inkscape:cy="530.91691"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1006"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
fit-margin-top="0"
|
||||
fit-margin-left="0"
|
||||
fit-margin-right="0"
|
||||
fit-margin-bottom="0"
|
||||
units="px"
|
||||
showguides="false"
|
||||
inkscape:guide-bbox="true">
|
||||
<sodipodi:guide
|
||||
position="259.4941,179.9198"
|
||||
orientation="-0.97920786,0.20285948"
|
||||
id="guide9012" />
|
||||
</sodipodi:namedview>
|
||||
<defs
|
||||
id="defs2">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient17375">
|
||||
<stop
|
||||
style="stop-color:#460000;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop17371" />
|
||||
<stop
|
||||
style="stop-color:#bf0000;stop-opacity:0.99774313"
|
||||
offset="1"
|
||||
id="stop17373" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient16613">
|
||||
<stop
|
||||
style="stop-color:#ea2400;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop16609" />
|
||||
<stop
|
||||
style="stop-color:#fe7600;stop-opacity:0"
|
||||
offset="1"
|
||||
id="stop16611" />
|
||||
</linearGradient>
|
||||
<pattern
|
||||
inkscape:collect="always"
|
||||
patternUnits="userSpaceOnUse"
|
||||
width="2"
|
||||
height="1"
|
||||
patternTransform="translate(0,0) scale(10,10)"
|
||||
id="Strips1_1"
|
||||
inkscape:stockid="Stripes 1:1">
|
||||
<rect
|
||||
style="fill:black;stroke:none"
|
||||
x="0"
|
||||
y="-0.5"
|
||||
width="1"
|
||||
height="2"
|
||||
id="rect11445" />
|
||||
</pattern>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient10513">
|
||||
<stop
|
||||
style="stop-color:#ea2400;stop-opacity:1"
|
||||
offset="0"
|
||||
id="stop10509" />
|
||||
<stop
|
||||
style="stop-color:#fe7600;stop-opacity:1"
|
||||
offset="1"
|
||||
id="stop10511" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient10513"
|
||||
id="linearGradient12684"
|
||||
x1="18.811222"
|
||||
y1="610.37628"
|
||||
x2="18.811222"
|
||||
y2="309.77011"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath12933">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text12937"
|
||||
transform="matrix(0,-3.2231088,2.3221071,0,-1107.4744,-1736.67)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan12935"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#ff0000;fill-opacity:1">LIBLAST</tspan></text>
|
||||
</clipPath>
|
||||
<mask
|
||||
maskUnits="userSpaceOnUse"
|
||||
id="mask15334">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:#fdfdfd;stroke-width:0.605657;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text15338"
|
||||
transform="matrix(2.6211221,0,0,2.6211221,1931.39,-1099.5214)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan15336"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#ffffff;fill-opacity:1;stroke:#fdfdfd;stroke-width:0.605657;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1">LIBLAST</tspan></text>
|
||||
</mask>
|
||||
<filter
|
||||
style="color-interpolation-filters:sRGB;"
|
||||
inkscape:label="Blur"
|
||||
id="filter3832"
|
||||
x="-0.19044651"
|
||||
y="-0.013029358"
|
||||
width="1.3861206"
|
||||
height="1.0135112">
|
||||
<feGaussianBlur
|
||||
stdDeviation="5.935 0.01"
|
||||
result="fbSourceGraphic"
|
||||
id="feGaussianBlur3830" />
|
||||
<feColorMatrix
|
||||
result="fbSourceGraphicAlpha"
|
||||
in="fbSourceGraphic"
|
||||
values="0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 1 0"
|
||||
id="feColorMatrix3872" />
|
||||
<feGaussianBlur
|
||||
id="feGaussianBlur3874"
|
||||
stdDeviation="13.0404 0.01"
|
||||
result="blur"
|
||||
in="fbSourceGraphic" />
|
||||
</filter>
|
||||
<filter
|
||||
inkscape:label="Rough and Glossy"
|
||||
inkscape:menu="Textures"
|
||||
inkscape:menu-tooltip="Crumpled glossy paper effect which can be used for pictures as for objects"
|
||||
style="color-interpolation-filters:sRGB;"
|
||||
id="filter4002"
|
||||
x="-4.8355243e-10"
|
||||
y="-4.8355243e-10"
|
||||
width="1"
|
||||
height="1">
|
||||
<feTurbulence
|
||||
type="turbulence"
|
||||
numOctaves="7"
|
||||
baseFrequency="0.55713113245630697"
|
||||
seed="55"
|
||||
result="result0"
|
||||
id="feTurbulence3984" />
|
||||
<feDiffuseLighting
|
||||
surfaceScale="4"
|
||||
diffuseConstant="1"
|
||||
kernelUnitLength="1"
|
||||
result="result1"
|
||||
in="result0"
|
||||
id="feDiffuseLighting3988"
|
||||
lighting-color="rgb(255,255,255)">
|
||||
<feDistantLight
|
||||
azimuth="235"
|
||||
elevation="60"
|
||||
id="feDistantLight3986" />
|
||||
</feDiffuseLighting>
|
||||
<feSpecularLighting
|
||||
in="result0"
|
||||
surfaceScale="3"
|
||||
specularConstant="1"
|
||||
specularExponent="25"
|
||||
kernelUnitLength="1"
|
||||
result="result3"
|
||||
id="feSpecularLighting3992"
|
||||
lighting-color="rgb(0,0,0)">
|
||||
<feDistantLight
|
||||
azimuth="235"
|
||||
elevation="55"
|
||||
id="feDistantLight3990" />
|
||||
</feSpecularLighting>
|
||||
<feComposite
|
||||
in="result1"
|
||||
in2="SourceGraphic"
|
||||
operator="arithmetic"
|
||||
k1="1"
|
||||
result="result2"
|
||||
id="feComposite3994" />
|
||||
<feComposite
|
||||
in="result2"
|
||||
in2="result3"
|
||||
operator="arithmetic"
|
||||
k2="1"
|
||||
k3="1"
|
||||
result="result4"
|
||||
id="feComposite3996" />
|
||||
<feComposite
|
||||
in2="SourceAlpha"
|
||||
operator="in"
|
||||
in="result4"
|
||||
result="fbSourceGraphic"
|
||||
id="feComposite3998" />
|
||||
<feDisplacementMap
|
||||
scale="7"
|
||||
yChannelSelector="G"
|
||||
xChannelSelector="R"
|
||||
in2="result0"
|
||||
id="feDisplacementMap4000" />
|
||||
</filter>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient16613"
|
||||
id="linearGradient16543"
|
||||
x1="-727.40527"
|
||||
y1="480.88785"
|
||||
x2="-633.90906"
|
||||
y2="480.88785"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient17375"
|
||||
id="linearGradient17377"
|
||||
x1="-727.99377"
|
||||
y1="476.11346"
|
||||
x2="-634.00549"
|
||||
y2="476.11346"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-7.4556532,-26.258593)">
|
||||
<rect
|
||||
style="fill:#000000;fill-opacity:1;stroke:#4d4d4d;stroke-width:0;stroke-linecap:round;stroke-opacity:1;paint-order:markers stroke fill"
|
||||
id="rect4249"
|
||||
width="1225.7052"
|
||||
height="1086.7213"
|
||||
x="-71.705978"
|
||||
y="-35.076351"
|
||||
transform="matrix(0.26458333,0,0,0.26458333,7.4556532,26.258593)" />
|
||||
<g
|
||||
id="g3870"
|
||||
transform="matrix(0.93228464,0,0,0.93228464,-241.87801,10.951286)"
|
||||
style="stroke:#4d4d4d;filter:url(#filter3832);fill:#552200">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#552200;fill-opacity:1;stroke:#4d4d4d;stroke-opacity:1"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text3864"
|
||||
transform="matrix(2.5001014,0,0,2.5001013,2118.7194,-1041.0983)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3862"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#552200;fill-opacity:1;stroke:#4d4d4d;stroke-opacity:1">LIBLAST</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#552200;fill-opacity:1;stroke:#4d4d4d;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text3868"
|
||||
transform="matrix(0.57875655,0,0,0.57875655,715.93357,-71.885784)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3866"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#552200;fill-opacity:1;stroke:#4d4d4d;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill">A LIBRE MULTIPLAYER FPS GAME</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g3656"
|
||||
transform="matrix(0.93228464,0,0,0.93228464,-241.87801,10.951286)"
|
||||
style="stroke:#000000;filter:url(#filter3832);fill:#550000">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#550000;fill-opacity:1;stroke:#000000;stroke-opacity:1"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text3380"
|
||||
transform="matrix(2.5001014,0,0,2.5001013,2118.7194,-1041.0983)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3378"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#550000;fill-opacity:1;stroke:#000000;stroke-opacity:1">LIBLAST</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#550000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text3388"
|
||||
transform="matrix(0.57875655,0,0,0.57875655,715.93357,-71.885784)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan3386"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#550000;fill-opacity:1;stroke:#000000;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill">A LIBRE MULTIPLAYER FPS GAME</tspan></text>
|
||||
</g>
|
||||
<g
|
||||
id="g16576"
|
||||
transform="matrix(0.88923981,0,0,0.88923981,15.902683,18.089503)">
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:none;fill-opacity:1;stroke:url(#linearGradient17377);stroke-opacity:1"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text15382"
|
||||
transform="matrix(2.6211221,0,0,2.621122,1931.39,-1099.5214)"><tspan
|
||||
id="tspan15380"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:none;fill-opacity:1;stroke:url(#linearGradient17377);stroke-opacity:1"
|
||||
sodipodi:role="line">LIBLAST</tspan></text>
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#fd4500;fill-opacity:1;stroke:none;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
id="text7061"
|
||||
transform="matrix(0.60677203,0,0,0.60677203,460.70045,-83.392836)"><tspan
|
||||
sodipodi:role="line"
|
||||
id="tspan7059"
|
||||
x="-728.78284"
|
||||
y="490.40057"
|
||||
style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:'Open Sans Condensed';-inkscape-font-specification:'Open Sans Condensed, ';fill:#fd4500;fill-opacity:1;stroke:none;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill">A LIBRE MULTIPLAYER FPS GAME</tspan></text>
|
||||
<rect
|
||||
style="mix-blend-mode:normal;fill:url(#linearGradient12684);fill-opacity:1;stroke:none;stroke-width:7.55906;stroke-linecap:round;paint-order:markers stroke fill"
|
||||
id="rect12596"
|
||||
width="109.6572"
|
||||
height="339.00281"
|
||||
x="-60.158474"
|
||||
y="290.37952"
|
||||
transform="matrix(0,1.1287688,-0.81322793,0,518.38479,149.86446)"
|
||||
clip-path="url(#clipPath12933)" />
|
||||
</g>
|
||||
<g
|
||||
id="g8930"
|
||||
transform="matrix(1.4453118,0,0,1.4453118,-5.0445275,-13.447954)">
|
||||
<g
|
||||
id="g7697"
|
||||
transform="matrix(6.5378298,0,0,6.5378298,1307.5503,-702.31895)" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 15 KiB |
|
@ -2,7 +2,8 @@ extends CharacterBody3D
|
|||
|
||||
@export var mouse_sensitivity := 0.35
|
||||
|
||||
@onready var hud = get_tree().root.get_node("Main").get_node("HUD")
|
||||
@onready var main = get_tree().root.get_node("Main")
|
||||
@onready var hud = main.get_node("HUD")
|
||||
@onready var crosshair = hud.get_node("Crosshair")
|
||||
@onready var vignette = hud.get_node("Vignette")
|
||||
|
||||
|
@ -25,29 +26,8 @@ extends CharacterBody3D
|
|||
@onready var climb_check_y = climb_check.position.y
|
||||
@onready var ground_check_y = ground_check.position.y
|
||||
|
||||
class PlayerInfo:
|
||||
var name: String
|
||||
var team: int
|
||||
var color: Color
|
||||
var focus: int #"res://Main.gd".GameFocus.GAME
|
||||
|
||||
func _init(name: String, team: int, color: Color):
|
||||
self.name = name
|
||||
self.team = team
|
||||
self.color = color
|
||||
self.focus = 0 #false
|
||||
|
||||
func serialize():
|
||||
return {
|
||||
'name': self.name,
|
||||
'team': str(self.team),
|
||||
'color': self.color.to_html(),
|
||||
'focus': self.focus,
|
||||
}
|
||||
|
||||
var input_active = false
|
||||
|
||||
var player_info: PlayerInfo
|
||||
|
||||
var base_fov = 90
|
||||
var view_zoom_target := 1.0
|
||||
|
@ -94,21 +74,6 @@ var jump := 14
|
|||
var velocity := Vector3.ZERO
|
||||
var gravity_vec := Vector3.ZERO
|
||||
|
||||
@puppetsync func set_info(info) -> void:
|
||||
player_info = PlayerInfo.new(info['name'], info['team'].to_int(), Color(info['color']))
|
||||
print("set_info - rpc called from ", get_tree().get_rpc_sender_id())
|
||||
|
||||
@master func update_info() -> void:
|
||||
rpc(&'set_info', player_info.serialize())
|
||||
|
||||
@master func generate_info() -> void:
|
||||
var player_name = ""
|
||||
for i in range(0, 4):
|
||||
player_name += ['a','b','c', 'd', 'e', 'f'][randi() % 5]
|
||||
|
||||
var color = Color(randf(),randf(),randf())
|
||||
rpc(&'set_info', PlayerInfo.new(player_name, 0, color).serialize() )
|
||||
|
||||
@puppet func update_movement(player_transform, head_rotation):
|
||||
global_transform = player_transform
|
||||
head.set_rotation(head_rotation)
|
||||
|
@ -117,7 +82,7 @@ func _ready() -> void:
|
|||
#Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
view_zoom_target = 1.0
|
||||
|
||||
generate_info()
|
||||
# generate_info()
|
||||
|
||||
rpc_config(&'move_and_slide', MultiplayerAPI.RPC_MODE_REMOTE)
|
||||
rpc_config(&"aim", MultiplayerAPI.RPC_MODE_REMOTE)
|
||||
|
|
|
@ -53,9 +53,7 @@ func _unhandled_input(_event) -> void:
|
|||
|
||||
# doesn't work over network due to missing RPC implementation in Godot 4
|
||||
@remotesync func chat_message(sender_id: int, recipient_team, message: String) -> void:
|
||||
var sender_info = main.get_node("Players").get_node(str(sender_id)).player_info
|
||||
|
||||
|
||||
var sender_info = main.player_list[sender_id]
|
||||
chat_history.append_bbcode('\n' + '[b][color=' + sender_info.color.to_html() +']' + str(sender_info.name) + '[/color][/b] : [i]' + message + '[/i]')
|
||||
|
||||
func _on_Editor_text_submitted(new_text):
|
||||
|
|
124
Game/Main.gd
124
Game/Main.gd
|
@ -20,24 +20,73 @@ var player_scene = preload("res://Assets/Characters/Player.tscn")
|
|||
@onready var chat = hud.get_node("Chat")
|
||||
var local_player: Node = null
|
||||
|
||||
class PlayerInfo:
|
||||
var name: String
|
||||
var team: int
|
||||
var color: Color
|
||||
var focus: GameFocus
|
||||
|
||||
class PlayerList:
|
||||
var items = {}
|
||||
func _init():#name: String, team: int, color: Color):
|
||||
# self.name = name
|
||||
# self.team = team
|
||||
# self.color = color
|
||||
# self.focus = 0
|
||||
|
||||
func store(pid, item):
|
||||
items[pid] = item
|
||||
var player_name = ""
|
||||
for i in range(0, 4):
|
||||
player_name += ['a','b','c', 'd', 'e', 'f'][randi() % 5]
|
||||
self.name = player_name
|
||||
self.color = Color(randf(),randf(),randf())
|
||||
self.team = 0
|
||||
|
||||
func erase(pid):
|
||||
items.erase(pid)
|
||||
func serialize():
|
||||
return {
|
||||
'name': self.name,
|
||||
'team': str(self.team),
|
||||
'color': self.color.to_html(),
|
||||
'focus': self.focus,
|
||||
}
|
||||
func set(name: String, team: int, color: Color, focus: int):
|
||||
self.name = name
|
||||
self.team = team
|
||||
self.color = color
|
||||
self.focus = focus
|
||||
|
||||
func update(pid, item):
|
||||
if items[pid]:
|
||||
items[pid] = item
|
||||
func deserialize(info):
|
||||
#var info_parsed = info.parse_json(info)
|
||||
self.name = info['name']
|
||||
self.team = info['team'].to_int()
|
||||
self.color = Color.html(info['color'])
|
||||
self.focus = info['focus']
|
||||
|
||||
func get():
|
||||
return items
|
||||
#func generate():
|
||||
|
||||
var player_list = []
|
||||
|
||||
var local_player_info: PlayerInfo
|
||||
|
||||
#class PlayerList:
|
||||
# var items = {}
|
||||
#
|
||||
# func store(pid, item):
|
||||
# items[pid] = item
|
||||
#
|
||||
# func erase(pid):
|
||||
# items.erase(pid)
|
||||
#
|
||||
# func update(pid, item):
|
||||
# if items[pid]:
|
||||
# items[pid] = item
|
||||
#
|
||||
# func get():
|
||||
# return items
|
||||
|
||||
var player_list = {}:
|
||||
set(player_list):
|
||||
if role in [NetworkRole.SERVER, NetworkRole.DEDICATED_SERVER]:
|
||||
for i in player_list:
|
||||
rpc(&'player_list_update', i.serialize())
|
||||
else:
|
||||
rpc_id(1, &'player_list_update', player_list.serialize())
|
||||
|
||||
var focus = GameFocus.MENU :
|
||||
set(new_focus):
|
||||
|
@ -61,7 +110,15 @@ var focus = GameFocus.MENU :
|
|||
|
||||
focus = new_focus
|
||||
|
||||
#@remote set_info(info) -> void:
|
||||
# player_info = PlayerInfo.new(info['name'], info['team'].to_int(), Color(info['color']))
|
||||
# print("set_info - rpc called from ", get_tree().get_rpc_sender_id())
|
||||
|
||||
#@master func update_info() -> void:
|
||||
# rpc(&'set_info', player_info.serialize())
|
||||
|
||||
#@master func generate_info() -> void:
|
||||
#rpc(&'set_info', PlayerInfo.new(player_name, 0, color).serialize() )
|
||||
|
||||
func _input(_event) -> void:
|
||||
if Input.is_action_just_pressed("ui_cancel"):
|
||||
|
@ -71,6 +128,17 @@ func _input(_event) -> void:
|
|||
focus = GameFocus.GAME
|
||||
|
||||
|
||||
#@remote func update_player_list(player_list):
|
||||
# self.player_list = player_list
|
||||
|
||||
@remote func player_list_update(info):
|
||||
var new_info = PlayerInfo.deserialize(info)
|
||||
var id = get_tree().get_rpc_sender_id()
|
||||
print("Updating player_list wit hnew info: ", new_info)
|
||||
player_list[id] = new_info
|
||||
print("Player list: ", player_list)
|
||||
print("Player list item for id ", id, ": ", player_list[id])
|
||||
|
||||
func create_player(id: int, is_local: bool) -> void:
|
||||
var new_player
|
||||
|
||||
|
@ -78,7 +146,6 @@ func create_player(id: int, is_local: bool) -> void:
|
|||
new_player = player_scene.instance()
|
||||
else:
|
||||
new_player = player_scene.instantiate()
|
||||
|
||||
var spawnpoint = $Map/SpawnPoints.get_children()[randi() % len($Map/SpawnPoints.get_children())]
|
||||
new_player.name = str(id)
|
||||
new_player.global_transform = spawnpoint.global_transform
|
||||
|
@ -86,16 +153,20 @@ func create_player(id: int, is_local: bool) -> void:
|
|||
$Players.add_child(new_player)
|
||||
|
||||
if is_local:
|
||||
local_player = $Players.get_node(str(id))
|
||||
local_player = new_player #$Players.get_node(str(id))
|
||||
local_player.get_node("Head/Camera").current = true
|
||||
else:
|
||||
$Players.get_node(str(id) + "/Head/Camera").current = false
|
||||
var new_info = PlayerInfo.new()
|
||||
#new_info.generate()
|
||||
local_player_info = new_info
|
||||
rpc_id(1,&'player_list_update', local_player_info.serialize())
|
||||
|
||||
$NetworkTesting/TextEdit.text = local_player_info.name
|
||||
$NetworkTesting/ColorPickerButton.color = local_player_info.color
|
||||
else: # make sure we use the right camera
|
||||
new_player.get_node("Head/Camera").current = false
|
||||
if local_player:
|
||||
local_player.get_node("Head/Camera").current = true
|
||||
|
||||
$NetworkTesting/TextEdit.text = local_player.player_info.name
|
||||
$NetworkTesting/ColorPickerButton.color = local_player.player_info.color
|
||||
|
||||
func start_dedicated_server():
|
||||
role = NetworkRole.DEDICATED_SERVER
|
||||
peer.create_server(NET_PORT, 16)
|
||||
|
@ -122,8 +193,11 @@ func _on_Connect_pressed():
|
|||
func _player_connected(id) -> void:
|
||||
print("player connected, id: ", id)
|
||||
create_player(id, false)
|
||||
if local_player:
|
||||
local_player.rpc(&"update_info")
|
||||
# if local_player:
|
||||
# local_player.rpc(&"update_info")
|
||||
#
|
||||
# if role in [NetworkRole.SERVER, NetworkRole.DEDICATED_SERVER]:
|
||||
# rpc_id(id, "player_list_update", player_list)
|
||||
|
||||
func _player_disconnected(id) -> void:
|
||||
print("player disconnected, id: ", id)
|
||||
|
@ -134,6 +208,7 @@ func _connected_ok() -> void:
|
|||
create_player(id, true)
|
||||
focus = GameFocus.GAME
|
||||
role = NetworkRole.CLIENT
|
||||
# todo pull player list from server
|
||||
|
||||
func _connected_fail() -> void:
|
||||
print("connection to server failed")
|
||||
|
@ -155,10 +230,7 @@ func _ready() -> void:
|
|||
|
||||
|
||||
func _on_TextEdit_text_submitted(new_text):
|
||||
local_player.player_info.name = new_text
|
||||
local_player.update_info()
|
||||
|
||||
local_player_info.name = new_text
|
||||
|
||||
func _on_ColorPickerButton_color_changed(color):
|
||||
local_player.player_info.color = color
|
||||
local_player.update_info()
|
||||
local_player_info.color = color
|
||||
|
|
Loading…
Reference in New Issue