diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/movieobjects/dmeparticlesystemdefinition.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/movieobjects/dmeparticlesystemdefinition.h')
| -rw-r--r-- | public/movieobjects/dmeparticlesystemdefinition.h | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/public/movieobjects/dmeparticlesystemdefinition.h b/public/movieobjects/dmeparticlesystemdefinition.h new file mode 100644 index 0000000..d2bee4f --- /dev/null +++ b/public/movieobjects/dmeparticlesystemdefinition.h @@ -0,0 +1,165 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: A particle system definition +// +//============================================================================= + +#ifndef DMEPARTICLESYSTEMDEFINITION_H +#define DMEPARTICLESYSTEMDEFINITION_H +#ifdef _WIN32 +#pragma once +#endif + +#include "datamodel/dmelement.h" +#include "datamodel/dmattribute.h" +#include "datamodel/dmattributevar.h" +#include "datamodel/dmehandle.h" +#include "particles/particles.h" + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class CDmeEditorTypeDictionary; +class CDmeParticleSystemDefinition; + + +//----------------------------------------------------------------------------- +// Base class for particle functions inside a particle system definition +//----------------------------------------------------------------------------- +class CDmeParticleFunction : public CDmElement +{ + DEFINE_ELEMENT( CDmeParticleFunction, CDmElement ); + +public: + virtual const char *GetFunctionType() const { return NULL; } + virtual void Resolve(); + virtual void OnElementUnserialized(); + + // Used for backward compat + void AddMissingFields( const DmxElementUnpackStructure_t *pUnpack ); + + // Returns the editor type dictionary + CDmeEditorTypeDictionary* GetEditorTypeDictionary(); + + // Marks a particle system as a new instance + // This is basically a workaround to prevent newly-copied particle functions + // from recompiling themselves a zillion times + void MarkNewInstance(); + +protected: + void UpdateAttributes( const DmxElementUnpackStructure_t *pUnpack ); + +private: + // Defines widgets to edit this bad boy + CDmeHandle< CDmeEditorTypeDictionary > m_hTypeDictionary; + bool m_bSkipNextResolve; +}; + + +//----------------------------------------------------------------------------- +// Something that updates particles +//----------------------------------------------------------------------------- +class CDmeParticleOperator : public CDmeParticleFunction +{ + DEFINE_ELEMENT( CDmeParticleOperator, CDmeParticleFunction ); + +public: + // Sets the particle operator + void SetFunction( IParticleOperatorDefinition *pDefinition ); + + // Returns the function type + virtual const char *GetFunctionType() const; + +private: + CDmaString m_FunctionName; +}; + + +//----------------------------------------------------------------------------- +// A child of a particle system +//----------------------------------------------------------------------------- +class CDmeParticleChild : public CDmeParticleFunction +{ + DEFINE_ELEMENT( CDmeParticleChild, CDmeParticleFunction ); + +public: + // Sets the particle operator + void SetChildParticleSystem( CDmeParticleSystemDefinition *pDef, IParticleOperatorDefinition *pDefinition ); + + // Returns the function type + virtual const char *GetFunctionType() const; + + CDmaElement< CDmeParticleSystemDefinition > m_Child; +}; + + + +//----------------------------------------------------------------------------- +// Represents an editable entity; draws its helpers +//----------------------------------------------------------------------------- +class CDmeParticleSystemDefinition : public CDmElement +{ + DEFINE_ELEMENT( CDmeParticleSystemDefinition, CDmElement ); + +public: + virtual void OnElementUnserialized(); + virtual void Resolve(); + + // Add, remove + CDmeParticleFunction* AddOperator( ParticleFunctionType_t type, const char *pFunctionName ); + CDmeParticleFunction* AddChild( CDmeParticleSystemDefinition *pChild ); + void RemoveFunction( ParticleFunctionType_t type, CDmeParticleFunction *pParticleFunction ); + void RemoveFunction( ParticleFunctionType_t type, int nIndex ); + + // Find + int FindFunction( ParticleFunctionType_t type, CDmeParticleFunction *pParticleFunction ); + int FindFunction( ParticleFunctionType_t type, const char *pFunctionName ); + + // Iteration + int GetParticleFunctionCount( ParticleFunctionType_t type ) const; + CDmeParticleFunction *GetParticleFunction( ParticleFunctionType_t type, int nIndex ); + + // Reordering + void MoveFunctionUp( ParticleFunctionType_t type, CDmeParticleFunction *pElement ); + void MoveFunctionDown( ParticleFunctionType_t type, CDmeParticleFunction *pElement ); + + // Returns the editor type dictionary + CDmeEditorTypeDictionary* GetEditorTypeDictionary(); + + // Recompiles the particle system when a change occurs + void RecompileParticleSystem(); + + // Marks a particle system as a new instance + // This is basically a workaround to prevent newly-copied particle functions + // from recompiling themselves a zillion times + void MarkNewInstance(); + + // Should we use name-based lookup? + bool UseNameBasedLookup() const; + +private: + CDmaElementArray< CDmeParticleFunction > m_ParticleFunction[PARTICLE_FUNCTION_COUNT]; + CDmaVar< bool > m_bPreventNameBasedLookup; + + // Defines widgets to edit this bad boy + CDmeHandle< CDmeEditorTypeDictionary > m_hTypeDictionary; +}; + + +//----------------------------------------------------------------------------- +// Should we use name-based lookup? +//----------------------------------------------------------------------------- +inline bool CDmeParticleSystemDefinition::UseNameBasedLookup() const +{ + return !m_bPreventNameBasedLookup; +} + + +//----------------------------------------------------------------------------- +// Human readable string for the particle functions +//----------------------------------------------------------------------------- +const char *GetParticleFunctionTypeName( ParticleFunctionType_t type ); + + +#endif // DMEPARTICLESYSTEMDEFINITION_H |