Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
FaDeOkno committed Aug 7, 2024
1 parent 0bc740f commit 406313d
Show file tree
Hide file tree
Showing 54 changed files with 1,051 additions and 357 deletions.
13 changes: 2 additions & 11 deletions Content.Client/ADT/Phantom/UI/PhantomFreedomMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech;
using Content.Shared.Whitelist;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
Expand All @@ -11,10 +9,7 @@
using Robust.Shared.Prototypes;
using Content.Shared.Phantom;
using Robust.Shared.Utility;
using Content.Shared.Humanoid.Prototypes;
using Content.Client.Humanoid;
using Content.Shared.Preferences;
using Robust.Shared.Map;
using Content.Shared.Actions;

namespace Content.Client.ADT.Phantom.UI;
Expand All @@ -24,11 +19,8 @@ public sealed partial class PhantomFreedomMenu : RadialMenu
{
[Dependency] private readonly EntityManager _entManager = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly ISharedPlayerManager _playerManager = default!;
[Dependency] private readonly HumanoidAppearanceSystem _appearanceSystem = default!;

private readonly SpriteSystem _spriteSystem;
private readonly EntityWhitelistSystem _whitelistSystem;
public List<(NetEntity, HumanoidCharacterProfile, string)> Vessels = new();

public event Action<string>? OnSelectFreedom;
Expand All @@ -39,7 +31,6 @@ public PhantomFreedomMenu()
RobustXamlLoader.Load(this);

_spriteSystem = _entManager.System<SpriteSystem>();
_whitelistSystem = _entManager.System<EntityWhitelistSystem>();
}

public void Populate(RequestPhantomFreedomMenuEvent args)
Expand All @@ -50,6 +41,7 @@ public void Populate(RequestPhantomFreedomMenuEvent args)
{
var proto = _proto.Index(protoId);


var button = new PhantomFreedomMenuButton
{
StyleClasses = { "RadialMenuButton" },
Expand All @@ -58,7 +50,6 @@ public void Populate(RequestPhantomFreedomMenuEvent args)
ID = proto.ID,
};


if (proto.TryGetComponent(out InstantActionComponent? action) && action.Icon != null)
{
var tex = new TextureRect
Expand All @@ -67,7 +58,7 @@ public void Populate(RequestPhantomFreedomMenuEvent args)
VerticalAlignment = VAlignment.Top,
Texture = _spriteSystem.Frame0(action.Icon ?? SpriteSpecifier.Invalid),
TextureScale = new Vector2(1.5f, 1.5f),
SetSize = new Vector2(28f, 28f),
SetSize = new Vector2(48f, 48f),
};
button.AddChild(tex);
}
Expand Down
9 changes: 4 additions & 5 deletions Content.Client/ADT/Phantom/UI/PhantomStyleMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ public PhantomStyleMenu()
ToolTip = Loc.GetString(style.Name ?? String.Empty),
ProtoId = style.ID,
};

var tex = new TextureRect
{
HorizontalAlignment = HAlignment.Left,
VerticalAlignment = VAlignment.Top,
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
Texture = _spriteSystem.Frame0(style.Icon ?? SpriteSpecifier.Invalid),
TextureScale = new Vector2(1.5f, 1.5f),
SetSize = new Vector2(28f, 28f),
SetSize = new Vector2(48f, 48f),
};

button.AddChild(tex);

parent.AddChild(button);
}

Expand Down
30 changes: 28 additions & 2 deletions Content.Server/ADT/GhostInteractions/GhostRadioSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Interaction;
using Content.Shared.PowerCell;
using Content.Shared.GhostInteractions;
using Content.Shared.Interaction.Events;

namespace Content.Server.GhostInteractions;

Expand All @@ -19,11 +20,36 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<GhostRadioComponent, ActivateInWorldEvent>(OnTranslatorToggle);
SubscribeLocalEvent<GhostRadioComponent, ActivateInWorldEvent>(OnRadioToggle);
SubscribeLocalEvent<GhostRadioComponent, UseInHandEvent>(OnRadioUseInHand);

SubscribeLocalEvent<GhostRadioComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
}

private void OnTranslatorToggle(EntityUid translator, GhostRadioComponent component, ActivateInWorldEvent args)
private void OnRadioToggle(EntityUid translator, GhostRadioComponent component, ActivateInWorldEvent args)
{
if (!component.ToggleOnInteract)
return;

var hasPower = _powerCell.HasDrawCharge(translator);

var isEnabled = !component.Enabled;

isEnabled &= hasPower;
component.Enabled = isEnabled;

OnAppearanceChange(translator, component);

// HasPower shows a popup when there's no power, so we do not proceed in that case
if (hasPower)
{
var message =
Loc.GetString(component.Enabled ? "ghost-radio-component-turnon" : "ghost-radio-component-shutoff");
_popup.PopupEntity(message, component.Owner, args.User);
}
}

private void OnRadioUseInHand(EntityUid translator, GhostRadioComponent component, UseInHandEvent args)
{
if (!component.ToggleOnInteract)
return;
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/ADT/Phantom/EntitySystems/PhantomSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,7 +1730,8 @@ public bool TryRevive(EntityUid uid, PhantomComponent component)
}

var randomVessel = _random.Pick(allowedVessels);
ChangeEssenceAmount(uid, component.Essence, component);
component.Essence = 50;
ChangeEssenceAmount(uid, 0, component, false);

if (!component.HasHaunted)
{
Expand Down
12 changes: 12 additions & 0 deletions Content.Server/ADT/Phantom/EntitySystems/VesselSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
using Content.Shared.Phantom;
using Content.Shared.Mobs;
using Content.Shared.Eye;
using Content.Shared.Damage.Systems;
using Content.Shared.Damage;

namespace Content.Server.Phantom.EntitySystems;

public sealed partial class PhantomVesselSystem : EntitySystem
{
[Dependency] private readonly PhantomSystem _phantom = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;

public override void Initialize()
{
Expand All @@ -18,6 +21,8 @@ public override void Initialize()
SubscribeLocalEvent<VesselComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<VesselComponent, MobStateChangedEvent>(OnDeath);
SubscribeLocalEvent<VesselComponent, EntityTerminatingEvent>(OnDeleted);
SubscribeLocalEvent<VesselComponent, EctoplasmHitscanHitEvent>(OnEctoplasmicDamage);

SubscribeLocalEvent<PhantomHolderComponent, MapInitEvent>(OnHauntedInit);
SubscribeLocalEvent<PhantomHolderComponent, MobStateChangedEvent>(OnHauntedDeath);
SubscribeLocalEvent<PhantomHolderComponent, ComponentShutdown>(OnHauntedShutdown);
Expand Down Expand Up @@ -61,6 +66,13 @@ private void OnDeath(EntityUid uid, VesselComponent component, MobStateChangedEv
}
}

private void OnEctoplasmicDamage(EntityUid uid, VesselComponent component, EctoplasmHitscanHitEvent args)
{
_damageableSystem.TryChangeDamage(component.Phantom, args.DamageToPhantom);
_damageableSystem.TryChangeDamage(uid, args.DamageToTarget, true);
_phantom.StopHaunt(component.Phantom, uid);
}

private void OnHauntedDeath(EntityUid uid, PhantomHolderComponent component, MobStateChangedEvent args)
{
if (args.NewMobState == MobState.Dead)
Expand Down
Loading

0 comments on commit 406313d

Please sign in to comment.