Skip to content

Commit

Permalink
Merge pull request #242 from Evgencheg/ee-merge
Browse files Browse the repository at this point in the history
Ee merge
  • Loading branch information
Evgencheg authored Oct 4, 2024
2 parents 183452a + cb26283 commit 5596bd2
Show file tree
Hide file tree
Showing 339 changed files with 4,683 additions and 2,434 deletions.
6 changes: 6 additions & 0 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,11 @@ public void ToggleGhostVisibility()
{
GhostVisibility = !GhostVisibility;
}

public void ReturnToRound()
{
var msg = new GhostReturnToRoundRequest();
RaiseNetworkEvent(msg);
}
}
}
2 changes: 1 addition & 1 deletion Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Stretch="KeepAspectCovered" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<SplitContainer State="Auto" HorizontalExpand="True">
<SplitContainer State="Auto" ResizeMode="NotResizable" HorizontalExpand="True">
<!-- LHS Controls -->
<BoxContainer Name="LeftSide" Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
<Control Name="DefaultState" VerticalExpand="True">
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@
</BoxContainer>
<!-- Lost Paradise Donate Preferences End -->
<BoxContainer Name="CMarkingsTab" HorizontalExpand="True" Orientation="Vertical" Margin="10">
<!-- Markings -->
<ScrollContainer VerticalExpand="True">
<ScrollContainer HorizontalExpand="True" HScrollEnabled="True" VerticalExpand="True" VScrollEnabled="True">
<!-- Markings -->
<humanoid:MarkingPicker Name="CMarkings" IgnoreCategories="Hair,FacialHair" />
</ScrollContainer>
</BoxContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void LoadGui()
Gui.ReturnToBodyPressed += ReturnToBody;
Gui.GhostRolesPressed += GhostRolesPressed;
Gui.TargetWindow.WarpClicked += OnWarpClicked;
Gui.ReturnToRoundPressed += ReturnToRound;

UpdateGui();
}
Expand All @@ -133,6 +134,7 @@ public void UnloadGui()
Gui.ReturnToBodyPressed -= ReturnToBody;
Gui.GhostRolesPressed -= GhostRolesPressed;
Gui.TargetWindow.WarpClicked -= OnWarpClicked;
Gui.ReturnToRoundPressed -= ReturnToRound;

Gui.Hide();
}
Expand All @@ -142,6 +144,11 @@ private void ReturnToBody()
_system?.ReturnToBody();
}

private void ReturnToRound()
{
_system?.ReturnToRound();
}

private void RequestWarps()
{
_system?.RequestWarps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
<Button Name="ReturnToBodyButton" Text="{Loc ghost-gui-return-to-body-button}" />
<Button Name="GhostWarpButton" Text="{Loc ghost-gui-ghost-warp-button}" />
<Button Name="GhostRolesButton" />
<Button Name="ReturnToRound" Text="{Loc ghost-gui-return-to-round-button}" />
</BoxContainer>
</widgets:GhostGui>
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public sealed partial class GhostGui : UIWidget
public event Action? RequestWarpsPressed;
public event Action? ReturnToBodyPressed;
public event Action? GhostRolesPressed;
public event Action? ReturnToRoundPressed;

public GhostGui()
{
Expand All @@ -26,6 +27,7 @@ public GhostGui()
GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
ReturnToRound.OnPressed += _ => ReturnToRoundPressed?.Invoke();
}

public void Hide()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions.Events;
using Content.Shared.Mobs.Components;
using System.Linq;
using System.Numerics;
using Content.Shared.Database;
using Robust.Shared.Collections;

namespace Content.Server.Abilities.Psionics;

public sealed partial class AnomalyPowerSystem
{
/// <summary>
/// This function handles emulating the effects of a "Bluespace Anomaly", using the caster as the "Anomaly",
/// while substituting their Psionic casting stats for "Severity and Stability".
/// Essentially, scramble the location of entities near the caster(possibly to include the caster).
/// </summary>
private void DoBluespaceAnomalyEffects(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args, bool overcharged = false)
{
if (args.Bluespace is null)
return;

if (overcharged)
BluespaceSupercrit(uid, component, args);
else BluespacePulse(uid, component, args);
}

private void BluespaceSupercrit(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
var xform = Transform(uid);
var mapPos = _xform.GetWorldPosition(xform);
var radius = args.Bluespace!.Value.SupercriticalTeleportRadius * component.CurrentAmplification;
var gridBounds = new Box2(mapPos - new Vector2(radius, radius), mapPos + new Vector2(radius, radius));
var mobs = new HashSet<Entity<MobStateComponent>>();
_lookup.GetEntitiesInRange(xform.Coordinates, args.Bluespace!.Value.MaxShuffleRadius, mobs);
foreach (var comp in mobs)
{
if (args.Bluespace!.Value.SupercritTeleportsCaster && comp.Owner == uid)
continue;

var ent = comp.Owner;
var randomX = _random.NextFloat(gridBounds.Left, gridBounds.Right);
var randomY = _random.NextFloat(gridBounds.Bottom, gridBounds.Top);

var pos = new Vector2(randomX, randomY);

_adminLogger.Add(LogType.Teleport, $"{ToPrettyString(ent)} has been teleported to {pos} by the supercritical {ToPrettyString(uid)} at {mapPos}");

_xform.SetWorldPosition(ent, pos);
_audio.PlayPvs(args.Bluespace!.Value.TeleportSound, ent);
}
}

private void BluespacePulse(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
var xformQuery = GetEntityQuery<TransformComponent>();
var xform = xformQuery.GetComponent(uid);
var range = args.Bluespace!.Value.MaxShuffleRadius * component.CurrentAmplification;
var mobs = new HashSet<Entity<MobStateComponent>>();
_lookup.GetEntitiesInRange(xform.Coordinates, range, mobs);
var allEnts = new ValueList<EntityUid>(mobs.Select(m => m.Owner)) { uid };
var coords = new ValueList<Vector2>();
foreach (var ent in allEnts)
{
if (args.Bluespace!.Value.PulseTeleportsCaster && ent == uid
|| !xformQuery.TryGetComponent(ent, out var allXform))
continue;

coords.Add(_xform.GetWorldPosition(allXform));
}

_random.Shuffle(coords);
for (var i = 0; i < allEnts.Count; i++)
{
_adminLogger.Add(LogType.Teleport, $"{ToPrettyString(allEnts[i])} has been shuffled to {coords[i]} by the {ToPrettyString(uid)} at {xform.Coordinates}");
_xform.SetWorldPosition(allEnts[i], coords[i]);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions.Events;

namespace Content.Server.Abilities.Psionics;

public sealed partial class AnomalyPowerSystem
{
/// <summary>
/// This function handles emulating the effects of a "Electrical Anomaly", using the caster as the "Anomaly",
/// while substituting their Psionic casting stats for "Severity and Stability".
/// This fires lightning bolts at random entities near the caster.
/// </summary>
private void DoElectricityAnomalyEffects(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args, bool overcharged = false)
{
if (args.Electricity is null)
return;

if (overcharged)
ElectricitySupercrit(uid, component, args);
else ElectricityPulse(uid, component, args);
}

private void ElectricitySupercrit(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
var range = args.Electricity!.Value.MaxElectrocuteRange * component.CurrentAmplification;

_emp.EmpPulse(_xform.GetMapCoordinates(uid), range, args.Electricity!.Value.EmpEnergyConsumption, args.Electricity!.Value.EmpDisabledDuration);
_lightning.ShootRandomLightnings(uid, range, args.Electricity!.Value.MaxBoltCount * (int) component.CurrentAmplification, arcDepth: (int) component.CurrentDampening);
}

private void ElectricityPulse(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
var range = args.Electricity!.Value.MaxElectrocuteRange * component.CurrentAmplification;

int boltCount = (int) MathF.Floor(MathHelper.Lerp(args.Electricity!.Value.MinBoltCount, args.Electricity!.Value.MaxBoltCount, component.CurrentAmplification));

_lightning.ShootRandomLightnings(uid, range, boltCount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions.Events;
using Content.Shared.Random.Helpers;
using Robust.Shared.Random;
using Content.Shared.Anomaly.Effects.Components;
using Robust.Shared.Map.Components;

namespace Content.Server.Abilities.Psionics;

public sealed partial class AnomalyPowerSystem
{
private const string NoGrid = "entity-anomaly-no-grid";

/// <summary>
/// This function handles emulating the effects of an "Entity Anomaly", using the caster as the "Anomaly",
/// while substituting their Psionic casting stats for "Severity and Stability".
/// Essentially, spawn entities on random tiles in a radius around the caster.
/// </summary>
private void DoEntityAnomalyEffects(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args, bool overcharged = false)
{
if (args.EntitySpawnEntries is null)
return;

if (Transform(uid).GridUid is null)
{
_popup.PopupEntity(Loc.GetString(NoGrid), uid, uid);
return;
}

if (overcharged)
EntitySupercrit(uid, component, args);
else EntityPulse(uid, component, args);
}

private void EntitySupercrit(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
foreach (var entry in args.EntitySpawnEntries!)
{
if (!entry.Settings.SpawnOnSuperCritical)
continue;

SpawnEntities(uid, component, entry);
}
}

private void EntityPulse(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
if (args.EntitySpawnEntries is null)
return;

foreach (var entry in args.EntitySpawnEntries!)
{
if (!entry.Settings.SpawnOnPulse)
continue;

SpawnEntities(uid, component, entry);
}
}

private void SpawnEntities(EntityUid uid, PsionicComponent component, EntitySpawnSettingsEntry entry)
{
if (!TryComp<MapGridComponent>(Transform(uid).GridUid, out var grid))
return;

var tiles = _anomalySystem.GetSpawningPoints(uid,
component.CurrentDampening,
component.CurrentAmplification,
entry.Settings,
_glimmerSystem.Glimmer / 1000,
component.CurrentAmplification,
component.CurrentAmplification);

if (tiles is null)
return;

foreach (var tileref in tiles)
Spawn(_random.Pick(entry.Spawns), _mapSystem.ToCenterCoordinates(tileref, grid));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions.Events;

namespace Content.Server.Abilities.Psionics;

public sealed partial class AnomalyPowerSystem
{
/// <summary>
/// This function handles emulating the effects of a "Explosion Anomaly", using the caster as the "Anomaly",
/// while substituting their Psionic casting stats for "Severity and Stability".
/// Generates an explosion centered on the caster.
/// </summary>
private void DoExplosionAnomalyEffects(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args, bool overcharged = false)
{
if (args.Explosion is null)
return;

if (overcharged)
ExplosionSupercrit(uid, component, args);
else ExplosionPulse(uid, component, args);
}

private void ExplosionSupercrit(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
if (args.Explosion!.Value.SupercritExplosionPrototype is null)
return;

var explosion = args.Explosion!.Value;
_boom.QueueExplosion(
uid,
explosion.SupercritExplosionPrototype,
explosion.SupercritTotalIntensity * component.CurrentAmplification,
explosion.SupercritDropoff / component.CurrentDampening,
explosion.SupercritMaxTileIntensity * component.CurrentDampening
);
}

private void ExplosionPulse(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
if (args.Explosion!.Value.ExplosionPrototype is null)
return;

var explosion = args.Explosion!.Value;
_boom.QueueExplosion(
uid,
explosion.ExplosionPrototype,
explosion.TotalIntensity * component.CurrentAmplification,
explosion.Dropoff / component.CurrentDampening,
explosion.MaxTileIntensity * component.CurrentDampening
);
}
}
Loading

0 comments on commit 5596bd2

Please sign in to comment.