Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit e69ff9e

Browse files
committed
Added Entity::RemoveFromGroup for Just Alex :)
1 parent 93cdbf5 commit e69ff9e

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
250250

251251
- New `SoundContainer` INI and Lua (R/W) property `PitchVariation`, which can be used to randomize the pitch of the sounds being played.
252252

253+
- Added `Entity` Lua function `entity:RemoveFromGroup(groupToRemoveFrom)` which removes the given group from the `Entity`. The reverse of `AddToGroup`.
254+
253255
</details>
254256

255257
<details><summary><b>Changed</b></summary>

Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace RTE {
2222
.def("Reset", &Entity::Reset)
2323
.def("GetModuleAndPresetName", &Entity::GetModuleAndPresetName)
2424
.def("AddToGroup", &Entity::AddToGroup)
25+
.def("RemoveFromGroup", &Entity::RemoveFromGroup)
2526
.def("IsInGroup", &Entity::IsInGroup);
2627
}
2728

System/Entity.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,13 @@ namespace RTE {
382382
/// Adds this Entity to a new grouping.
383383
/// </summary>
384384
/// <param name="newGroup">A string which describes the group to add this to. Duplicates will be ignored.</param>
385-
void AddToGroup(std::string newGroup) { m_Groups.push_back(newGroup); m_Groups.sort(); m_Groups.unique(); m_LastGroupSearch.clear(); }
385+
void AddToGroup(const std::string &newGroup) { m_Groups.push_back(newGroup); m_Groups.sort(); m_Groups.unique(); m_LastGroupSearch.clear(); }
386+
387+
/// <summary>
388+
/// Removes this Entity from the specified grouping.
389+
/// </summary>
390+
/// <param name="groupToRemoveFrom">A string which describes the group to remove this from.</param>
391+
void RemoveFromGroup(const std::string &groupToRemoveFrom) { m_Groups.remove(groupToRemoveFrom); m_LastGroupSearch.clear(); }
386392

387393
/// <summary>
388394
/// Returns random weight used in PresetMan::GetRandomBuyableOfGroupFromTech.

0 commit comments

Comments
 (0)