When adding volatile script, return the script object.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -15,16 +15,17 @@ namespace CreatureLib::Battling {
|
||||
static constexpr size_t defaultCapacity = 8;
|
||||
ScriptSet() : _scripts(defaultCapacity), _lookup(defaultCapacity){};
|
||||
|
||||
void Add(BattleScript* script) {
|
||||
BattleScript* Add(BattleScript* script) {
|
||||
auto v = _lookup.TryGet(script->GetName());
|
||||
if (v.has_value()) {
|
||||
_scripts[v.value()]->Stack();
|
||||
delete script;
|
||||
return;
|
||||
return _scripts[v.value()];
|
||||
}
|
||||
|
||||
_scripts.Append(script);
|
||||
_lookup.Insert(script->GetName(), _scripts.Count() - 1);
|
||||
return script;
|
||||
}
|
||||
|
||||
std::optional<ArbUt::BorrowedPtr<BattleScript>> Get(const ArbUt::BasicStringView& key) const {
|
||||
|
||||
Reference in New Issue
Block a user