Files
RP411/MUNGA/AUDENT.cpp
T
CydandClaude Opus 4.8 4abbf8879f Initial import of Red Planet v4.10 Win32 source
Imports the current Win32 source for the pod-racing game 'Red Planet',
built on the MUNGA engine and its L4 (Win32/DirectX) platform layer:

- MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend
- RP / RP_L4: Red Planet game logic and Win32 application
- DivLoader, Setup1: asset loader and installer project
- lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies

Removed stale Subversion metadata and added .gitignore/.gitattributes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 07:59:51 -05:00

178 lines
4.3 KiB
C++

#include "munga.h"
#pragma hdrstop
#include "audent.h"
#include "jmover.h"
#include "app.h"
#include "hostmgr.h"
//#############################################################################
//########################### AudioEntity ###############################
//#############################################################################
//#############################################################################
// Shared Data Support
//
Derivation* AudioEntity::GetClassDerivations()
{ static Derivation classDerivations(Explosion::GetClassDerivations(), "AudioEntity");
return &classDerivations;
}
AudioEntity::SharedData
AudioEntity::DefaultData(
AudioEntity::GetClassDerivations(),
AudioEntity::GetMessageHandlers(),
AudioEntity::GetAttributeIndex(),
AudioEntity::StateCount,
(Entity::MakeHandler)AudioEntity::Make
);
//
//#############################################################################
//#############################################################################
//
AudioEntity::AudioEntity(
AudioEntity::MakeMessage *creation_message,
AudioEntity::SharedData &shared_data
):
Explosion(creation_message, shared_data),
parentEntitySocket(NULL)
{
Check_Pointer(this);
Check_Pointer(creation_message);
//
// Get the parent entity
//
Entity *parent_entity;
parent_entity =
application->GetHostManager()->GetEntityPointer(
creation_message->parentEntityID
);
if (parent_entity != NULL)
{
parentEntitySocket.Add(parent_entity);
parentEntitySegment = creation_message->parentEntitySegment;
}
else
{
parentEntitySegment = NULL;
}
//
// Set simulation
//
SetPerformance(&AudioEntity::AudioEntitySimulation);
SetValidFlag();
}
//
//#############################################################################
//#############################################################################
//
AudioEntity::~AudioEntity()
{
}
//
//#############################################################################
//#############################################################################
//
Logical
AudioEntity::TestInstance() const
{
if (!IsDerivedFrom(*GetClassDerivations()))
{
return False;
}
Check(&parentEntitySocket);
if (parentEntitySegment != NULL)
{
Check(parentEntitySegment);
}
return True;
}
//
//#############################################################################
//#############################################################################
//
AudioEntity*
AudioEntity::Make(AudioEntity::MakeMessage *creation_message)
{
return new AudioEntity(creation_message);
}
//
//#############################################################################
//#############################################################################
//
void
AudioEntity::AudioEntitySimulation(Scalar time_slice)
{
Check(this);
//
// Get the parent entity, if it does not exist, condemn to death row
//
Entity *parent_entity;
if ((parent_entity = parentEntitySocket.GetCurrent()) == NULL)
{
CondemnToDeathRow();
return;
}
//
// Get the orign of the parent entities segment
//
JointedMover *jointed_mover;
Verify(parent_entity->IsDerivedFrom(JointedMover::GetClassDerivations()));
jointed_mover = Cast_Object(JointedMover*, parent_entity);
Check(jointed_mover);
Check(parentEntitySegment);
jointed_mover->GetSegmentToWorld(
*parentEntitySegment,
&localToWorld
);
//
// Set the origin of this entity
//
localOrigin = localToWorld;
updateOrigin = localOrigin;
//
// Call inherited simulation
//
Explosion::ExplosionSimulation(time_slice);
}
//#############################################################################
//##################### AudioEntity__MakeMessage ########################
//#############################################################################
AudioEntity__MakeMessage::AudioEntity__MakeMessage(
ResourceDescription::ResourceID resource_ID,
Entity *parent_entity,
EntitySegment *parent_entity_segment
):
Explosion::MakeMessage(
AudioEntity::MakeMessageID,
sizeof(AudioEntity__MakeMessage),
RegisteredClass::AudioEntityClassID,
EntityID::Null,
resource_ID,
Entity::HermitInstance|Entity::DynamicFlag,
parent_entity->localOrigin,
parent_entity->GetEntityID(),
EntityID::Null
),
parentEntityID(parent_entity->GetEntityID()),
parentEntitySegment(parent_entity_segment)
{
}