Skip to content

Commit

Permalink
#6092: Extend FX interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 4, 2022
1 parent e6ceda0 commit 2c5b31d
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/ifx.h
Expand Up @@ -12,7 +12,11 @@ class IFxAction

virtual ~IFxAction() {}

// Returns the action delay in seconds
virtual float getDelay() = 0;

// True: Don't shake the entity this effect is attached to
virtual bool getIgnoreMaster() = 0;
};

class IFxDeclaration :
Expand All @@ -26,6 +30,10 @@ class IFxDeclaration :

// Returns the n-th action (based on the given 0-based index)
virtual IFxAction::Ptr getAction(std::size_t index) = 0;

// Returns the name of the joint this FX should bind to
// Evaluated to an empty string if "bindTo" is not set
virtual std::string getBindTo() = 0;
};

}
1 change: 1 addition & 0 deletions radiantcore/CMakeLists.txt
Expand Up @@ -71,6 +71,7 @@ add_library(radiantcore MODULE
fonts/GlyphInfo.cpp
fonts/GlyphSet.cpp
fx/FxDeclaration.cpp
fx/FxAction.cpp
fx/FxManager.cpp
grid/GridManager.cpp
imagefile/BMPLoader.cpp
Expand Down
21 changes: 21 additions & 0 deletions radiantcore/fx/FxAction.cpp
@@ -0,0 +1,21 @@
#include "FxAction.h"

namespace fx
{

FxAction::FxAction() :
_delayInSeconds(0.0),
_ignoreMaster(false)
{}

float FxAction::getDelay()
{
return _delayInSeconds;
}

bool FxAction::getIgnoreMaster()
{
return _ignoreMaster;
}

}
24 changes: 24 additions & 0 deletions radiantcore/fx/FxAction.h
@@ -0,0 +1,24 @@
#pragma once

#include "ifx.h"

namespace fx
{

class FxAction :
public IFxAction
{
private:
float _delayInSeconds;
bool _ignoreMaster;

public:
using Ptr = std::shared_ptr<FxAction>;

FxAction();

float getDelay() override;
bool getIgnoreMaster() override;
};

}
7 changes: 7 additions & 0 deletions radiantcore/fx/FxDeclaration.cpp
Expand Up @@ -19,8 +19,15 @@ IFxAction::Ptr FxDeclaration::getAction(std::size_t index)
return _actions.at(index);
}

std::string FxDeclaration::getBindTo()
{
ensureParsed();
return _bindTo;
}

void FxDeclaration::onBeginParsing()
{
_bindTo.clear();
_actions.clear();
}

Expand Down
2 changes: 2 additions & 0 deletions radiantcore/fx/FxDeclaration.h
Expand Up @@ -12,12 +12,14 @@ class FxDeclaration :
{
private:
std::vector<IFxAction::Ptr> _actions;
std::string _bindTo;

public:
FxDeclaration(const std::string& name);

std::size_t getNumActions() override;
IFxAction::Ptr getAction(std::size_t index) override;
std::string getBindTo() override;

protected:
void onBeginParsing() override;
Expand Down
2 changes: 2 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -85,6 +85,7 @@
<ClCompile Include="..\..\radiantcore\fonts\FontManager.cpp" />
<ClCompile Include="..\..\radiantcore\fonts\GlyphInfo.cpp" />
<ClCompile Include="..\..\radiantcore\fonts\GlyphSet.cpp" />
<ClCompile Include="..\..\radiantcore\fx\FxAction.cpp" />
<ClCompile Include="..\..\radiantcore\fx\FxDeclaration.cpp" />
<ClCompile Include="..\..\radiantcore\fx\FxManager.cpp" />
<ClCompile Include="..\..\radiantcore\grid\GridManager.cpp" />
Expand Down Expand Up @@ -831,6 +832,7 @@
<ClInclude Include="..\..\radiantcore\fonts\FontManager.h" />
<ClInclude Include="..\..\radiantcore\fonts\GlyphInfo.h" />
<ClInclude Include="..\..\radiantcore\fonts\GlyphSet.h" />
<ClInclude Include="..\..\radiantcore\fx\FxAction.h" />
<ClInclude Include="..\..\radiantcore\fx\FxDeclaration.h" />
<ClInclude Include="..\..\radiantcore\fx\FxManager.h" />
<ClInclude Include="..\..\radiantcore\grid\GridItem.h" />
Expand Down
6 changes: 6 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -1162,6 +1162,9 @@
<ClCompile Include="..\..\radiantcore\fx\FxDeclaration.cpp">
<Filter>src\fx</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\fx\FxAction.cpp">
<Filter>src\fx</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiantcore\modulesystem\ModuleLoader.h">
Expand Down Expand Up @@ -2388,6 +2391,9 @@
<ClInclude Include="..\..\radiantcore\fx\FxDeclaration.h">
<Filter>src\fx</Filter>
</ClInclude>
<ClInclude Include="..\..\radiantcore\fx\FxAction.h">
<Filter>src\fx</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\install\gl\cubemap_fp.glsl">
Expand Down

0 comments on commit 2c5b31d

Please sign in to comment.