Files
TeslaRel410/restoration/source410/BT/MECH.HPP
T
CydandClaude Fable 5 4d175c959a Mech phase 3: named member layout + embedded-member construction
Replaced MECH.HPP reserved[331] with the named Mech-own members: cached subsystem
pointers (sensor/gyro/sinkSource/hud) + messageManager + weaponCount, the 5
capability chains (ChainOf<Subsystem*>), and the embedded status/animation state
(4 AlarmIndicators, Reticle, 3 StateIndicators, 2 SequenceControllers, NameFilter,
telemetryFilter[5]=AverageOf<Scalar>, 3 CStrings) + a reservedState pad for the
phase-5 per-frame fields. The subsystem ROSTER (subsystemArray/subsystemCount)
lives in the base Entity (GetSubsystem/GetSubsystemCount), so the Mech only caches
back-pointers.

The Mech ctor now CONSTRUCTS all embedded members (alarms Initialize'd, reticle
armed, state indicators sized, telemetry filters sized, sequence controllers
Init'd) -- compile-verified -- then halts at the segment walk (the remaining
piece). BT: 42 ok; tree links clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 07:00:51 -05:00

323 lines
9.2 KiB
C++

//===========================================================================//
// File: mech.hpp //
// Project: BattleTech Brick: Entity Manager //
// Contents: Implementation details for the Mech entity //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(MECH_HPP)
# define MECH_HPP
# if !defined(JMOVER_HPP)
# include <jmover.hpp>
# endif
# if !defined(RETICLE_HPP)
# include <reticle.hpp>
# endif
# if !defined(ALARM_HPP)
# include <alarm.hpp>
# endif
# if !defined(STATE_HPP)
# include <state.hpp>
# endif
# if !defined(CHAIN_HPP)
# include <chain.hpp>
# endif
# if !defined(AVERAGE_HPP)
# include <average.hpp>
# endif
# if !defined(CSTR_HPP)
# include <cstr.hpp>
# endif
# if !defined(SEQCTL_HPP)
# include <seqctl.hpp>
# endif
# if !defined(NAMEFILT_HPP)
# include <namefilt.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
class Subsystem;
class SubsystemMessageManager;
class ControlsMapping;
class PlatformTool;
class MechControlsMapper;
class Mech__DamageZone;
//###########################################################################
//######################### Mech Model Resource #########################
//###########################################################################
struct Mech__ModelResource:
public JointedMover::ModelResource
{
char animationPrefix[4];
Scalar maxAcceleration;
Scalar superStopAcceleration;
Scalar throttleAdjustment;
Scalar lookLeftAngle;
Scalar lookRightAngle;
Scalar lookFrontAngle;
Scalar lookBackAngle;
Scalar walkingTurnRate;
Scalar runningTurnRate;
Scalar reticleX;
Scalar reticleY;
Scalar relativeMechValue;
int deathEffectResourceID;
Scalar deathSplashDamage;
Scalar deathSplashRadius;
Scalar maxUnstableAcceleration;
Scalar unstableAccelerationEffect;
Scalar unstableGunTheEngineEffect;
Scalar unstableSuperStopEffect;
Scalar unstableHighVelocityEffect;
Scalar unstableStopedTurnEffect;
Scalar updatePositionDiffrence;
Scalar updateTurnVelocityDiffrence;
Scalar updateTurnDegreeDiffrence;
Scalar timeDelay;
Vector3D cameraOffset;
char shadowJointName[20];
};
//###########################################################################
//########################## Mech Make Message ##########################
//###########################################################################
class Mech__MakeMessage:
public JointedMover::MakeMessage
{
public:
char resourceNameA[20];
char resourceNameB[20];
char resourceNameC[20];
Mech__MakeMessage(
Receiver::MessageID message_ID,
size_t length,
const EntityID &entity_ID,
Entity::ClassID class_ID,
const EntityID &owner_ID,
ResourceDescription::ResourceID resource_ID,
LWord instance_flags,
const Origin &origin,
const Motion &velocity,
const Motion &acceleration,
const char *badge,
const char *color,
const char *patch
):
JointedMover::MakeMessage(
message_ID, length, entity_ID, class_ID, owner_ID,
resource_ID, instance_flags, origin, velocity, acceleration
)
{
Str_Copy(resourceNameA, badge, sizeof(resourceNameA));
Str_Copy(resourceNameB, color, sizeof(resourceNameB));
Str_Copy(resourceNameC, patch, sizeof(resourceNameC));
}
};
//###########################################################################
//############################## Mech ###############################
//###########################################################################
class Mech:
public JointedMover
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static const HandlerEntry
MessageHandlerEntries[];
static MessageHandlerSet
MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Test Class Support
//
public:
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
typedef Mech__ModelResource ModelResource;
typedef Mech__MakeMessage MakeMessage;
typedef Mech__DamageZone DamageZone;
static Mech*
Make(MakeMessage *creation_message);
Mech(
MakeMessage *creation_message,
SharedData &shared_data = DefaultData
);
~Mech();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// App interface
//
public:
void
SetMappingSubsystem(Subsystem *mapper);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Resource creation
//
public:
static void
CreateMakeMessage(
MakeMessage *creation_message,
NotationFile *model_file,
const ResourceDirectories *directories
);
static ResourceDescription::ResourceID
CreateModelResource(
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories,
ModelResource *model = 0
);
static ResourceDescription::ResourceID
CreateSubsystemStream(
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories
);
static ResourceDescription::ResourceID
CreateDamageZoneStream(
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories
);
static ResourceDescription::ResourceID
CreateSkeletonStream(
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories
);
static ResourceDescription::ResourceID
CreateExplosionTableStream(
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories
);
typedef Logical (*FindNameFunction)(
const char *control_name, ControlsMapping *mapping);
static ResourceDescription::ResourceID
CreateControlMappingStream(
const char *mapping_name,
NotationFile *mapping_file,
FindNameFunction find_name,
ResourceFile *resource_file,
const char *model_name,
NotationFile *model_file,
const ResourceDirectories *directories,
PlatformTool *current_tool
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Subsystem roster accessors (the roster itself -- subsystemArray /
// subsystemCount -- lives in the base Entity)
//
public:
Subsystem*
GetGyroSubsystem() { Check(this); return gyroSubsystem; }
Subsystem*
GetTorsoSubsystem() { Check(this); return sinkSourceSubsystem; }
Subsystem*
GetHudSubsystem() { Check(this); return hudSubsystem; }
Subsystem*
GetSensorSubsystem() { Check(this); return sensorSubsystem; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data
//
protected:
//
// Cached subsystem back-pointers (also held in the base roster).
//
Subsystem *sensorSubsystem;
Subsystem *gyroSubsystem;
Subsystem *sinkSourceSubsystem; // the real Torso
Subsystem *hudSubsystem;
SubsystemMessageManager *messageManager;
int weaponCount;
//
// Capability sub-rosters (Socket views onto the subsystem roster;
// populated per-frame -- phase 5).
//
ChainOf<Subsystem*> controllableSubsystems;
ChainOf<Subsystem*> watchedSubsystems;
ChainOf<Subsystem*> heatableSubsystems;
ChainOf<Subsystem*> weaponRoster;
ChainOf<Subsystem*> damageableSubsystems;
//
// Embedded status / animation / naming state.
//
NameFilter mechNameFilter;
AlarmIndicator masterAlarm;
AlarmIndicator heatAlarm;
AlarmIndicator stabilityAlarm;
AlarmIndicator statusAlarm;
Reticle targetReticle;
StateIndicator animationState;
StateIndicator replicantAnimationState;
StateIndicator collisionState;
SequenceController legAnimation;
SequenceController bodyAnimation;
AverageOf<Scalar> telemetryFilter[5];
CString resourceNameA;
CString resourceNameB;
CString resourceNameC;
//
// Per-frame locomotion / targeting / animation state, advanced by the
// mech2/mech3/mech4 simulation. Reserved until that path (phase 5) is
// reconstructed with named fields.
//
int reservedState[220];
};
#endif