Skip to content
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

Upgrade Invaders to use Netcode For Gameobject 1.8.1 [MTT-8503] #172

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

bastienunity
Copy link

Description

  • Upgraded NGO to 1.8.1
  • Changed usage of ClientRPC and ServerRPC to the unified RPCAttribute.
  • Changed OnClientConnectedCallback registration to use the new OnConnectionEvent.
  • Changing spawn methods to use InstantiateAndSpawn.

Issue Number(s)

MTT-8503 Upgrade Invaders to use Netcode For Gameobject 1.8.1 and changed code to new recommended API.

Contribution checklist

  • Tests have been added for the project and/or any internal package
  • Release notes have been added to the project changelog file
  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • JIRA ticket ID is in the PR title or at least one commit message
  • Include the ticket ID number within the body message of the PR to create a hyperlink

@bastienunity bastienunity marked this pull request as ready for review May 6, 2024 18:28
@bastienunity bastienunity requested a review from a team as a code owner May 6, 2024 18:28
Copy link
Collaborator

@fernando-cortez fernando-cortez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nitpicks on Rpc names!

Basic/Invaders/Assets/Scripts/PlayerControl.cs Outdated Show resolved Hide resolved
[ClientRpc]
void SpawnExplosionVFXClientRpc(Vector3 spawnPosition, Quaternion spawnRotation)
[Rpc(SendTo.ClientsAndHost)]
void ClientSpawnExplosionVFXRpc(Vector3 spawnPosition, Quaternion spawnRotation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to maintain consistency with NGO's naming (and with the gaming industry's best practice), methods in NetworkBehaviours that are executed on Client or Server should start with "OnClient" or "OnServer" for clarity.

@bastienunity Since you're going through renaming RPCs, could you rename according to that logic?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Paolo. This suggestion seems to contradict the alignment we had with Noel in this discussion, at least for Rpcs.

As for the other methods, if it's not listed on our coding standard reference doc, we don't necessarily need to follow any naming convention. If we want to introduce that as a convention for our samples moving forward, we should establish that convention first, since that's not present in any sample so far.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alignment we had with Noel in that discussion was about keeping a prefix, which is maintained in both cases. How does my previous comment contradict it?

The additional "On" prefix is what is present in NGO's and Small Scale template's codebases. As a user, I'd expect netcode code to stay consistent with the naming convention of the netcode framework I'm using.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alignment in that conversation was to name Rpcs invoked on clients or server as just ClientRpc, and ServerRpc. This line is a similar scenario, no?

We haven't established yet to add the prefix On on methods invoked on clients, server, or authority yet. We're starting those conversations offline, so let's align there!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RikuTheFuffs Let's proceed with the current Rpc naming and come back to refactors, to try and get this PR through.

}

base.OnNetworkSpawn();
}

private void OnClientConnected(ulong clientId)
private void ServerOnConnectionEvent(NetworkManager networkManager, ConnectionEventData connectionEventData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

[ClientRpc]
public void BroadcastGameOverClientRpc(GameOverReason reason)
[Rpc(SendTo.ClientsAndHost)]
public void ClientBroadcastGameOverRpc(GameOverReason reason)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

private void OnClientConnectedCallback(ulong clientId)
/// <param name="networkManager"></param>
/// <param name="connectionEventData">Connection event to check for which player id is connecting.</param>
private void ServerOnConnectionEvent(NetworkManager networkManager, ConnectionEventData connectionEventData)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

[ClientRpc]
private void SendClientReadyStatusUpdatesClientRpc(ulong clientId, bool isReady)
[Rpc(SendTo.ClientsAndHost)]
private void ClientSendReadyStatusUpdatesRpc(ulong clientId, bool isReady)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

}

/// <summary>
/// SendClientReadyStatusUpdatesClientRpc
/// ClientSendReadyStatusUpdatesRpc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What value does this line in this comment provide?

[ServerRpc(RequireOwnership = false)]
private void OnClientIsReadyServerRpc(ulong clientid)
[Rpc(SendTo.Server)]
private void ServerOnClientIsReadyRpc(ulong clientid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

[ClientRpc]
void SpawnExplosionVFXClientRPC(Vector3 spawnPosition, Quaternion spawnRotation)
[Rpc(SendTo.ClientsAndHost)]
void ClientSpawnExplosionVFXRpc(Vector3 spawnPosition, Quaternion spawnRotation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

[ServerRpc]
private void ShootServerRPC()
[Rpc(SendTo.Server)]
private void ServerShootRpc()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

[ClientRpc]
private void NotifyGameOverClientRpc(GameOverReason reason, ClientRpcParams clientParams)
[Rpc(SendTo.Owner)]
private void ClientNotifyGameOverRpc(GameOverReason reason)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants