namespace Fusion.Addons.KCC
{
using System.Collections.ObjectModel;
using UnityEngine;
#pragma warning disable 0109
// This file contains public properties.
public partial class KCC
{
// PUBLIC MEMBERS
///
/// True if the KCC is already initialized - Spawned() has been called.
///
public bool IsSpawned => _isSpawned;
///
/// Controls execution of the KCC.
///
public bool IsActive => Data.IsActive;
///
/// Returns FixedData if in fixed update, otherwise RenderData.
///
public new KCCData Data => IsInFixedUpdate == true ? _fixedData : _renderData;
///
/// Returns KCCData instance used for calculations in fixed update.
///
public KCCData FixedData => _fixedData;
///
/// Returns KCCData instance used for calculations in render update.
///
public KCCData RenderData => _renderData;
///
/// Basic KCC settings. These settings are reset to default when Initialize() or Deinitialize() is called.
///
public KCCSettings Settings => _settings;
///
/// Used for debugging - logs, drawings, statistics.
///
public KCCDebug Debug => _debug;
///
/// Reference to cached Transform component.
///
public Transform Transform => _transform;
///
/// Reference to KCC collider. Can be null if Settings.Shape is set to EKCCShape.None.
///
public CapsuleCollider Collider => _collider.Collider;
///
/// Reference to attached Rigidbody component.
///
public Rigidbody Rigidbody => _rigidbody;
///
/// Features the KCC is executing during update.
///
public EKCCFeatures ActiveFeatures => _activeFeatures;
///
/// Controls whether update methods are driven by default Unity/Fusion methods or called manually using ManualFixedUpdate() and ManualRenderUpdate().
///
public bool HasManualUpdate => _hasManualUpdate;
///
/// True if the KCC is in fixed update. This can be used to skip logic in render.
///
public bool IsInFixedUpdate => _isInFixedUpdate == true || (_isSpawned == true && Runner.Stage != default);
///
/// True if the current fixed update is forward.
///
public bool IsInForwardUpdate => _isSpawned == true && Runner.Stage != default && Runner.IsForward == true;
///
/// True if the current fixed update is resimulation.
///
public bool IsInResimulationUpdate => _isSpawned == true && Runner.Stage != default && Runner.IsResimulation == true;
///
/// True if the movement prediction is enabled in fixed update.
///
[System.Obsolete("Use Object.IsInSimulation.")]
public bool IsPredictingInFixedUpdate => Object.IsInSimulation;
///
/// True if the movement interpolation is enabled in fixed update.
///
[System.Obsolete("Interpolation in fixed update has been removed.")]
public bool IsInterpolatingInFixedUpdate => false;
///
/// True if the movement prediction is enabled in render update.
///
public bool IsPredictingInRenderUpdate
{
get
{
if (Object.HasInputAuthority == true)
return _settings.InputAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_PredictRender;
if (Object.HasStateAuthority == true)
return _settings.StateAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_PredictRender;
return false;
}
}
///
/// True if the movement interpolation is enabled in render update.
///
public bool IsInterpolatingInRenderUpdate
{
get
{
if (Object.HasInputAuthority == true)
return _settings.InputAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_InterpolateRender;
if (Object.HasStateAuthority == true)
return _settings.StateAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_InterpolateRender;
return true;
}
}
///
/// True if the look rotation prediction is enabled in fixed/render update.
///
public bool IsPredictingLookRotation
{
get
{
if (Object.HasInputAuthority == true)
{
if (_settings.InputAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_PredictRender)
return true;
if (_settings.ForcePredictedLookRotation == true)
return true;
return IsInFixedUpdate;
}
if (Object.HasStateAuthority == true)
{
if (_settings.StateAuthorityBehavior == EKCCAuthorityBehavior.PredictFixed_PredictRender)
return true;
return IsInFixedUpdate;
}
if (Object.IsInSimulation == true)
{
if (_settings.ForcePredictedLookRotation == true)
return true;
return IsInFixedUpdate;
}
return false;
}
}
///
/// Tick number of the last fixed update in which KCC was predicted.
///
public int LastPredictedFixedTick => _lastPredictedFixedTick;
///
/// Frame number of the last render update in which KCC was predicted.
///
public float LastPredictedRenderFrame => _lastPredictedRenderFrame;
///
/// Frame number of the last render update in which KCC look rotation was predicted.
/// The look rotation can be render predicted even if the KCC is render interpolated using KCCSettings.ForcePredictedLookRotation.
///
public float LastPredictedLookRotationFrame => _lastPredictedLookRotationFrame;
///
/// Render position difference on input authority compared to state authority.
///
public Vector3 PredictionError => _predictionError;
///
/// Locally executed processors. This list is cleared in Initialize() and initialized with KCCSettings.Processors.
/// The list is read-only and can be explicitly modified by AddLocalProcessor() and RemoveLocalProcessor().
///
public ReadOnlyCollection LocalProcessors => _localROProcessors;
}
}