Add Friction Volume script

This commit is contained in:
Aaron Kimbre 2022-08-27 23:06:44 -05:00
parent 3b75ecc0b4
commit b6fb5f8173
4 changed files with 29 additions and 0 deletions

View File

@ -87,6 +87,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp"
"FlameJetServer.cpp" "FlameJetServer.cpp"
"ForceVolumeServer.cpp" "ForceVolumeServer.cpp"
"FountainOfImagination.cpp" "FountainOfImagination.cpp"
"FrictionVolume.cpp"
"FvBounceOverWall.cpp" "FvBounceOverWall.cpp"
"FvBrickPuzzleServer.cpp" "FvBrickPuzzleServer.cpp"
"FvCandle.cpp" "FvCandle.cpp"

View File

@ -170,6 +170,7 @@
#include "MailBoxServer.h" #include "MailBoxServer.h"
#include "ActMine.h" #include "ActMine.h"
#include "FireFirstSkillonStartup.h" #include "FireFirstSkillonStartup.h"
#include "FrictionVolume.h"
// Racing Scripts // Racing Scripts
#include "RaceImagineCrateServer.h" #include "RaceImagineCrateServer.h"
@ -627,6 +628,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
script = new FvRaceSmashEggImagineServer(); script = new FvRaceSmashEggImagineServer();
else if (scriptName == "scripts\\ai\\RACING\\OBJECTS\\RACE_SMASH_SERVER.lua") else if (scriptName == "scripts\\ai\\RACING\\OBJECTS\\RACE_SMASH_SERVER.lua")
script = new RaceSmashServer(); script = new RaceSmashServer();
else if (scriptName == "scripts\\02_server\\Map\\General\\L_FRICTION_VOLUME_SERVER.lua")
script = new FrictionVolume();
//NT: //NT:
else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_SENTINELWALKWAY_SERVER.lua") else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_SENTINELWALKWAY_SERVER.lua")

View File

@ -0,0 +1,14 @@
#include "FrictionVolume.h"
#include "PhantomPhysicsComponent.h"
#include "Entity.h"
void FrictionVolume::OnStartup(Entity* self) {
auto frictionAmount = self->GetVarAs<float>(m_FrictionVariable);
if (!frictionAmount) frictionAmount = m_DefaultFriction;
auto* phanPhys = self->GetComponent<PhantomPhysicsComponent>();
if (!phanPhys) return;
phanPhys->SetPhysicsEffectActive(true);
phanPhys->SetEffectType(4); // this should be noted in a enum somewhere
phanPhys->SetDirectionalMultiplier(frictionAmount);
}

11
dScripts/FrictionVolume.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include "CppScripts.h"
class FrictionVolume : public CppScripts::Script
{
public:
void OnStartup(Entity* self) override;
private:
const float m_DefaultFriction = 1.5;
const std::u16string m_FrictionVariable = u"FrictionAmt";
};