Skip to content

Commit 4679897

Browse files
committed
Remove overly defensive entt ctx.contains<T> checks that we would prefer to fail loudly
1 parent 826965c commit 4679897

3 files changed

Lines changed: 3 additions & 17 deletions

File tree

Source/Game-Lib/Game-Lib/ECS/Systems/Editor/EditorTools.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ namespace ECS::Systems::Editor
118118
return false;
119119

120120
entt::registry::context& ctx = registries->gameRegistry->ctx();
121-
if (!ctx.contains<Singletons::EditorSelection>())
122-
return false;
123-
124121
auto& selection = ctx.get<Singletons::EditorSelection>();
125122
if (selection.selectedEntity == entt::null || !registries->gameRegistry->valid(selection.selectedEntity))
126123
return false;
@@ -324,9 +321,6 @@ namespace ECS::Systems::Editor
324321
void EditorTools::SetSelectedEntity(entt::registry& registry, entt::entity entity)
325322
{
326323
entt::registry::context& ctx = registry.ctx();
327-
if (!ctx.contains<Singletons::EditorSelection>())
328-
return;
329-
330324
auto& selection = ctx.get<Singletons::EditorSelection>();
331325
if (selection.selectedEntity == entity)
332326
return;
@@ -338,9 +332,6 @@ namespace ECS::Systems::Editor
338332
void EditorTools::Update(entt::registry& registry, f32 /*deltaTime*/)
339333
{
340334
entt::registry::context& ctx = registry.ctx();
341-
if (!ctx.contains<Singletons::EditorSelection>())
342-
return;
343-
344335
auto& selection = ctx.get<Singletons::EditorSelection>();
345336

346337
GameRenderer* gameRenderer = ServiceLocator::GetGameRenderer();

Source/Game-Lib/Game-Lib/Scripting/Handlers/AssetHandler.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,9 @@ namespace Scripting::Asset
190190

191191
EnttRegistries* registries = ServiceLocator::GetEnttRegistries();
192192
entt::registry::context& ctx = registries->gameRegistry->ctx();
193-
if (ctx.contains<ECS::Singletons::EditorSelection>())
194-
{
195-
auto& selection = ctx.get<ECS::Singletons::EditorSelection>();
196-
selection.dragSpawnRequested = true;
197-
selection.dragSpawnModelPath = relativeRaw;
198-
}
193+
auto& selection = ctx.get<ECS::Singletons::EditorSelection>();
194+
selection.dragSpawnRequested = true;
195+
selection.dragSpawnModelPath = relativeRaw;
199196

200197
return 0;
201198
}

Source/Game-Lib/Game-Lib/Scripting/Handlers/EditorToolHandler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ namespace Scripting::Editor
4848
if (!registries || !registries->gameRegistry)
4949
return nullptr;
5050
auto& ctx = registries->gameRegistry->ctx();
51-
if (!ctx.contains<ECS::Singletons::EditorSelection>())
52-
return nullptr;
5351
return &ctx.get<ECS::Singletons::EditorSelection>();
5452
}
5553

0 commit comments

Comments
 (0)