Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: VMSolidus <[email protected]>
Signed-off-by: spess-empyrean <[email protected]>
  • Loading branch information
spess-empyrean and VMSolidus authored Jan 15, 2025
1 parent a786840 commit 1885d33
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions Content.Client/Light/EntitySystems/LightBehaviorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,17 @@ private void CopyLightSettings(Entity<LightBehaviourComponent> entity, string pr
public void StartLightBehaviour(Entity<LightBehaviourComponent> entity, string id = "")
{
if (!EntityManager.TryGetComponent(entity, out AnimationPlayerComponent? animation))
{
return;
}

foreach (var container in entity.Comp.Animations)
{
if (container.LightBehaviour.ID == id || id == string.Empty)
{
if (!_player.HasRunningAnimation(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key))
{
CopyLightSettings(entity, container.LightBehaviour.Property);
container.LightBehaviour.UpdatePlaybackValues(container.Animation);
_player.Play(entity, container.Animation, LightBehaviourComponent.KeyPrefix + container.Key);
}
}
if (container.LightBehaviour.ID != id || id != string.Empty
|| _player.HasRunningAnimation(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key))
continue;

CopyLightSettings(entity, container.LightBehaviour.Property);
container.LightBehaviour.UpdatePlaybackValues(container.Animation);
_player.Play(entity, container.Animation, LightBehaviourComponent.KeyPrefix + container.Key);
}
}
/// <summary>
Expand All @@ -118,17 +115,14 @@ public void StopLightBehaviour(Entity<LightBehaviourComponent> entity, string id
var toRemove = new List<LightBehaviourComponent.AnimationContainer>();
foreach (var container in comp.Animations)
{
if (container.LightBehaviour.ID == id || id == string.Empty)
{
if (_player.HasRunningAnimation(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key))
{
_player.Stop(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key);
}
if (removeBehaviour)
{
toRemove.Add(container);
}
}
if (container.LightBehaviour.ID != id || id != string.Empty)
continue;

if (_player.HasRunningAnimation(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key))
_player.Stop(entity, animation, LightBehaviourComponent.KeyPrefix + container.Key);

if (removeBehaviour)
toRemove.Add(container);
}
foreach (var container in toRemove)
{
Expand Down

0 comments on commit 1885d33

Please sign in to comment.