-
-
Notifications
You must be signed in to change notification settings - Fork 6
Broke Fog of war manager to vision manager and fog of war node #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e2651d5
Broke Fog of war manager to vision manager and fog of war node
amitnos123 9b74bf7
removed add addons/rts_framework/features/vision/unit_vision_data_wea…
amitnos123 5eeb5eb
I worte await vision_manager and forgot .ready
amitnos123 4435b90
Enchanced how null treated in UnitVisionData class
amitnos123 532b524
Enchanced how UnitVisionData class position sync func chekck if emit …
amitnos123 3ea9fde
Changed according to coderabbitai PR
amitnos123 5160968
fixed typo
amitnos123 2d96fc4
Changed according to coderabbitai PR
amitnos123 57f70bd
Changed according to coderabbitai PR
amitnos123 0398535
Added guard material_override in getters
amitnos123 0f55b31
Updated comments in code
amitnos123 7a74ac1
demo/game.tscn
amitnos123 30565c8
Merge branch 'rluders:main' into enhancement/vision
amitnos123 43f517a
Connected VisibilityField's signals to VisionManager
amitnos123 13de27f
Added draw_node_on_minimap function for other scripts to able to draw…
amitnos123 aa9f3e3
Fixed bug. Prefore this commit, the function adds as child to wrong n…
amitnos123 6b2fba1
Merge branch 'rluders:main' into enhancement/vision
amitnos123 d3a7235
Minimap now validate in ready function, if vision_data from vision ma…
amitnos123 f481f22
cleaning units which stop revealing
amitnos123 9f09b63
removed comments in code
amitnos123 2c97cf5
Changes according to Coderabbitai PR
amitnos123 24476c3
currected starting values of fog_circle_color and shroud_circle_color
amitnos123 926d363
Disable physics processing on _vision_data == null
amitnos123 aa66716
on adding new circle, sync circle's position
amitnos123 1e80d81
changed how handles vision_manager == null
amitnos123 ede0e45
when fails to draw circle on minimap delete the node
amitnos123 eb6d812
when vision_manager is null, pause both physics and normal proccessing
amitnos123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| @tool | ||
| extends MeshInstance3D | ||
| class_name FogOfWarManager | ||
|
|
||
| @export var vision_manager : VisionManager: | ||
| set(value): | ||
| _vision_manager = value | ||
| if _vision_manager: | ||
| _apply_fog_texture_from_vision_manager() | ||
| get: | ||
| return _vision_manager | ||
|
|
||
| # Private backing field | ||
| var _vision_manager : VisionManager | ||
|
|
||
| @export_category("Fog Values") | ||
|
|
||
| ## The size of a single pixel in the 3D world | ||
| var _texture_units_per_world_unit: int = 2 | ||
| @export_range(1, 10000, 1,"suffix:px/length") var texture_units_per_world_unit : int = 2 : # px/length | ||
| set(value): | ||
| if material_override: | ||
| material_override.set_shader_parameter("texture_units_per_world_unit", value) | ||
| _texture_units_per_world_unit = value | ||
| get: | ||
| return _texture_units_per_world_unit | ||
|
|
||
| ## Color of the generated fog | ||
| @export var fog_color : Color : | ||
| set(value): | ||
| if material_override: | ||
| material_override.set_shader_parameter("color", value) | ||
| get: | ||
| if material_override: | ||
| return material_override.get_shader_parameter("color") | ||
| return Color.BLACK | ||
|
|
||
| ## Controls the size of the fade-out effect at the edges of the visible area, creating a smooth transition between visible and fog areas. | ||
| @export var outer_margin_for_fade_out : float : | ||
| set(value): | ||
| if material_override: | ||
| material_override.set_shader_parameter("outer_margin_for_fade_out", value) | ||
| get: | ||
| if material_override: | ||
| return material_override.get_shader_parameter("outer_margin_for_fade_out") | ||
| return 0.0 | ||
|
|
||
| @export_category("Debug Values") | ||
| ## Shows small texture of the fog | ||
| @export var debug_texture_view : bool = false: | ||
| set(value): | ||
| if material_override: | ||
| material_override.set_shader_parameter("debug_texture_view", value) | ||
| get: | ||
| if material_override: | ||
| return material_override.get_shader_parameter("debug_texture_view") | ||
| return false | ||
|
|
||
| ## Controls the size of the debug texture view when enabled | ||
| @export_range(0, 1) var debug_texture_view_size : float = 0.2: | ||
| set(value): | ||
| if material_override: | ||
| material_override.set_shader_parameter("debug_texture_view_size", value) | ||
| get: | ||
| if material_override: | ||
| return material_override.get_shader_parameter("debug_texture_view_size") | ||
| return 0.2 | ||
|
|
||
| # Private backing field to store the texture | ||
| var _fog_texture : ViewportTexture | ||
| var fog_texture : ViewportTexture: | ||
| set(value): | ||
| _fog_texture = value # Store in backing field | ||
| if material_override: # Check if material exists | ||
| material_override.set_shader_parameter("world_visibility_texture", value) | ||
| get: | ||
| return _fog_texture # Return from backing field | ||
|
|
||
|
|
||
| func _ready() -> void: | ||
| if vision_manager: | ||
| await vision_manager.ready | ||
| var fog_texture_result = vision_manager.get_fog_texture() | ||
| if fog_texture_result: | ||
| fog_texture = fog_texture_result | ||
| else: | ||
| push_warning("FogOfWarManager: 'vision_manager' is not assigned – fog texture cannot be applied.") | ||
|
|
||
| func _apply_fog_texture_from_vision_manager() -> void: | ||
| if _vision_manager == null: | ||
| return | ||
| var fog_texture_result = _vision_manager.get_fog_texture() | ||
| if fog_texture_result: | ||
| fog_texture = fog_texture_result | ||
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [gd_scene load_steps=6 format=3 uid="uid://71g6dowvqb5i"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://de87xn1b8u07i" path="res://addons/rts_framework/features/vision/fog_of_war.gd" id="1_vrsar"] | ||
| [ext_resource type="Shader" uid="uid://cbo2vdgrqc60a" path="res://addons/rts_framework/features/vision/detailed_fog_of_war.gdshader" id="2_oehrr"] | ||
|
|
||
| [sub_resource type="ViewportTexture" id="ViewportTexture_m5cnj"] | ||
|
|
||
| [sub_resource type="ShaderMaterial" id="ShaderMaterial_imaik"] | ||
| resource_local_to_scene = true | ||
| render_priority = 2 | ||
| shader = ExtResource("2_oehrr") | ||
| shader_parameter/color = Color(0, 0, 0, 1) | ||
| shader_parameter/world_visibility_texture = SubResource("ViewportTexture_m5cnj") | ||
| shader_parameter/texture_units_per_world_unit = 2 | ||
| shader_parameter/outer_margin_for_fade_out = 0.0 | ||
| shader_parameter/debug_texture_view = false | ||
| shader_parameter/debug_texture_view_size = 0.2 | ||
|
|
||
| [sub_resource type="QuadMesh" id="QuadMesh_3f4cn"] | ||
| flip_faces = true | ||
| size = Vector2(2, 2) | ||
|
|
||
| [node name="FogOfWar" type="MeshInstance3D"] | ||
| material_override = SubResource("ShaderMaterial_imaik") | ||
| cast_shadow = 0 | ||
| extra_cull_margin = 16384.0 | ||
| mesh = SubResource("QuadMesh_3f4cn") | ||
| script = ExtResource("1_vrsar") |
28 changes: 0 additions & 28 deletions
28
addons/rts_framework/features/vision/fog_of_war_manager.gdshader
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
addons/rts_framework/features/vision/fog_of_war_manager.gdshader.uid
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.