fix(network): isolate auth sessions for multiple instances on same pc
This commit is contained in:
+30
-30
@@ -50,10 +50,10 @@ The dock allows you to define and manage custom cell states:
|
||||
2. **Custom States**:
|
||||
- Add new states with the "Add Item State" button.
|
||||
- For each state, you can set:
|
||||
- Name
|
||||
- ID (used in scripts to reference the state)
|
||||
- Include in Randomize (toggle)
|
||||
- Randomize Percentage (when included in randomization)
|
||||
- Name
|
||||
- ID (used in scripts to reference the state)
|
||||
- Include in Randomize (toggle)
|
||||
- Randomize Percentage (when included in randomization)
|
||||
|
||||
3. **State Management**:
|
||||
- Edit existing states
|
||||
@@ -193,10 +193,10 @@ extends Node3D
|
||||
@onready var player = $Player
|
||||
|
||||
func _ready():
|
||||
player.enhanced_gridmap_path = enhanced_gridmap.get_path()
|
||||
player.player_path = player.get_path()
|
||||
player.cell_size = Vector3(2, 2, 2)
|
||||
player.use_diagonal_movement = true
|
||||
player.enhanced_gridmap_path = enhanced_gridmap.get_path()
|
||||
player.player_path = player.get_path()
|
||||
player.cell_size = Vector3(2, 2, 2)
|
||||
player.use_diagonal_movement = true
|
||||
```
|
||||
|
||||
This setup allows for click-to-move functionality on your EnhancedGridMap, with the player finding and following optimal paths while avoiding non-walkable cells.
|
||||
@@ -282,12 +282,12 @@ Override the `get_cell_cost` method in a script extending EnhancedGridMap to imp
|
||||
extends EnhancedGridMap
|
||||
|
||||
func get_cell_cost(x: int, z: int) -> float:
|
||||
var cell_item = get_cell_item(Vector3i(x, 0, z))
|
||||
match cell_item:
|
||||
0: return 1.0 # Normal cell
|
||||
1: return 2.0 # Slow terrain
|
||||
2: return 0.5 # Fast terrain
|
||||
_: return INF # Non-walkable
|
||||
var cell_item = get_cell_item(Vector3i(x, 0, z))
|
||||
match cell_item:
|
||||
0: return 1.0 # Normal cell
|
||||
1: return 2.0 # Slow terrain
|
||||
2: return 0.5 # Fast terrain
|
||||
_: return INF # Non-walkable
|
||||
```
|
||||
|
||||
### Custom Grid Generation
|
||||
@@ -298,14 +298,14 @@ You can implement custom grid generation by overriding the `generate_grid` metho
|
||||
extends EnhancedGridMap
|
||||
|
||||
func generate_grid():
|
||||
clear()
|
||||
for x in range(columns):
|
||||
for z in range(rows):
|
||||
var item_index = (x + z) % 2 # Checkerboard pattern
|
||||
set_cell_item(Vector3i(x, 0, z), item_index)
|
||||
update_grid_data()
|
||||
initialize_astar()
|
||||
update_astar_costs()
|
||||
clear()
|
||||
for x in range(columns):
|
||||
for z in range(rows):
|
||||
var item_index = (x + z) % 2 # Checkerboard pattern
|
||||
set_cell_item(Vector3i(x, 0, z), item_index)
|
||||
update_grid_data()
|
||||
initialize_astar()
|
||||
update_astar_costs()
|
||||
```
|
||||
|
||||
## Extending the Player Movement
|
||||
@@ -318,9 +318,9 @@ You can extend the player movement functionality by overriding or adding methods
|
||||
extends "res://addons/enhanced_gridmap/examples/player.gd"
|
||||
|
||||
func is_valid_move(from: Vector2i, to: Vector2i) -> bool:
|
||||
# Add custom logic for valid moves
|
||||
var distance = from.distance_to(to)
|
||||
return distance <= 1 and super.is_valid_move(from, to)
|
||||
# Add custom logic for valid moves
|
||||
var distance = from.distance_to(to)
|
||||
return distance <= 1 and super.is_valid_move(from, to)
|
||||
```
|
||||
|
||||
### Additional Interactions
|
||||
@@ -329,14 +329,14 @@ func is_valid_move(from: Vector2i, to: Vector2i) -> bool:
|
||||
extends "res://addons/enhanced_gridmap/examples/player.gd"
|
||||
|
||||
func _unhandled_input(event):
|
||||
super._unhandled_input(event)
|
||||
super._unhandled_input(event)
|
||||
|
||||
if event.is_action_pressed("interact"):
|
||||
interact_with_current_cell()
|
||||
if event.is_action_pressed("interact"):
|
||||
interact_with_current_cell()
|
||||
|
||||
func interact_with_current_cell():
|
||||
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(current_position.x, 0, current_position.y))
|
||||
# Add custom interaction logic based on cell_item
|
||||
var cell_item = enhanced_gridmap.get_cell_item(Vector3i(current_position.x, 0, current_position.y))
|
||||
# Add custom interaction logic based on cell_item
|
||||
```
|
||||
|
||||
These examples demonstrate how you can build upon the provided player movement script to create more complex game mechanics that integrate seamlessly with the EnhancedGridMap plugin.
|
||||
|
||||
@@ -18,4 +18,3 @@ The generated code is designed to be supported Godot Engine `3.1+`.
|
||||
### Limitations
|
||||
|
||||
The code generator has __only__ been checked against the Swagger specification generated for Nakama server. YMMV.
|
||||
|
||||
|
||||
@@ -21,13 +21,19 @@ var is_guest: bool = false
|
||||
var auth_mode: AuthMode = AuthMode.GUEST
|
||||
|
||||
# Session persistence
|
||||
const SESSION_FILE := "user://auth_session.dat"
|
||||
const CREDENTIALS_FILE := "user://auth_credentials.dat"
|
||||
var SESSION_FILE := "user://auth_session.dat"
|
||||
var CREDENTIALS_FILE := "user://auth_credentials.dat"
|
||||
|
||||
# Encryption key for session storage (device-specific)
|
||||
var ENCRYPTION_KEY: String = OS.get_unique_id().sha256_text()
|
||||
|
||||
func _ready() -> void:
|
||||
# In debug mode, suffix session files with the process ID to allow multiple instances
|
||||
if OS.is_debug_build():
|
||||
var suffix = "_" + str(OS.get_process_id())
|
||||
SESSION_FILE = "user://auth_session%s.dat" % suffix
|
||||
CREDENTIALS_FILE = "user://auth_credentials%s.dat" % suffix
|
||||
|
||||
# Try to restore session on startup
|
||||
call_deferred("_try_restore_session")
|
||||
|
||||
@@ -155,6 +161,9 @@ func login_as_guest() -> bool:
|
||||
func _get_device_id() -> String:
|
||||
# Try to load saved device ID for consistent guest identity
|
||||
var id_file := "user://device_id.txt"
|
||||
if OS.is_debug_build():
|
||||
id_file = "user://device_id_%s.txt" % str(OS.get_process_id())
|
||||
|
||||
if FileAccess.file_exists(id_file):
|
||||
var file_read := FileAccess.open(id_file, FileAccess.READ)
|
||||
if file_read:
|
||||
|
||||
Reference in New Issue
Block a user