Skip to content

Commit

Permalink
Moved classes in demos to namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-weiland committed Dec 17, 2021
1 parent 04c6825 commit 3820151
Show file tree
Hide file tree
Showing 13 changed files with 545 additions and 526 deletions.
1 change: 1 addition & 0 deletions Demos/Console/ConsoleClient/ConsoleClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestClient</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions Demos/Console/ConsoleClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using RiptideNetworking.Transports.RudpTransport;
using RiptideNetworking.Utils;
using System;
Expand All @@ -12,7 +11,7 @@
using System.Threading;
using Timer = System.Timers.Timer;

namespace ConsoleClient
namespace RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestClient
{
class Program
{
Expand Down
1 change: 1 addition & 0 deletions Demos/Console/ConsoleServer/ConsoleServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestServer</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions Demos/Console/ConsoleServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using RiptideNetworking.Transports.RudpTransport;
using RiptideNetworking.Utils;
using System;
using System.Collections.Generic;
using System.Threading;
using Timer = System.Timers.Timer;

namespace ConsoleServer
namespace RiptideNetworking.Demos.RudpTransport.ConsoleApp.TestServer
{
class Program
{
Expand Down
77 changes: 40 additions & 37 deletions Demos/Unity/Client/Assets/Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,56 @@

using UnityEngine;

public class CameraController : MonoBehaviour
namespace RiptideNetworking.Demos.RudpTransport.Unity.ExampleClient
{
[SerializeField] private Player player;
[SerializeField] private float sensitivity = 100f;
[SerializeField] private float clampAngle = 85f;
public class CameraController : MonoBehaviour
{
[SerializeField] private Player player;
[SerializeField] private float sensitivity = 100f;
[SerializeField] private float clampAngle = 85f;

private float verticalRotation;
private float horizontalRotation;
private float verticalRotation;
private float horizontalRotation;

private void Start()
{
verticalRotation = transform.localEulerAngles.x;
horizontalRotation = player.transform.eulerAngles.y;
}
private void Start()
{
verticalRotation = transform.localEulerAngles.x;
horizontalRotation = player.transform.eulerAngles.y;
}

private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
ToggleCursorMode();
private void Update()
{
if (Input.GetKeyDown(KeyCode.Escape))
ToggleCursorMode();

if (Cursor.lockState == CursorLockMode.Locked)
Look();
if (Cursor.lockState == CursorLockMode.Locked)
Look();

Debug.DrawRay(transform.position, transform.forward * 2, Color.green);
}
Debug.DrawRay(transform.position, transform.forward * 2, Color.green);
}

private void Look()
{
float mouseVertical = -Input.GetAxis("Mouse Y");
float mouseHorizontal = Input.GetAxis("Mouse X");
private void Look()
{
float mouseVertical = -Input.GetAxis("Mouse Y");
float mouseHorizontal = Input.GetAxis("Mouse X");

verticalRotation += mouseVertical * sensitivity * Time.deltaTime;
horizontalRotation += mouseHorizontal * sensitivity * Time.deltaTime;
verticalRotation += mouseVertical * sensitivity * Time.deltaTime;
horizontalRotation += mouseHorizontal * sensitivity * Time.deltaTime;

verticalRotation = Mathf.Clamp(verticalRotation, -clampAngle, clampAngle);
verticalRotation = Mathf.Clamp(verticalRotation, -clampAngle, clampAngle);

transform.localRotation = Quaternion.Euler(verticalRotation, 0f, 0f);
player.transform.rotation = Quaternion.Euler(0f, horizontalRotation, 0f);
}
transform.localRotation = Quaternion.Euler(verticalRotation, 0f, 0f);
player.transform.rotation = Quaternion.Euler(0f, horizontalRotation, 0f);
}

private void ToggleCursorMode()
{
Cursor.visible = !Cursor.visible;
private void ToggleCursorMode()
{
Cursor.visible = !Cursor.visible;

if (Cursor.lockState == CursorLockMode.None)
Cursor.lockState = CursorLockMode.Locked;
else
Cursor.lockState = CursorLockMode.None;
if (Cursor.lockState == CursorLockMode.None)
Cursor.lockState = CursorLockMode.Locked;
else
Cursor.lockState = CursorLockMode.None;
}
}
}
}
110 changes: 56 additions & 54 deletions Demos/Unity/Client/Assets/Scripts/Multiplayer/MessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,70 @@
// Copyright (c) 2021 Tom Weiland
// For additional information please see the included LICENSE.md file or view it on GitHub: https://github.com/tom-weiland/RiptideNetworking/blob/main/LICENSE.md

using RiptideNetworking;
using UnityEngine;

public static class MessageExtensions
namespace RiptideNetworking.Demos.RudpTransport.Unity.ExampleClient
{
#region Vector2
/// <summary>Adds a <see cref="Vector2"/> to the message.</summary>
/// <param name="value">The <see cref="Vector2"/> to add.</param>
/// <returns>The message that the <see cref="Vector2"/> was added to.</returns>
public static Message Add(this Message message, Vector2 value)
public static class MessageExtensions
{
message.Add(value.x);
message.Add(value.y);
return message;
}
#region Vector2
/// <summary>Adds a <see cref="Vector2"/> to the message.</summary>
/// <param name="value">The <see cref="Vector2"/> to add.</param>
/// <returns>The message that the <see cref="Vector2"/> was added to.</returns>
public static Message Add(this Message message, Vector2 value)
{
message.Add(value.x);
message.Add(value.y);
return message;
}

/// <summary>Retrieves a <see cref="Vector2"/> from the message.</summary>
/// <returns>The <see cref="Vector2"/> that was retrieved.</returns>
public static Vector2 GetVector2(this Message message)
{
return new Vector2(message.GetFloat(), message.GetFloat());
}
#endregion
/// <summary>Retrieves a <see cref="Vector2"/> from the message.</summary>
/// <returns>The <see cref="Vector2"/> that was retrieved.</returns>
public static Vector2 GetVector2(this Message message)
{
return new Vector2(message.GetFloat(), message.GetFloat());
}
#endregion

#region Vector3
/// <summary>Adds a <see cref="Vector3"/> to the message.</summary>
/// <param name="value">The <see cref="Vector3"/> to add.</param>
/// <returns>The message that the <see cref="Vector3"/> was added to.</returns>
public static Message Add(this Message message, Vector3 value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
return message;
}
#region Vector3
/// <summary>Adds a <see cref="Vector3"/> to the message.</summary>
/// <param name="value">The <see cref="Vector3"/> to add.</param>
/// <returns>The message that the <see cref="Vector3"/> was added to.</returns>
public static Message Add(this Message message, Vector3 value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
return message;
}

/// <summary>Retrieves a <see cref="Vector3"/> from the message.</summary>
/// <returns>The <see cref="Vector3"/> that was retrieved.</returns>
public static Vector3 GetVector3(this Message message)
{
return new Vector3(message.GetFloat(), message.GetFloat(), message.GetFloat());
}
#endregion
/// <summary>Retrieves a <see cref="Vector3"/> from the message.</summary>
/// <returns>The <see cref="Vector3"/> that was retrieved.</returns>
public static Vector3 GetVector3(this Message message)
{
return new Vector3(message.GetFloat(), message.GetFloat(), message.GetFloat());
}
#endregion

#region Quaternion
/// <summary>Adds a <see cref="Quaternion"/> to the message.</summary>
/// <param name="value">The <see cref="Quaternion"/> to add.</param>
/// <returns>The message that the <see cref="Quaternion"/> was added to.</returns>
public static Message Add(this Message message, Quaternion value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
message.Add(value.w);
return message;
}
#region Quaternion
/// <summary>Adds a <see cref="Quaternion"/> to the message.</summary>
/// <param name="value">The <see cref="Quaternion"/> to add.</param>
/// <returns>The message that the <see cref="Quaternion"/> was added to.</returns>
public static Message Add(this Message message, Quaternion value)
{
message.Add(value.x);
message.Add(value.y);
message.Add(value.z);
message.Add(value.w);
return message;
}

/// <summary>Retrieves a <see cref="Quaternion"/> from the message.</summary>
/// <returns>The <see cref="Quaternion"/> that was retrieved.</returns>
public static Quaternion GetQuaternion(this Message message)
{
return new Quaternion(message.GetFloat(), message.GetFloat(), message.GetFloat(), message.GetFloat());
/// <summary>Retrieves a <see cref="Quaternion"/> from the message.</summary>
/// <returns>The <see cref="Quaternion"/> that was retrieved.</returns>
public static Quaternion GetQuaternion(this Message message)
{
return new Quaternion(message.GetFloat(), message.GetFloat(), message.GetFloat(), message.GetFloat());
}
#endregion
}
#endregion
}
Loading

0 comments on commit 3820151

Please sign in to comment.