2021-12-05 17:54:36 +00:00
|
|
|
/*
|
|
|
|
* Darkflame Universe
|
|
|
|
* Copyright 2018
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "NiPoint3.h"
|
|
|
|
#include "NiQuaternion.h"
|
|
|
|
#include "BitStream.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "CppScripts.h"
|
|
|
|
#include "InvalidScript.h"
|
2023-03-04 07:16:37 +00:00
|
|
|
#include "eReplicaComponentType.h"
|
2023-10-09 20:19:38 +00:00
|
|
|
#include "PhysicsComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
class LDFBaseData;
|
|
|
|
class Entity;
|
|
|
|
class dpEntity;
|
2023-03-25 10:26:39 +00:00
|
|
|
enum class ePhysicsEffectType : uint32_t ;
|
2024-05-10 14:22:26 +00:00
|
|
|
enum class eReplicaComponentType : uint32_t;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows the creation of phantom physics for an entity: a physics object that is generally invisible but can be
|
|
|
|
* collided with using various shapes to detect collision on certain points in the map. Generally these are used to
|
|
|
|
* trigger gameplay events, for example the bus in Avant Gardens that moves around when the player touches its physics
|
|
|
|
* body. Optionally this object can also have effects, like the fans in AG.
|
|
|
|
*/
|
2024-01-24 05:13:23 +00:00
|
|
|
class PhantomPhysicsComponent final : public PhysicsComponent {
|
2021-12-05 17:54:36 +00:00
|
|
|
public:
|
2024-01-24 05:13:23 +00:00
|
|
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::PHANTOM_PHYSICS;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2024-12-16 05:44:57 +00:00
|
|
|
PhantomPhysicsComponent(Entity* parent, int32_t componentId);
|
2022-07-28 13:39:57 +00:00
|
|
|
~PhantomPhysicsComponent() override;
|
2021-12-05 17:54:36 +00:00
|
|
|
void Update(float deltaTime) override;
|
2024-02-27 07:25:44 +00:00
|
|
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Sets the direction this physics object is pointed at
|
|
|
|
* @param pos the direction to set
|
|
|
|
*/
|
|
|
|
void SetDirection(const NiPoint3& pos);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the direction this physics object is pointed at
|
|
|
|
* @return the direction this physics object is pointed at
|
|
|
|
*/
|
|
|
|
const NiPoint3& GetDirection() const { return m_Direction; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the multiplier by which the direction coordinates are multiplied
|
|
|
|
* @return the multiplier by which the direction coordinates are multiplied
|
|
|
|
*/
|
|
|
|
float GetDirectionalMultiplier() const { return m_DirectionalMultiplier; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the multiplier by which direction coordinates are multiplied
|
|
|
|
* @param mul the multiplier to set
|
|
|
|
*/
|
|
|
|
void SetDirectionalMultiplier(float mul);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not there's currently an effect active
|
|
|
|
* @return true if there's an effect active, false otherwise
|
|
|
|
*/
|
|
|
|
bool GetPhysicsEffectActive() const { return m_IsPhysicsEffectActive; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets whether or not there's a physics effect active
|
|
|
|
* @param val whether or not there's an effect active
|
|
|
|
*/
|
|
|
|
void SetPhysicsEffectActive(bool val) { m_IsPhysicsEffectActive = val; m_EffectInfoDirty = true; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the position of this physics object
|
|
|
|
* @param pos the position to set
|
|
|
|
*/
|
2023-10-09 20:19:38 +00:00
|
|
|
void SetPosition(const NiPoint3& pos) override;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the rotation of this physics object
|
|
|
|
* @param rot the rotation to set
|
|
|
|
*/
|
2023-10-09 20:19:38 +00:00
|
|
|
void SetRotation(const NiQuaternion& rot) override;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the effect that's currently active, defaults to 0
|
|
|
|
* @return the effect that's currently active
|
|
|
|
*/
|
2023-03-25 10:26:39 +00:00
|
|
|
ePhysicsEffectType GetEffectType() const { return m_EffectType; }
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the effect that's currently active
|
|
|
|
* @param type the effect to set
|
|
|
|
*/
|
2023-03-25 10:26:39 +00:00
|
|
|
void SetEffectType(ePhysicsEffectType type);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Physics entity for the component
|
|
|
|
* @return Physics entity for the component
|
|
|
|
*/
|
|
|
|
|
|
|
|
dpEntity* GetdpEntity() const { return m_dpEntity; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Spawns an object at each of the vertices for debugging purposes
|
|
|
|
*/
|
2024-05-10 14:22:26 +00:00
|
|
|
void SpawnVertices() const;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Legacy stuff no clue what this does
|
|
|
|
*/
|
|
|
|
void SetMin(uint32_t min);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Legacy stuff no clue what this does
|
|
|
|
*/
|
|
|
|
void SetMax(uint32_t max);
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
private:
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* A scale to apply to the size of the physics object
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
float m_Scale;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the effect has changed and needs to be serialized
|
|
|
|
*/
|
|
|
|
bool m_EffectInfoDirty;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not there's currently a physics effect active
|
|
|
|
*/
|
|
|
|
bool m_IsPhysicsEffectActive;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The physics effect that's currently active, defaults to 0
|
|
|
|
*/
|
2023-03-25 10:26:39 +00:00
|
|
|
ePhysicsEffectType m_EffectType;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A scaling multiplier to add to the directional vector
|
|
|
|
*/
|
|
|
|
float m_DirectionalMultiplier;
|
|
|
|
|
|
|
|
bool m_MinMax;
|
|
|
|
uint32_t m_Min;
|
|
|
|
uint32_t m_Max;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not this physics object is pointed in some direction
|
|
|
|
*/
|
|
|
|
bool m_IsDirectional;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The direction this physics object is pointed in, if any
|
|
|
|
*/
|
|
|
|
NiPoint3 m_Direction;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The parent entity of this component
|
|
|
|
*/
|
|
|
|
dpEntity* m_dpEntity;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not this physics object represents an object that updates the respawn pos of an entity that crosses it
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
bool m_IsRespawnVolume = false;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* If this is a respawn volume, the exact position an entity will respawn
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
NiPoint3 m_RespawnPos;
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
/**
|
|
|
|
* If this is a respawn volume, the exact rotation an entity will respawn
|
|
|
|
*/
|
2021-12-05 17:54:36 +00:00
|
|
|
NiQuaternion m_RespawnRot;
|
2022-07-28 13:39:57 +00:00
|
|
|
};
|