//===========================================================================// // File: ammobin.hpp // // Project: BattleTech Brick: Mech weapons // // Contents: AmmoBin -- an ammunition store (with cook-off heat) // //---------------------------------------------------------------------------// // Copyright (C) 1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #if !defined(AMMOBIN_HPP) # define AMMOBIN_HPP # if !defined(HEAT_HPP) # include # endif //##################### Forward Class Declarations ####################### class Mech; //########################################################################### //###################### AmmoBin Model Resource ######################## //########################################################################### struct AmmoBin__SubsystemResource: public HeatWatcher::SubsystemResource { int ammoClassID; int ammoModelFile; int explosionModelFile; int ammoCount; Scalar feedRate; Scalar heatPerRound; }; //########################################################################### //############################## AmmoBin ############################### //########################################################################### class AmmoBin: public HeatWatcher { public: static Derivation ClassDerivations; static SharedData DefaultData; static Logical TestClass(Mech &); Logical TestInstance() const; int GetAmmoCount() const { return ammoCount; } // // The feed interface the ballistic fire path consumes. Ammo states // (the 1995 feed alarm): 1 = a round is chambered/ready, 2 = EMPTY. // FeedAmmo pulls one round (the launcher calls it on a granted shot); // returns 0 when dry. (Feed-rate pacing + the cook-off heat source // join with the heat wave; the launcher's own recharge already paces // shots.) // enum { AmmoLoadedState = 1, AmmoEmptyState = 2 }; int GetAmmoState() const { Check(this); return (ammoCount > 0) ? AmmoLoadedState : AmmoEmptyState; } // // Respawn restock: refill the magazine from the authored count. // virtual void DeathReset(Logical full_reset); int FeedAmmo() { Check(this); if (ammoCount <= 0) { return 0; } --ammoCount; return 1; } public: typedef AmmoBin__SubsystemResource SubsystemResource; AmmoBin( Mech *owner, int subsystem_ID, SubsystemResource *subsystem_resource, SharedData &shared_data = DefaultData ); ~AmmoBin(); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Attribute Support. The shipped pool lists this class's attributes // contiguously after the class name: // AmmoCount TimeToReady AmmoClassID AmmoState FireCountdownStarted // and BTL4.RES binds watchers to AmmoState and FireCountdownStarted on // every bin. AmmoState is a *State name, so it MUST resolve to a // StateIndicator (see RENDER-ROADMAP.NOTES.md) -- ammoAlarm below is // one. AmmoBin chains HeatWatcher -> MechSubsystem, so the ids start // at MechSubsystem::NextAttributeID. // public: enum { AmmoCountAttributeID = MechSubsystem::NextAttributeID, TimeToReadyAttributeID, AmmoClassIDAttributeID, AmmoStateAttributeID, FireCountdownStartedAttributeID, NextAttributeID }; static const IndexEntry AttributePointers[]; static AttributeIndexSet AttributeIndex; protected: int ammoCount; int initialAmmoCount; Scalar feedTimer; Scalar feedRate; int ammoClassID; int ammoModelFile; int explosionModelFile; Scalar heatPerRound; int cookOffArmed; int cookOffTime; // // Spends the spare reserved slot rather than growing the class -- // AmmoBin has offset-sensitive neighbours. // int fireCountdownStarted; // was: reserved AlarmIndicator ammoAlarm; // // Cook-off heat-source registration state (advanced by the heat sim). // Reserved until the per-frame path is reconstructed. // int cookOffState[12]; }; #endif