Skip to content

Commit

Permalink
feat: death message event
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsubasa6848 committed Mar 4, 2024
1 parent 8864421 commit 0fe3c69
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/CompatibilityApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,12 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "getVersion_GMLIB", []() -> std::string {
return GMLIB::Version::getLibVersionString();
});
RemoteCall::exportAs(
"GMLIB_API",
"resourcePackTranslate",
[](std::string key, std::vector<std::string> params) -> std::string { return I18n::get(key, params); }
);
RemoteCall::exportAs("GMLIB_API", "chooseResourcePackI18nLanguage", [](std::string code) -> void {
I18n::chooseLanguage(code);
});
}
20 changes: 20 additions & 0 deletions src/EventAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ void Export_Event_API() {
);
return true;
}
case do_hash("onDeathMessage"): {
auto Call = RemoteCall::importAs<
bool(std::string message, std::vector<std::string>, Actor * dead, Actor * killer, int cause)>(
eventName,
eventId
);
eventBus->emplaceListener<GMLIB::Event::EntityEvent::DeathMessageAfterEvent>(
[Call](GMLIB::Event::EntityEvent::DeathMessageAfterEvent& ev) {
auto msg = ev.getDeathMessage();
auto source = ev.getDamageSource();
Actor* entity = nullptr;
entity = GMLIB_Level::getLevel()->fetchEntity(source.getDamagingEntityUniqueID());
if (entity->getOwner()) {
entity = entity->getOwner();
}
Call(msg.first, msg.second, &ev.self(), entity, (int)source.getCause());
}
);
return true;
}
default:
return false;
}
Expand Down

0 comments on commit 0fe3c69

Please sign in to comment.