Skip to content

Commit cf1e34d

Browse files
First steps
1 parent 050fea0 commit cf1e34d

File tree

3 files changed

+251
-0
lines changed

3 files changed

+251
-0
lines changed

DOC.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
\`\`\`mermaid
2+
classDiagram
3+
class PlayerPlugin {
4+
- FpsControllerPlugin
5+
- RapierPhysicsPlugin
6+
- RapierDebugRenderPlugin
7+
- RapierConfiguration
8+
- PlayerColliderUpdateEvent
9+
- Resources
10+
- Systems
11+
}
12+
13+
%% Components
14+
class HighlightCube
15+
class Player
16+
class PlayerCamera
17+
class Raycastable
18+
19+
%% Resources
20+
class BlockSelection {
21+
+ position: Option<Vec3>
22+
+ normal: Option<Vec3>
23+
}
24+
class PlayerSpawned {
25+
+ is_spawned(): bool
26+
+ is_not_spawned(): bool
27+
}
28+
class LastPlayerPosition {
29+
+ position: Vec3
30+
}
31+
32+
%% Events
33+
class PlayerColliderUpdateEvent
34+
35+
%% Systems
36+
class SetupSystems {
37+
setup_highlight_cube_system
38+
setup_player_camera
39+
}
40+
class UpdateSystems {
41+
setup_controller_on_area_ready_system
42+
handle_controller_movement_system
43+
manage_cursor_system
44+
handle_mouse_events_system
45+
handle_keyboard_events_system
46+
raycast_system
47+
handle_block_update_events
48+
broadcast_player_attributes_system
49+
handle_player_collider_events_system
50+
}
51+
52+
PlayerPlugin --|> HighlightCube
53+
PlayerPlugin --|> Player
54+
PlayerPlugin --|> PlayerCamera
55+
PlayerPlugin --|> Raycastable
56+
PlayerPlugin --> BlockSelection
57+
PlayerPlugin --> PlayerSpawned
58+
PlayerPlugin --> LastPlayerPosition
59+
PlayerPlugin --> PlayerColliderUpdateEvent
60+
PlayerPlugin --> SetupSystems
61+
PlayerPlugin --> UpdateSystems
62+
\`\`\`
63+
64+
65+
\`\`\`mermaid
66+
sequenceDiagram
67+
participant App
68+
participant PlayerPlugin
69+
participant Resources
70+
participant Systems
71+
participant Physics
72+
participant Render
73+
74+
note over App,PlayerPlugin: Startup Phase
75+
App->>PlayerPlugin: Add FpsControllerPlugin
76+
App->>PlayerPlugin: Add RapierPhysicsPlugin
77+
App->>PlayerPlugin: Add RapierDebugRenderPlugin
78+
PlayerPlugin->>Resources: Insert RapierConfiguration
79+
PlayerPlugin->>Resources: Add BlockSelection, PlayerSpawned, LastPlayerPosition
80+
PlayerPlugin->>Systems: Add Startup Systems (setup_highlight_cube_system, setup_player_camera)
81+
82+
note over App,PlayerPlugin: Update Phase
83+
App->>Systems: Run setup_controller_on_area_ready_system
84+
Systems->>Resources: Check PlayerSpawned, SpawnAreaLoaded
85+
Systems->>Render: Setup player camera
86+
Systems->>Physics: Add Player Collider
87+
88+
App->>Systems: Run handle_controller_movement_system
89+
Systems->>Resources: Update LastPlayerPosition
90+
Systems->>Events: Trigger PlayerColliderUpdateEvent
91+
92+
App->>Systems: Run raycast_system
93+
Systems->>Resources: Update BlockSelection
94+
Systems->>Render: Update HighlightCube Position
95+
96+
App->>Systems: Run handle_mouse_events_system
97+
Systems->>Resources: Read BlockSelection
98+
Systems->>Events: Trigger BlockUpdateEvent
99+
100+
App->>Systems: Run handle_block_update_events
101+
Systems->>Resources: Update Terrain Blocks
102+
Systems->>Events: Trigger ChunkMeshUpdateEvent
103+
104+
App->>Systems: Run broadcast_player_attributes_system
105+
Systems->>Resources: Send Player State to Network
106+
107+
App->>Systems: Run handle_player_collider_events_system
108+
Systems->>Events: Process PlayerColliderUpdateEvent
109+
\`\`\`
110+
111+
```mermaid
112+
graph TD
113+
subgraph PlayerPlugin
114+
subgraph Components
115+
HighlightCube
116+
Player
117+
PlayerCamera
118+
Raycastable
119+
end
120+
121+
subgraph Resources
122+
BlockSelection
123+
PlayerSpawned
124+
LastPlayerPosition
125+
end
126+
127+
subgraph Events
128+
PlayerColliderUpdateEvent
129+
end
130+
131+
subgraph Systems
132+
setup_highlight_cube_system
133+
setup_player_camera
134+
setup_controller_on_area_ready_system
135+
handle_controller_movement_system
136+
manage_cursor_system
137+
handle_mouse_events_system
138+
handle_keyboard_events_system
139+
raycast_system
140+
broadcast_player_attributes_system
141+
handle_block_update_events
142+
handle_player_collider_events_system
143+
end
144+
145+
subgraph Dependencies
146+
FpsControllerPlugin
147+
RapierPhysicsPlugin
148+
RapierDebugRenderPlugin
149+
end
150+
151+
subgraph Conditions
152+
SpawnAreaLoaded
153+
PlayerSpawnedConditions
154+
end
155+
end
156+
157+
Dependencies --> PlayerPlugin
158+
Components --> PlayerPlugin
159+
Resources --> PlayerPlugin
160+
Events --> PlayerPlugin
161+
Systems --> PlayerPlugin
162+
Conditions --> Systems
163+
```

generate_doc.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
# Directories
4+
SRC_DIR="src"
5+
DOC_DIR="docs/plugins"
6+
PLUGIN_DIR="plugin"
7+
8+
# Files to concatenate
9+
PLUGIN_FILES=$(find $PLUGIN_DIR -type f -name '*.rs')
10+
CLIENT_PRELUDE="$SRC_DIR/client/prelude.rs"
11+
SERVER_PRELUDE="$SRC_DIR/server/prelude.rs"
12+
CLIENT_NETWORKING="$SRC_DIR/client/networking/systems.rs"
13+
SERVER_NETWORKING="$SRC_DIR/server/networking/systems.rs"
14+
15+
# Function to concatenate files
16+
concatenate_files() {
17+
local dir=$1
18+
find "$dir" -type f -name '*.rs' | while read -r file; do
19+
echo "---- File: $file ----"
20+
cat "$file"
21+
echo
22+
done
23+
}
24+
25+
# Concatenate client and server files
26+
echo "Concatenating client files..."
27+
CLIENT_FILES_CONTENT=$(concatenate_files "$SRC_DIR/client")
28+
echo "Concatenating server files..."
29+
SERVER_FILES_CONTENT=$(concatenate_files "$SRC_DIR/server")
30+
31+
# Output prompt
32+
PROMPT="# Plugin Name
33+
Short plugin description
34+
35+
## Dependencies
36+
- \`Dependency\`
37+
Necessary for ...
38+
39+
\`\`\`mermaid
40+
A mermaid diagram showcasing the various elements of the plugin.
41+
- Use subgraphs to structure Components / Systems / Resources / Events
42+
- Show relations between the components systems etc.
43+
- Show data attributes of the resources / components with the corresponding visibility
44+
\`\`\`
45+
46+
## Components
47+
- \`Component Name\`: Purpose
48+
49+
## Resources
50+
- \`Resource Name\`: Purpose
51+
52+
## Systems
53+
- **Category of System**:
54+
- \`Name of system\`: Description
55+
- **Networking** (if applicable)
56+
"
57+
58+
# Create docs directory if it doesn't exist
59+
mkdir -p "$DOC_DIR"
60+
61+
# Save the output
62+
OUTPUT_FILE="$DOC_DIR/plugin_name.md"
63+
printf "file: %s\n\n" "$OUTPUT_FILE" > "$OUTPUT_FILE"
64+
printf "$PROMPT" >> "$OUTPUT_FILE"
65+
printf "\n%s\n\n" "$CLIENT_FILES_CONTENT" >> "$OUTPUT_FILE"
66+
printf "\n%s\n\n" "$SERVER_FILES_CONTENT" >> "$OUTPUT_FILE"
67+
printf "\n%s\n\n" "$(cat "$CLIENT_PRELUDE")" >> "$OUTPUT_FILE"
68+
printf "\n%s\n\n" "$(cat "$SERVER_PRELUDE")" >> "$OUTPUT_FILE"
69+
printf "\n%s\n\n" "$(cat "$CLIENT_NETWORKING")" >> "$OUTPUT_FILE"
70+
printf "\n%s\n\n" "$(cat "$SERVER_NETWORKING")" >> "$OUTPUT_FILE"
71+
printf "\n%s\n\n" "$PLUGIN_FILES" >> "$OUTPUT_FILE"
72+
73+
echo "Documentation generated and saved to $OUTPUT_FILE"

script.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Define the base directory
4+
BASE_DIR="src"
5+
6+
# Find all mod.rs files and check if they contain "impl Plugin"
7+
find "$BASE_DIR" -type f -name "mod.rs" | while read -r mod_file; do
8+
if grep -q "impl Plugin" "$mod_file"; then
9+
# Get the directory of the mod.rs file
10+
dir_path=$(dirname "$mod_file")
11+
echo "$dir_path"
12+
13+
cat "$dir_path/mod.rs" | rg "::\w+_system"
14+
fi
15+
done

0 commit comments

Comments
 (0)