Merge branch 'master' into 2020-04-28-tool-component

# Conflicts:
#	SpaceStation14.sln.DotSettings
This commit is contained in:
zumorica
2020-05-22 11:31:18 +02:00
56 changed files with 1128 additions and 43 deletions

View File

@@ -101,6 +101,7 @@ namespace Content.Client.GameObjects
ActiveIndex = cast.ActiveIndex;
_gui?.UpdateHandIcons();
RefreshInHands();
}
private void _setHand(string hand, IEntity entity)
@@ -116,7 +117,19 @@ namespace Content.Client.GameObjects
return;
}
var item = entity.GetComponent<ItemComponent>();
SetInHands(hand, entity);
}
private void SetInHands(string hand, IEntity entity)
{
if (entity == null)
{
_sprite.LayerSetVisible($"hand-{hand}", false);
return;
}
if (!entity.TryGetComponent(out ItemComponent item)) return;
var maybeInhands = item.GetInHandStateInfo(hand);
if (!maybeInhands.HasValue)
{
@@ -130,6 +143,16 @@ namespace Content.Client.GameObjects
}
}
public void RefreshInHands()
{
if (!Initialized) return;
foreach (var (hand, entity) in _hands)
{
SetInHands(hand, entity);
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);

View File

@@ -3,8 +3,10 @@ using Content.Shared.GameObjects.Components.Items;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.ResourceManagement;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Renderable;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
@@ -26,7 +28,13 @@ namespace Content.Client.GameObjects
public string EquippedPrefix
{
get => _equippedPrefix;
set => _equippedPrefix = value;
set
{
_equippedPrefix = value;
if (!ContainerHelpers.TryGetContainer(Owner, out IContainer container)) return;
if(container.Owner.TryGetComponent(out HandsComponent hands))
hands.RefreshInHands();
}
}
public (RSI rsi, RSI.StateId stateId)? GetInHandStateInfo(string hand)

View File

@@ -1,6 +1,11 @@
using Content.Shared.GameObjects.Components.Mobs;
using System;
using Content.Shared.GameObjects.Components.Mobs;
using Microsoft.CodeAnalysis.Completion;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Client.GameObjects.Components.Animations;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Shared.Animations;
using Robust.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
@@ -11,19 +16,51 @@ namespace Content.Client.GameObjects.Components.Mobs
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (component.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var state))
{
switch (state)
{
case SharedSpeciesComponent.MobState.Stand:
sprite.Rotation = 0;
case SharedSpeciesComponent.MobState.Standing:
SetRotation(component, 0);
break;
case SharedSpeciesComponent.MobState.Down:
sprite.Rotation = Angle.FromDegrees(90);
SetRotation(component, Angle.FromDegrees(90));
break;
}
}
}
private void SetRotation(AppearanceComponent component, Angle rotation)
{
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent animation))
{
sprite.Rotation = rotation;
return;
}
if (animation.HasRunningAnimation("rotate"))
animation.Stop("rotate");
animation.Play(new Animation
{
Length = TimeSpan.FromSeconds(0.125),
AnimationTracks =
{
new AnimationTrackComponentProperty
{
ComponentType = typeof(ISpriteComponent),
Property = nameof(ISpriteComponent.Rotation),
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(sprite.Rotation, 0),
new AnimationTrackProperty.KeyFrame(rotation, 0.125f)
}
}
}
}, "rotate");
}
}
}