Move speed settings to Player and make it work with players

Probably
This commit is contained in:
Norbi Peti 2021-05-28 02:52:42 +02:00
parent 5bfd0b7f10
commit b8fd14d934
2 changed files with 54 additions and 52 deletions

View file

@ -1,51 +0,0 @@
using RobocraftX.Physics;
using Svelto.ECS;
using Svelto.ECS.EntityStructs;
using Techblox.FlyCam;
using TechbloxModdingAPI.Blocks;
using TechbloxModdingAPI.Players;
using TechbloxModdingAPI.Utility;
using Unity.Mathematics;
using UnityEngine;
namespace TechbloxModdingAPI
{
public partial class Player
{
/// <summary>
/// Whether the camera (player) is sprinting.
/// </summary>
public bool Sprinting
{
get => playerEngine.GetCharacterStruct<FlyCamMovementComponent>(Id).Get().sprinting;
set => playerEngine.GetCharacterStruct<FlyCamMovementComponent>(Id).Get().sprinting = value;
}
/// <summary>
/// The speed setting of the camera.
/// </summary>
public float Speed
{
get => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speed;
set => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speed = value;
}
/// <summary>
/// The multiplier setting to use when sprinting.
/// </summary>
public float SpeedSprintMultiplier
{
get => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speedSprintMultiplier;
set => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speedSprintMultiplier = value;
}
/// <summary>
/// The acceleration setting of the camera.
/// </summary>
public float Acceleration
{
get => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().acceleration;
set => playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().acceleration = value;
}
}
}

View file

@ -1,5 +1,6 @@
using System; using System;
using RobocraftX.Character; using RobocraftX.Character;
using RobocraftX.Character.Movement;
using Unity.Mathematics; using Unity.Mathematics;
using RobocraftX.Common; using RobocraftX.Common;
using RobocraftX.Common.Players; using RobocraftX.Common.Players;
@ -17,7 +18,7 @@ namespace TechbloxModdingAPI
/// <summary> /// <summary>
/// An in-game player character. Any Leo you see is a player. /// An in-game player character. Any Leo you see is a player.
/// </summary> /// </summary>
public partial class Player : IEquatable<Player>, IEquatable<EGID> public class Player : IEquatable<Player>, IEquatable<EGID>
{ {
// static functionality // static functionality
private static PlayerEngine playerEngine = new PlayerEngine(); private static PlayerEngine playerEngine = new PlayerEngine();
@ -350,6 +351,58 @@ namespace TechbloxModdingAPI
public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine
.GetCharacterStruct<PlayerInputTimeStoppedContextStruct>(Id).Get().timeStoppedContext; .GetCharacterStruct<PlayerInputTimeStoppedContextStruct>(Id).Get().timeStoppedContext;
/// <summary>
/// Whether the player is sprinting.
/// </summary>
public bool Sprinting
{
get => GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementComponent>(Id).Get().sprinting
: playerEngine.GetCharacterStruct<CharacterMovementEntityStruct>(Id).Get().isSprinting;
set => _ = GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementComponent>(Id).Get().sprinting = value
: playerEngine.GetCharacterStruct<CharacterMovementEntityStruct>(Id).Get().isSprinting = value;
}
/// <summary>
/// Movement speed setting. Build mode (camera) and simulation mode settings are separate.
/// </summary>
public float SpeedSetting
{
get => GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speed
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().moveSpeed;
set => _ = GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speed = value
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().moveSpeed = value;
}
/// <summary>
/// The multiplier setting to use when sprinting. Build mode (camera) and simulation mode settings are separate.
/// </summary>
public float SpeedSprintMultiplierSetting
{
get => GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speedSprintMultiplier
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().sprintSpeedMultiplier;
set => _ = GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().speedSprintMultiplier = value
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().sprintSpeedMultiplier = value;
}
/// <summary>
/// The acceleration setting of the player. Build mode (camera) and simulation mode settings are separate.
/// </summary>
public float AccelerationSetting
{
get => GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().acceleration
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().acceleration;
set => _ = GameState.IsBuildMode()
? playerEngine.GetCharacterStruct<FlyCamMovementSettingsComponent>(Id).Get().acceleration = value
: playerEngine.GetCharacterStruct<CharacterMovementSettingsEntityStruct>(Id).Get().acceleration = value;
}
// object methods // object methods
/// <summary> /// <summary>