Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,90 @@
#nullable enable
using System.Collections.Generic;
using Content.Shared.DrawDepth;
using Content.Shared.MobState;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Client.MobState
{
[UsedImplicitly]
public sealed class DamageStateVisualizer : AppearanceVisualizer, ISerializationHooks
{
private DamageState _data = DamageState.Alive;
private Dictionary<DamageState, string> _stateMap = new();
private int? _originalDrawDepth;
[DataField("normal")]
private string? normal;
[DataField("crit")]
private string? crit;
[DataField("dead")]
private string? dead;
void ISerializationHooks.BeforeSerialization()
{
_stateMap.TryGetValue(DamageState.Alive, out normal);
_stateMap.TryGetValue(DamageState.Critical, out crit);
_stateMap.TryGetValue(DamageState.Dead, out dead);
}
void ISerializationHooks.AfterDeserialization()
{
if (normal != null)
{
_stateMap.Add(DamageState.Alive, normal);
}
if (crit != null)
{
_stateMap.Add(DamageState.Critical, crit);
}
if (dead != null)
{
_stateMap.Add(DamageState.Dead, dead);
}
}
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (!component.TryGetData(DamageStateVisuals.State, out DamageState data))
{
return;
}
if (_data == data)
{
return;
}
_data = data;
if (_stateMap.TryGetValue(_data, out var state))
{
sprite.LayerSetState(DamageStateVisualLayers.Base, state);
}
// So they don't draw over mobs anymore
if (_data == DamageState.Dead)
{
_originalDrawDepth = sprite.DrawDepth;
sprite.DrawDepth = (int) DrawDepth.FloorObjects;
}
else if (_originalDrawDepth != null)
{
sprite.DrawDepth = _originalDrawDepth.Value;
_originalDrawDepth = null;
}
}
}
public enum DamageStateVisualLayers : byte
{
Base
}
}

View File

@@ -0,0 +1,13 @@
using Content.Shared.MobState;
using Content.Shared.MobState.State;
using Robust.Shared.GameObjects;
namespace Content.Client.MobState
{
[RegisterComponent]
[ComponentReference(typeof(SharedMobStateComponent))]
[ComponentReference(typeof(IMobStateComponent))]
public class MobStateComponent : SharedMobStateComponent
{
}
}

View File

@@ -0,0 +1,37 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.MobState.Overlays
{
public class CircleMaskOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;
public CircleMaskOverlay()
{
IoCManager.InjectDependencies(this);
_shader = _prototypeManager.Index<ShaderPrototype>("CircleMask").Instance();
}
protected override void Draw(in OverlayDrawArgs args)
{
if (!CritOverlay.LocalPlayerHasState(_playerManager, false, true))
return;
var worldHandle = args.WorldHandle;
worldHandle.UseShader(_shader);
var viewport = _eyeManager.GetWorldViewport();
worldHandle.DrawRect(viewport, Color.White);
}
}
}

View File

@@ -0,0 +1,59 @@
using Content.Shared.MobState;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Client.MobState.Overlays
{
public class CritOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _gradientCircleShader;
private readonly ShaderInstance? _glowingBorderShader;
public CritOverlay()
{
IoCManager.InjectDependencies(this);
_gradientCircleShader = _prototypeManager.Index<ShaderPrototype>("GradientCircleMask").Instance();
}
public static bool LocalPlayerHasState(IPlayerManager pm, bool critical, bool dead) {
var playerEntity = pm.LocalPlayer?.ControlledEntity;
if (playerEntity == null)
{
return false;
}
if (playerEntity.TryGetComponent<IMobStateComponent>(out var mobState))
{
if (critical)
if (mobState.IsCritical())
return true;
if (dead)
if (mobState.IsDead())
return true;
}
return false;
}
protected override void Draw(in OverlayDrawArgs args)
{
if (!LocalPlayerHasState(_playerManager, true, false))
return;
var worldHandle = args.WorldHandle;
var viewport = _eyeManager.GetWorldViewport();
worldHandle.UseShader(_gradientCircleShader);
worldHandle.DrawRect(viewport, Color.White);
}
}
}

View File

@@ -0,0 +1,8 @@
using Content.Shared.MobState.State;
namespace Content.Client.MobState.States
{
public class CriticalMobState : SharedCriticalMobState
{
}
}

View File

@@ -0,0 +1,40 @@
using Content.Client.Standing;
using Content.Shared.MobState;
using Content.Shared.MobState.State;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.MobState.States
{
public class DeadMobState : SharedDeadMobState
{
public override void EnterState(IEntity entity)
{
base.EnterState(entity);
if (entity.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
}
EntitySystem.Get<StandingStateSystem>().Down(entity);
if (entity.TryGetComponent(out PhysicsComponent? physics))
{
physics.CanCollide = false;
}
}
public override void ExitState(IEntity entity)
{
base.ExitState(entity);
EntitySystem.Get<StandingStateSystem>().Standing(entity);
if (entity.TryGetComponent(out PhysicsComponent? physics))
{
physics.CanCollide = true;
}
}
}
}

View File

@@ -0,0 +1,20 @@
using Content.Shared.MobState;
using Content.Shared.MobState.State;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
namespace Content.Client.MobState.States
{
public class NormalMobState : SharedNormalMobState
{
public override void EnterState(IEntity entity)
{
base.EnterState(entity);
if (entity.TryGetComponent(out AppearanceComponent? appearance))
{
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
}
}
}
}