using System; using System.Collections.Generic; using Robust.Shared; using Robust.Shared.GameObjects; using Robust.Shared.GameStates; using Robust.Shared.Input; using Robust.Shared.Network.Messages; using Robust.Shared.Timing; namespace Robust.Client.GameStates { /// /// Engine service that provides processing and management of game states. /// public interface IClientGameStateManager { /// /// Minimum number of states needed in the buffer for everything to work. /// /// /// With interpolation enabled the minimum is 2 states (current & next tick). Without interpolation the /// minimum is just 1. /// int MinBufferSize { get; } /// /// The number of states the system is trying to keep in the buffer. This will always /// be greater or equal to . /// int TargetBufferSize { get; } /// /// Number of applicable game states currently in the state buffer. /// int CurrentBufferSize { get; } /// /// If the buffer size is this many states larger than the target buffer size, /// apply the overflow of states in a single tick. /// int StateBufferMergeThreshold { get; } /// /// Whether prediction is currently enabled on the client entirely. /// This is NOT equal to or . /// /// This is effectively an alias of . bool IsPredictionEnabled { get; } /// /// This is called after the game state has been applied for the current tick. /// event Action GameStateApplied; /// /// This is invoked whenever a pvs-leave message is received. /// event Action? PvsLeave; /// /// One time initialization of the service. /// void Initialize(); /// /// Resets the service back to its initial state. /// void Reset(); /// /// Applies the game state for this tick. /// void ApplyGameState(); /// /// Applies a given set of game states. /// IEnumerable ApplyGameState(GameState curState, GameState? nextState); /// /// Resets any entities that have changed while predicting future ticks. /// void ResetPredictedEntities(); /// /// An input command has been dispatched. /// /// Message being dispatched. void InputCommandDispatched(ClientFullInputCmdMessage clientMsg, FullInputCmdMessage message); /// /// Requests a full state from the server. This should override even implicit entity data. /// void RequestFullState(NetEntity? missingEntity = null); uint SystemMessageDispatched(T message) where T : EntityEventArgs; /// /// Updates the cached game sates that are used to reset predicted entities. /// /// If true, this will clone old states while applying delta states, rather than /// modifying them directly. Useful if they are still cached elsewhere (e.g., replays). void UpdateFullRep(GameState state, bool cloneDelta = false); /// /// Returns the full collection of cached game states that are used to reset predicted entities. /// Dictionary> GetFullRep(); /// /// This will perform some setup in order to reset the game to an earlier state. To fully reset the state /// still needs to be called separately. /// /// /// This function will delete any networked entities that are not present in the given game state. Any child /// entities that are in the state will simply be sent to null-space. This will also reset /// to zero, so that will /// actually apply the state. /// /// /// The state to reset to. /// /// /// Whether or not to reset for all entities, or only those /// that have been modified some after the states . This effectively /// determines whether we should do a full-state reset, or only reset recently modified entities. /// /// /// Whether to delete all client-side entities (which are never part of the networked game state). /// /// /// Whether to delete client-side entities that are parented to networked that are about to be deleted during /// the partial reset. E.g., if this is true, then a client-side muzzle flash effect entity that is parented to /// a networked gun entity will get deleted if that gun is about to be deleted. If false, the entity will /// simply be detached to nullspace. This option has no effect if is true. /// void PartialStateReset( GameState state, bool resetAllEntities, bool deleteClientEntities = false, bool deleteClientChildren = true); /// /// Queue a collection of entities that are to be detached to null-space & marked as PVS-detached. /// This store and modify the list given to it. /// void QueuePvsDetach(List entities, GameTick tick); /// /// Immediately detach several entities. /// void DetachImmediate(List entities); /// /// Clears the PVS detach queue. /// void ClearDetachQueue(); } }