#pragma once #include "subsystm.h" #include "boxsolid.h" class DoorFrame; //########################################################################## //##################### Door::SubsystemResource ################### //########################################################################## struct Door__SubsystemResource: public Subsystem::SubsystemResource { Vector3D motionExtent; Scalar travelTime, deadTime; ResourceDescription::ResourceID collisionID; }; // // A door has no update record. It is Hermit clockwork - every host builds // its own out of the map stream and derives the position from the mission // clock, so there is nothing to publish and nothing to receive. // //########################################################################## //######################### CLASS Door ######################## //########################################################################## class Door : public Subsystem { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Messaging Support // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Shared Data Support // public: static Derivation *GetClassDerivations(); static SharedData DefaultData; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Attribute Support // public: enum { PercentOpenAttributeID = Subsystem::NextAttributeID, CurrentPositionAttributeID, VideoResourceAttributeID, CurrentVelocityAttributeID, NextAttributeID }; private: static const IndexEntry AttributePointers[]; protected: //static AttributeIndexSet AttributeIndex static AttributeIndexSet& GetAttributeIndex(); public: Scalar percentOpen; ResourceDescription::ResourceID videoResource; Point3D currentPosition; Vector3D currentVelocity; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Model Support // public: enum { Opening = Subsystem::StateCount, Opened, Closing, Closed, StateCount }; typedef void (Door::*Performance)(Scalar time_slice); void SetPerformance(Performance performance) { Check(this); activePerformance = (Simulation::Performance)performance; } void SlideDoor(Scalar time_slice); void MoveCollisionVolume(Scalar open_percent); BoxedSolid* GetFirstBoxedSolid() {Check(this); return collisionVolumes;} //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Construction and Destruction // public: typedef Door__SubsystemResource SubsystemResource; Door( DoorFrame *entity, int subsystem_ID, SubsystemResource *subsystem_resource ); ~Door(); Logical TestInstance() const; static Logical CreateStreamedSubsystem( NotationFile *model_file, const char *model_name, const char *subsystem_name, SubsystemResource *subsystem_resource, NotationFile *subsystem_file, const ResourceDirectories *directories, ResourceFile *res_file ); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Local Support // private: Point3D localExtent, worldExtent; Scalar travelTime, deadTime, // // Where in the cycle this door sits at mission time zero, and the // length of one full open-close-open cycle. phaseOffset is not in // the subsystem resource yet: every door in the game is in lockstep, // and adding a field to Door__SubsystemResource changes its sizeof, // which invalidates every prebuilt .res. Wire it to a "PhaseOffset" // notation entry when there is a reason to rebuild resources. // phaseOffset, cycleTime; int collisionVolumeCount; BoxedSolid *collisionTemplates, *collisionVolumes; };