Minor appearance changes (#2370)

* Minor appearance changes

* Remove that redundant deleted property

* Fixes and remove redundant checks

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2020-11-14 00:42:35 +11:00
committed by GitHub
parent 4f03c81ddc
commit 02f827f063
14 changed files with 28 additions and 60 deletions

View File

@@ -60,12 +60,6 @@ namespace Content.Client.GameObjects.Components.Conveyor
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
ChangeState(component);
}
}

View File

@@ -60,12 +60,6 @@ namespace Content.Client.GameObjects.Components.Conveyor
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
ChangeState(component);
}
}

View File

@@ -150,12 +150,6 @@ namespace Content.Client.GameObjects.Components.Disposal
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
ChangeState(component);
}
}

View File

@@ -69,12 +69,6 @@ namespace Content.Client.GameObjects.Components.Disposal
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
ChangeState(component);
}
}

View File

@@ -103,8 +103,7 @@ namespace Content.Client.GameObjects.Components.Doors
public override void OnChangeData(AppearanceComponent component)
{
if (component.Owner.Deleted)
return;
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
var animPlayer = component.Owner.GetComponent<AnimationPlayerComponent>();

View File

@@ -12,11 +12,6 @@ namespace Content.Client.GameObjects.Components.MedicalScanner
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData(MedicalScannerVisuals.Status, out MedicalScannerStatus status)) return;
sprite.LayerSetState(MedicalScannerVisualLayers.Machine, StatusToMachineStateId(status));

View File

@@ -22,10 +22,8 @@ namespace Content.Client.GameObjects.Components.Nutrition
public override void OnChangeData(AppearanceComponent component)
{
if(!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite))
{
return;
};
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData<float>(SharedFoodComponent.FoodVisuals.MaxUses, out var maxUses))
{

View File

@@ -49,10 +49,7 @@ namespace Content.Client.GameObjects.Components.PDA
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
{
return;
}
var sprite = component.Owner.GetComponent<ISpriteComponent>();
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, false);
if (component.TryGetData(PDAVisuals.FlashlightLit, out bool isScreenLit))

View File

@@ -43,7 +43,7 @@ namespace Content.Client.GameObjects.Components
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
if (!entity.TryGetComponent<SpriteComponent>(out var sprite))
if (!entity.TryGetComponent<ISpriteComponent>(out var sprite))
{
throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer");
}
@@ -56,9 +56,7 @@ namespace Content.Client.GameObjects.Components
public override void OnChangeData(AppearanceComponent component)
{
if (component.Owner.Deleted)
return;
base.OnChangeData(component);
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite)) return;
if (!component.TryGetData(ParticleAcceleratorVisuals.VisualState, out ParticleAcceleratorVisualState state))
{

View File

@@ -57,8 +57,7 @@ namespace Content.Client.GameObjects.Components
public override void OnChangeData(AppearanceComponent component)
{
if (component.Owner.Deleted)
return;
base.OnChangeData(component);
if (!component.Owner.TryGetComponent<ISpriteComponent>(out var sprite)) return;
if (!component.Owner.TryGetComponent<AnimationPlayerComponent>(out var animPlayer)) return;

View File

@@ -16,8 +16,8 @@ namespace Content.Client.GameObjects.Components.VendingMachines
public sealed class VendingMachineVisualizer : AppearanceVisualizer
{
// TODO: Should default to off or broken if damaged
//
//
// TODO: The length of these animations is supposed to be dictated
// by the vending machine's pack prototype's `AnimationDuration`
// but we have no good way of passing that data from the server
@@ -38,7 +38,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
{"deny-unshaded", VendingMachineVisualLayers.BaseUnshaded},
{"broken", VendingMachineVisualLayers.Unlit},
};
private Dictionary<string, Animation> _animations = new Dictionary<string, Animation>();
public override void LoadData(YamlMappingNode node)
@@ -71,7 +71,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
_baseStates[textureState] = false;
continue;
}
_baseStates.Add(textureState, yamlNode.AsBool());
}
@@ -99,7 +99,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
private void InitializeAnimation(string key, bool unshaded = false)
{
_animations.Add(key, new Animation {Length = TimeSpan.FromSeconds(1.2f)});
var flick = new AnimationTrackSpriteFlick();
_animations[key].AnimationTracks.Add(flick);
flick.LayerKey = unshaded ? VendingMachineVisualLayers.BaseUnshaded : VendingMachineVisualLayers.Base;
@@ -128,13 +128,15 @@ namespace Content.Client.GameObjects.Components.VendingMachines
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
var animPlayer = component.Owner.GetComponent<AnimationPlayerComponent>();
if (!component.TryGetData(VendingMachineVisuals.VisualState, out VendingMachineVisualState state))
{
state = VendingMachineVisualState.Normal;
}
// Hide last state
HideLayers(sprite);
ActivateState(sprite, "off");
@@ -146,10 +148,10 @@ namespace Content.Client.GameObjects.Components.VendingMachines
ActivateState(sprite, "normal-unshaded");
ActivateState(sprite, "normal");
break;
case VendingMachineVisualState.Off:
break;
case VendingMachineVisualState.Broken:
ActivateState(sprite, "broken-unshaded");
ActivateState(sprite, "broken");
@@ -171,7 +173,7 @@ namespace Content.Client.GameObjects.Components.VendingMachines
throw new ArgumentOutOfRangeException();
}
}
// Helper methods just to avoid all of that hard-to-read-indented code
private void ActivateState(ISpriteComponent spriteComponent, string stateId)
{
@@ -192,14 +194,14 @@ namespace Content.Client.GameObjects.Components.VendingMachines
{
return;
}
if (!animationPlayer.HasRunningAnimation(key))
{
spriteComponent.LayerSetVisible(LayerMap[key], true);
animationPlayer.Play(animation, key);
}
}
public enum VendingMachineVisualLayers
{
// Off / Broken. The other layers will overlay this if the machine is on.

View File

@@ -18,6 +18,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels.Visualize
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData(BarrelBoltVisuals.BoltOpen, out bool boltOpen))

View File

@@ -45,6 +45,8 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged.Barrels.Visualize
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
// tl;dr
// 1.If no mag then hide it OR
// 2. If step 0 isn't visible then hide it (mag or unshaded)

View File

@@ -9,15 +9,16 @@ namespace Content.Client.GameObjects.Components.Wires
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
if (component.Owner.Deleted)
return;
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (component.TryGetData<bool>(WiresVisuals.MaintenancePanelState, out var state))
{
sprite.LayerSetVisible(WiresVisualLayers.MaintenancePanel, state);
}
// Mainly for spawn window
else
{
sprite.LayerSetVisible(WiresVisualLayers.MaintenancePanel, false);
}
}
public enum WiresVisualLayers