Sensor : public PoweredSubsystem -- the radar/targeting subsystem, using the SURVIVING 4.10 interface (CODE/BT/BT/SENSOR.HPP) with a reconstructed SENSOR.CPP body (from BT411 decomp). Ctor chains PoweredSubsystem, inits radarPercent/ selfTest/badVoltage, and installs the per-frame performance unless the owner is a replicant (owner->GetInstance() != ReplicantInstance -- the clean form of the binary's (flags & 0xC) != 4). Statics, dtor, TestClass/TestInstance, ResetToInitialState, TakeDamage, DeathReset real; SensorSimulation (per-frame radar) + CreateStreamedSubsystem staged. Completes the first full vertical slice of the subsystem roster, all compile-verified: MechSubsystem -> HeatableSubsystem -> HeatSink -> PoweredSubsystem -> Sensor. The hierarchy backbone is proven; remaining leaves (Generator, Gyro, Torso, HUD, Myomers, weapons) follow the same pattern. BT: 27 ok; tree links clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
164 lines
4.2 KiB
C++
164 lines
4.2 KiB
C++
//===========================================================================//
|
|
// File: sensor.cpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: Sensor -- the radar / targeting subsystem //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <bt.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(SENSOR_HPP)
|
|
# include <sensor.hpp>
|
|
#endif
|
|
|
|
#if !defined(MECH_HPP)
|
|
# include <mech.hpp>
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
// Shared data support
|
|
//#############################################################################
|
|
//
|
|
Derivation
|
|
Sensor::ClassDerivations(
|
|
PoweredSubsystem::ClassDerivations,
|
|
"Sensor"
|
|
);
|
|
|
|
Sensor::SharedData
|
|
Sensor::DefaultData(
|
|
Sensor::ClassDerivations,
|
|
Subsystem::MessageHandlers,
|
|
Subsystem::AttributeIndex,
|
|
Subsystem::StateCount
|
|
);
|
|
|
|
//
|
|
//#############################################################################
|
|
// The radar / targeting subsystem. A non-replicant (master) instance runs the
|
|
// per-frame SensorSimulation.
|
|
//#############################################################################
|
|
//
|
|
Sensor::Sensor(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource
|
|
):
|
|
PoweredSubsystem(owner, subsystem_ID, subsystem_resource, DefaultData)
|
|
{
|
|
Check(owner);
|
|
Check_Pointer(subsystem_resource);
|
|
|
|
radarPercent = 1.0f; // RadarBaseline
|
|
selfTest = False;
|
|
badVoltage = False;
|
|
|
|
//
|
|
// Install the per-frame performance unless the owner is a replicant copy
|
|
// (which is driven by console updates instead).
|
|
//
|
|
if (owner->GetInstance() != Entity::ReplicantInstance)
|
|
{
|
|
SetPerformance(&Sensor::SensorSimulation);
|
|
}
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Sensor::~Sensor()
|
|
{
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
Sensor::TestClass(Mech &)
|
|
{
|
|
return True;
|
|
}
|
|
|
|
Logical
|
|
Sensor::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::ResetToInitialState()
|
|
{
|
|
Check(this);
|
|
|
|
radarPercent = 1.0f; // RadarBaseline
|
|
selfTest = False;
|
|
badVoltage = False;
|
|
|
|
PoweredSubsystem::ResetToInitialState(True);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Per-frame radar / targeting update. Not yet reconstructed -- fires only once
|
|
// the mech is ticking.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::SensorSimulation(Scalar)
|
|
{
|
|
Fail("Sensor::SensorSimulation -- sensor.cpp not yet reconstructed");
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Damage / death.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::TakeDamage(Damage &damage)
|
|
{
|
|
Check(this);
|
|
PoweredSubsystem::TakeDamage(damage);
|
|
}
|
|
|
|
void
|
|
Sensor::DeathReset(Logical /*full_recovery*/)
|
|
{
|
|
Check(this);
|
|
ResetToInitialState();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// CreateStreamedSubsystem Model-load-time construction. Not yet reconstructed
|
|
// (see MECHSUB.NOTES.md -- the 4.10 subsystem stream format).
|
|
//#############################################################################
|
|
//
|
|
int
|
|
Sensor::CreateStreamedSubsystem(
|
|
NotationFile *,
|
|
const char *,
|
|
const char *,
|
|
SubsystemResource *,
|
|
NotationFile *,
|
|
const ResourceDirectories *,
|
|
int
|
|
)
|
|
{
|
|
Fail("Sensor::CreateStreamedSubsystem -- sensor.cpp not yet reconstructed");
|
|
return 0;
|
|
}
|