forked from OpenXRay/xray-16
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Added ZS_AMEBA and ZS_NGRAV class registrator ids
- Loading branch information
1 parent
8a423ed
commit 2748b74
Showing
5 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#include "stdafx.h" | ||
|
||
#include "AmebaZone.h" | ||
#include "ZoneVisual.h" | ||
#include "CustomZone.h" | ||
#include "xrEngine/xr_collide_form.h" | ||
#include "Include/xrRender/Kinematics.h" | ||
#include "PhysicsShellHolder.h" | ||
#include "PHMovementControl.h" | ||
#include "CharacterPhysicsSupport.h" | ||
#include "entity_alive.h" | ||
|
||
|
||
CAmebaZone::CAmebaZone() : m_fVelocityLimit(1.f) {} | ||
|
||
CAmebaZone::~CAmebaZone() {} | ||
|
||
void CAmebaZone::Load(LPCSTR section) | ||
{ | ||
inherited::Load(section); | ||
m_fVelocityLimit = pSettings->r_float(section, "max_velocity_in_zone"); | ||
} | ||
|
||
bool CAmebaZone::BlowoutState() | ||
{ | ||
bool result = inherited::BlowoutState(); | ||
if (!result) | ||
UpdateBlowout(); | ||
|
||
// XXX: use range-based for | ||
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it) | ||
Affect(&(*it)); | ||
|
||
return result; | ||
} | ||
|
||
void CAmebaZone::Affect(SZoneObjectInfo* O) | ||
{ | ||
CPhysicsShellHolder* pGameObject = smart_cast<CPhysicsShellHolder*>(O->object); | ||
if (!pGameObject) return; | ||
|
||
if (O->zone_ignore) return; | ||
|
||
Fvector hit_dir; | ||
hit_dir.set(Random.randF(-.5f, .5f), | ||
Random.randF(.0f, 1.f), | ||
Random.randF(-.5f, .5f)); | ||
hit_dir.normalize(); | ||
|
||
Fvector position_in_bone_space; | ||
|
||
float power = Power(distance_to_center(O->object), m_fEffectiveRadius); | ||
float power_critical = 0.0f; | ||
float impulse = m_fHitImpulseScale * power * pGameObject->GetMass(); | ||
|
||
if (power > 0.01f) | ||
{ | ||
//m_dwDeltaTime = 0; | ||
position_in_bone_space.set(0.f, 0.f, 0.f); | ||
|
||
CreateHit(pGameObject->ID(), ID(), hit_dir, power, 0, position_in_bone_space, impulse, m_eHitTypeBlowout); | ||
|
||
PlayHitParticles(pGameObject); | ||
} | ||
} | ||
|
||
void CAmebaZone::PhTune(float step) | ||
{ | ||
// XXX: use range-based for | ||
for (OBJECT_INFO_VEC::iterator it = m_ObjectInfoMap.begin(); m_ObjectInfoMap.end() != it; ++it) | ||
{ | ||
CEntityAlive* EA = smart_cast<CEntityAlive*>((*it).object); | ||
if (EA) | ||
{ | ||
CPHMovementControl* mc = EA->character_physics_support()->movement(); | ||
if (mc) | ||
{ | ||
if (distance_to_center(EA) < effective_radius(m_fEffectiveRadius)) | ||
mc->SetVelocityLimit(m_fVelocityLimit); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void CAmebaZone::SwitchZoneState(EZoneState new_state) | ||
{ | ||
if (new_state == eZoneStateBlowout && m_eZoneState != eZoneStateBlowout) | ||
Activate(); | ||
|
||
if (new_state != eZoneStateBlowout && m_eZoneState == eZoneStateBlowout) | ||
Deactivate(); | ||
|
||
inherited::SwitchZoneState(new_state); | ||
} | ||
|
||
float CAmebaZone::distance_to_center(CGameObject* O) | ||
{ | ||
Fvector P; | ||
XFORM().transform_tiny(P, CForm->getSphere().P); | ||
Fvector OP; | ||
OP.set(O->Position()); | ||
return _sqrt((P.x - OP.x) * (P.x - OP.x) + (P.x - OP.x) * (P.x - OP.x)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
|
||
#include "CustomZone.h" | ||
#include "Include/xrRender/KinematicsAnimated.h" | ||
#include "ZoneVisual.h" | ||
#include "xrPhysics/PHUpdateObject.h" | ||
|
||
class CAmebaZone : | ||
public CVisualZone, | ||
public CPHUpdateObject | ||
{ | ||
typedef CVisualZone inherited; | ||
float m_fVelocityLimit; | ||
|
||
public: | ||
CAmebaZone(); | ||
~CAmebaZone(); | ||
void Affect(SZoneObjectInfo* O) override; | ||
|
||
protected: | ||
void PhTune(float step) override; | ||
void PhDataUpdate(float step) override {} | ||
bool BlowoutState() override; | ||
void SwitchZoneState(EZoneState new_state) override; | ||
void Load(LPCSTR section) override; | ||
virtual float distance_to_center(CGameObject* O); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters