Browse Source

Move speed settings to Player and make it work with players

Probably
tags/v2.0.0
NorbiPeti 3 years ago
parent
commit
b8fd14d934
2 changed files with 54 additions and 52 deletions
  1. +0
    -51
      TechbloxModdingAPI/Player.FlyCamSettings.cs
  2. +54
    -1
      TechbloxModdingAPI/Player.cs

+ 0
- 51
TechbloxModdingAPI/Player.FlyCamSettings.cs 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;
}
}
}

+ 54
- 1
TechbloxModdingAPI/Player.cs View File

@@ -1,5 +1,6 @@
using System;
using RobocraftX.Character;
using RobocraftX.Character.Movement;
using Unity.Mathematics;
using RobocraftX.Common;
using RobocraftX.Common.Players;
@@ -17,7 +18,7 @@ namespace TechbloxModdingAPI
/// <summary>
/// An in-game player character. Any Leo you see is a player.
/// </summary>
public partial class Player : IEquatable<Player>, IEquatable<EGID>
public class Player : IEquatable<Player>, IEquatable<EGID>
{
// static functionality
private static PlayerEngine playerEngine = new PlayerEngine();
@@ -350,6 +351,58 @@ namespace TechbloxModdingAPI
public PlayerBuildingMode BuildingMode => (PlayerBuildingMode) playerEngine
.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

/// <summary>


Loading…
Cancel
Save