Nuclide
Software Development Kit for id Technology (BETA)
Loading...
Searching...
No Matches
Spectator.h
1/*
2 * Copyright (c) 2016-2022 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
17typedef enumflags
18{
19 SPECFL_ORIGIN,
20 SPECFL_VELOCITY,
21 SPECFL_TARGET,
22 SPECFL_MODE,
23 SPECFL_FLAGS,
24 SPECFL_TYPE,
25} ncSpectatorFlags_t;
26
27
28
29#ifdef CLIENT
30string g_specmodes[] = {
31 "Death Cam",
32 "Locked Chase Cam",
33 "Free Chase Cam",
34 "Free Look",
35 "First Person",
36 "Free Overview",
37 "Chase Overview"
38};
39#endif
40
41enumflags
42{
43 SPECFLAG_BUTTON_RELEASED,
44};
45
58class
60{
61public:
62 void ncSpectator(void);
63
64 /* overrides */
65 virtual void ProcessInput(void);
66 virtual void PreFrame(void);
67 virtual void PostFrame(void);
68 virtual bool IsFakeSpectator(void);
69 virtual bool IsRealSpectator(void);
70 virtual bool IsDead(void);
71 virtual bool IsPlayer(void);
72 virtual void SharedInputFrame(void);
73
75 virtual void InputNext(void);
77 virtual void InputPrevious(void);
79 virtual void InputMode(void);
81 nonvirtual void Unspectate(void);
82 virtual void OnRemoveEntity(void);
83 virtual void Respawn(void);
84
87 virtual void WarpToTarget(void);
88
90 virtual void SpectatorTrackPlayer(void);
91
92#ifdef CLIENT
93 virtual void ClientInputFrame(void);
94 virtual void ReceiveEntity(float,float);
95 virtual float predraw(void);
96#endif
97
98#ifdef SERVER
99 virtual void Save(float);
100 virtual void Restore(string,string);
101 virtual void EvaluateEntity(void);
102 virtual float SendEntity(entity,float);
103 virtual void ServerInputFrame(void);
104
105 nonvirtual void SpectatorDeathcam(ncRenderableEntity, ncEntity, float);
106#endif
107
108private:
109 NETWORKED_FLOAT(m_spectatingEntity)
110 NETWORKED_FLOAT(m_spectatingFlags)
111 ncSpectatorMode_t m_spectatingMode; ncSpectatorMode_t m_spectatingMode_net;
112 float m_flDeathCam;
113 float m_flLastSpecTargetChange;
114 vector spec_org;
115 int sequence;
116};
117
118#ifdef CLIENT
119void Spectator_ReadEntity(float new);
120#endif
void ncClient(void)
Definition Client.qc:18
ncEntity is the lowest of the user-accessible entity class.
Definition Entity.h:75
This entity represents any ncEntity with advanced rendering properties.
Definition RenderableEntity.h:94
nonvirtual void Unspectate(void)
Call to forcefully un-spectate a thing.
Definition Spectator.qc:39
virtual void InputPrevious(void)
Call to spectate the previous player target.
Definition Spectator.qc:347
virtual bool IsDead(void)
Returns if we're considered 'dead'.
Definition Spectator.qc:70
virtual bool IsFakeSpectator(void)
Returns if we're a 'fake' spectator.
Definition Spectator.qc:82
virtual void ServerInputFrame(void)
Server: This is where the input* variables arrive after sending them out from the client (see ClientI...
Definition Spectator.qc:161
virtual void InputNext(void)
Call to spectate the next spectating target.
Definition Spectator.qc:265
virtual void PreFrame(void)
Run once, every frame, before physics are run on the player.
Definition Spectator.qc:462
virtual void WarpToTarget(void)
Re-teleport to the target we're spectating.
Definition Spectator.qc:104
virtual void SpectatorTrackPlayer(void)
Called every frame to track with our target player.
Definition Spectator.qc:502
virtual void PostFrame(void)
Run once, every frame, after physics are run on the player.
Definition Spectator.qc:560
virtual void Restore(string, string)
Similar to ncIO::SpawnKey() but for save-game fields.
Definition Spectator.qc:54
virtual bool IsRealSpectator(void)
Returns if we're a 'real' spectator.
Definition Spectator.qc:64
virtual void ProcessInput(void)
Called within the class to deal with the final input handling of the client.
Definition Spectator.qc:88
virtual void OnRemoveEntity(void)
Handles what happens before the entity gets removed from the client game.
Definition Spectator.qc:32
virtual void Save(float)
Handles saving a copy of this entity to a given filehandle.
Definition Spectator.qc:48
virtual void ClientInputFrame(void)
Client: Called on the client to give a chance to override input_* variables before networking them ta...
virtual bool IsPlayer(void)
Returns if we're a player.
Definition Spectator.qc:76
nonvirtual void SpectatorDeathcam(ncRenderableEntity, ncEntity, float)
Definition Spectator.qc:551
virtual float predraw(void)
virtual float SendEntity(entity, float)
Called by the engine whenever we need to send a client an update about this entity.
Definition Spectator.qc:130
virtual void EvaluateEntity(void)
Run each tic after physics are run to determine if we need to send updates over the network.
Definition Spectator.qc:537
virtual void ReceiveEntity(float, float)
Client: Handles network updates from the server for the associated entity.
virtual void Respawn(void)
Server: Called when the entity first spawns or when game-logic requests the entity to return to its o...
Definition Spectator.qc:25
void ncSpectator(void)
Definition Spectator.qc:18
virtual void InputMode(void)
Call to change the spectating mode.
Definition Spectator.qc:427
virtual void SharedInputFrame(void)
Like ClientInputFrame and ServerInputFrame, but run on both client and server at the same time.
Definition Spectator.qc:111