2013-09-21 04:17:34 +09:00
|
|
|
/*
|
|
|
|
Copyright (c) 2013 yvt
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
This file is part of OpenSpades.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
OpenSpades is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
OpenSpades is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with OpenSpades. If not, see <http://www.gnu.org/licenses/>.
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-05-05 23:32:57 +09:00
|
|
|
#include <array>
|
|
|
|
|
2016-12-03 18:23:47 +09:00
|
|
|
#include "Player.h"
|
|
|
|
#include <Core/Math.h>
|
2013-09-21 04:17:34 +09:00
|
|
|
#include <Core/RefCountedObject.h>
|
|
|
|
#include <ScriptBindings/ScriptManager.h>
|
|
|
|
|
|
|
|
namespace spades {
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-11-03 17:13:49 +01:00
|
|
|
class ScriptFunction;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
namespace client {
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
class Client;
|
2013-11-03 17:13:49 +01:00
|
|
|
class IRenderer;
|
|
|
|
class IAudioDevice;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-23 18:26:00 +09:00
|
|
|
class SandboxedRenderer;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2019-07-20 17:01:04 +09:00
|
|
|
// TODO: Use `shared_ptr` instead of `RefCountedObject`
|
2013-09-21 04:17:34 +09:00
|
|
|
/** Representation of player which is used by
|
|
|
|
* drawing/view layer of game client. */
|
2016-12-03 18:23:47 +09:00
|
|
|
class ClientPlayer : public RefCountedObject {
|
2019-07-17 00:31:00 +09:00
|
|
|
Client &client;
|
|
|
|
Player &player;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
float sprintState;
|
|
|
|
float aimDownState;
|
|
|
|
float toolRaiseState;
|
|
|
|
Player::ToolType currentTool;
|
|
|
|
float localFireVibrationTime;
|
|
|
|
float time;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2017-02-25 21:19:19 +09:00
|
|
|
/**
|
|
|
|
* Indicates whether the third-person weapon skin script has the latest
|
|
|
|
* value of `OriginMatrix`.
|
|
|
|
*/
|
|
|
|
bool hasValidOriginMatrix;
|
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
Vector3 viewWeaponOffset;
|
2016-11-22 01:16:28 +09:00
|
|
|
|
|
|
|
Vector3 lastFront;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2019-05-05 23:32:57 +09:00
|
|
|
Vector3 flashlightOrientation;
|
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
asIScriptObject *spadeSkin;
|
|
|
|
asIScriptObject *blockSkin;
|
|
|
|
asIScriptObject *weaponSkin;
|
|
|
|
asIScriptObject *grenadeSkin;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
asIScriptObject *spadeViewSkin;
|
|
|
|
asIScriptObject *blockViewSkin;
|
|
|
|
asIScriptObject *weaponViewSkin;
|
|
|
|
asIScriptObject *grenadeViewSkin;
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2015-01-23 18:26:00 +09:00
|
|
|
Handle<SandboxedRenderer> sandboxedRenderer;
|
2016-11-22 01:16:28 +09:00
|
|
|
|
2019-05-05 23:32:57 +09:00
|
|
|
std::array<Vector3, 3> GetFlashlightAxes();
|
2013-09-21 04:17:34 +09:00
|
|
|
void AddToSceneThirdPersonView();
|
|
|
|
void AddToSceneFirstPersonView();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
|
|
|
void SetSkinParameterForTool(Player::ToolType, asIScriptObject *);
|
2013-09-21 04:17:34 +09:00
|
|
|
void SetCommonSkinParameter(asIScriptObject *);
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2017-01-06 04:01:10 +09:00
|
|
|
struct AmbienceInfo;
|
|
|
|
AmbienceInfo ComputeAmbience();
|
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
float GetLocalFireVibration();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
bool ShouldRenderInThirdPersonView();
|
2013-11-03 17:13:49 +01:00
|
|
|
|
2019-07-20 15:31:36 +09:00
|
|
|
// TODO: Naming convention violation
|
|
|
|
asIScriptObject *initScriptFactory(ScriptFunction &creator, IRenderer &renderer,
|
|
|
|
IAudioDevice &audio);
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
protected:
|
2017-01-05 03:48:11 +09:00
|
|
|
~ClientPlayer();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
public:
|
2019-07-17 00:31:00 +09:00
|
|
|
ClientPlayer(Player &p, Client &);
|
|
|
|
Player &GetPlayer() const { return player; }
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
void Update(float dt);
|
|
|
|
void AddToScene();
|
2013-11-01 00:39:17 +09:00
|
|
|
void Draw2D();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
bool IsChangingTool();
|
|
|
|
void FiredWeapon();
|
|
|
|
void ReloadingWeapon();
|
|
|
|
void ReloadedWeapon();
|
2016-12-03 18:23:47 +09:00
|
|
|
|
2013-09-21 04:17:34 +09:00
|
|
|
float GetAimDownState() { return aimDownState; }
|
|
|
|
float GetSprintState() { return sprintState; }
|
2016-11-22 01:16:28 +09:00
|
|
|
|
|
|
|
Matrix4 GetEyeMatrix();
|
2013-09-21 04:17:34 +09:00
|
|
|
};
|
2019-07-17 00:31:22 +09:00
|
|
|
} // namespace client
|
|
|
|
} // namespace spades
|