forked from skyrim-multiplayer/skymp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(skymp5-server): add spawnDelay property to gamemode API (skyrim-…
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
skymp5-server/cpp/addon/property_bindings/SpawnDelayBinding.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "SpawnDelayBinding.h" | ||
#include "NapiHelper.h" | ||
|
||
Napi::Value SpawnDelayBinding::Get(Napi::Env env, ScampServer& scampServer, | ||
uint32_t formId) | ||
{ | ||
auto& partOne = scampServer.GetPartOne(); | ||
|
||
auto& actor = partOne->worldState.GetFormAt<MpActor>(formId); | ||
return Napi::Number::New(env, actor.GetRespawnTime()); | ||
} | ||
|
||
void SpawnDelayBinding::Set(Napi::Env env, ScampServer& scampServer, | ||
uint32_t formId, Napi::Value newValue) | ||
{ | ||
auto& partOne = scampServer.GetPartOne(); | ||
|
||
auto newSpawnDelay = NapiHelper::ExtractFloat(newValue, "newSpawnDelay"); | ||
|
||
auto& actor = partOne->worldState.GetFormAt<MpActor>(formId); | ||
actor.SetRespawnTime(newSpawnDelay); | ||
} |
12 changes: 12 additions & 0 deletions
12
skymp5-server/cpp/addon/property_bindings/SpawnDelayBinding.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
#include "PropertyBinding.h" | ||
|
||
class SpawnDelayBinding : public PropertyBinding | ||
{ | ||
public: | ||
std::string GetPropertyName() const override { return "spawnDelay"; } | ||
Napi::Value Get(Napi::Env env, ScampServer& scampServer, | ||
uint32_t formId) override; | ||
void Set(Napi::Env env, ScampServer& scampServer, uint32_t formId, | ||
Napi::Value newValue) override; | ||
}; |