This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
UTY-2504: Nullable command response #1428
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
19c3ef5
Change messagespan to nullable
BryanJY-Wong 59f04e8
Added simple validation in player command system
BryanJY-Wong f2f0201
todo changelist
BryanJY-Wong acde590
Update CHANGELOG.md
BryanJY-Wong 7be4127
add preprocessor directives
BryanJY-Wong 03a6285
Merge branch 'feature/nullable-command-response' of github.com:spatia…
BryanJY-Wong b24dc0b
send command
BryanJY-Wong 6c70ca6
Merge branch 'develop' into feature/nullable-command-response
BryanJY-Wong 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 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
This file contains 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
using System; | ||
using Improbable; | ||
using Improbable.Gdk.Core; | ||
using Improbable.Gdk.Core.Commands; | ||
using Playground.Scripts.UI; | ||
using Unity.Collections; | ||
using Unity.Entities; | ||
|
@@ -26,6 +27,9 @@ private enum PlayerCommand | |
private CommandSystem commandSystem; | ||
private EntityQuery launchGroup; | ||
|
||
#if UNITY_EDITOR | ||
private CommandRequestId? lastId; | ||
#endif | ||
protected override void OnCreate() | ||
{ | ||
base.OnCreate(); | ||
|
@@ -39,6 +43,22 @@ protected override void OnCreate() | |
|
||
protected override void OnUpdate() | ||
{ | ||
#if UNITY_EDITOR | ||
if (lastId.HasValue) | ||
{ | ||
var response = commandSystem.GetResponse<Launcher.LaunchEntity.ReceivedResponse>(lastId.Value); | ||
if (response.HasValue) | ||
{ | ||
Debug.Log($"Launch {response.Value.RequestId.Raw} successful, with response {response.Value}"); | ||
lastId = null; | ||
} | ||
else | ||
{ | ||
Debug.Log($"Could not find response for Launch {lastId.Value.Raw}"); | ||
} | ||
} | ||
#endif | ||
|
||
using (var entities = launchGroup.ToEntityArray(Allocator.TempJob)) | ||
using (var spatialIdData = launchGroup.ToComponentDataArray<SpatialEntityId>(Allocator.TempJob)) | ||
{ | ||
|
@@ -86,8 +106,12 @@ protected override void OnUpdate() | |
command == PlayerCommand.LaunchLarge ? LargeEnergy : SmallEnergy, | ||
playerId | ||
)); | ||
|
||
#if UNITY_EDITOR | ||
lastId = commandSystem.SendCommand(request, entities[0]); | ||
BryanJY-Wong marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Debug.Log($"Launching {lastId.Value.Raw}"); | ||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checking if you tested this works? I think this now means that it won't send commands in the editor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😕 if editor send command, store id and log else just send command, and yes I did test it |
||
commandSystem.SendCommand(request, entities[0]); | ||
#endif | ||
} | ||
} | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add this to playground?
This might be rather spammy in a cloud build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only logs when you left/right-click, but if its still too spammy I can remove it. @jamiebrynes7 @paulbalaji what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful locally, but don't think it's worth keeping for cloud builds