Skip to content

Commit

Permalink
Do not replace components that have the KeepOnReplace attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
isadorasophia committed Jul 26, 2024
1 parent 478c70f commit 30dac0a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Bang/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ public void Replace(IComponent[] components, List<(int, string)> children, bool

if (HasComponent(index))
{
// Skip components that must be kept.
if (Attribute.IsDefined(c.GetType(), typeof(KeepOnReplaceAttribute)))
{
continue;
}

ReplaceComponent(c, index, forceReplace: true);
}
else
Expand Down

0 comments on commit 30dac0a

Please sign in to comment.