Skip to content

Commit

Permalink
Merge branch 'DeltaV-Station:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreammyrr authored Sep 16, 2024
2 parents e8abe7d + 0c5d0ca commit 4e6a60c
Show file tree
Hide file tree
Showing 72 changed files with 37,573 additions and 22,337 deletions.
42 changes: 35 additions & 7 deletions Content.Server/DeltaV/StationEvents/Events/FugitiveRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@
using Content.Server.StationEvents.Components;
using Content.Shared.GameTicking.Components;
using Content.Shared.Ghost;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Inventory;
using Content.Shared.Paper;
using Content.Shared.Popups;
using Content.Shared.Random.Helpers;
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;

namespace Content.Server.StationEvents.Events;

public sealed class FugitiveRule : StationEventSystem<FugitiveRuleComponent>
{
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly PaperSystem _paper = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -47,9 +53,7 @@ protected override void ActiveTick(EntityUid uid, FugitiveRuleComponent comp, Ga

foreach (var xform in consoles)
{
var report = Spawn(comp.ReportPaper, xform.Coordinates);
var paper = Comp<PaperComponent>(report);
_paper.SetContent((report, paper), comp.Report);
SpawnReport(comp, xform);
}

// prevent any possible funnies
Expand All @@ -60,18 +64,42 @@ protected override void ActiveTick(EntityUid uid, FugitiveRuleComponent comp, Ga

private void OnEntitySelected(Entity<FugitiveRuleComponent> ent, ref AfterAntagEntitySelectedEvent args)
{
if (ent.Comp.NextAnnounce != null)
var (uid, comp) = ent;
if (comp.NextAnnounce != null)
{
Log.Error("Fugitive rule spawning multiple fugitives isn't supported, sorry.");
return;
}

var fugi = args.EntityUid;
ent.Comp.Report = GenerateReport(fugi, ent.Comp).ToMarkup();
ent.Comp.Station = StationSystem.GetOwningStation(fugi);
ent.Comp.NextAnnounce = Timing.CurTime + ent.Comp.AnnounceDelay;
comp.Report = GenerateReport(fugi, comp).ToMarkup();
comp.Station = StationSystem.GetOwningStation(fugi);
comp.NextAnnounce = Timing.CurTime + comp.AnnounceDelay;

_popup.PopupEntity(Loc.GetString("fugitive-spawn"), fugi, fugi);

// give the fugi a report so they know what their charges are
var report = SpawnReport(comp, Transform(fugi));

// try to insert it into their bag
if (_inventory.TryGetSlotEntity(fugi, "back", out var backpack))
{
_storage.Insert(backpack.Value, report, out _, playSound: false);
}
else
{
// no bag somehow, at least pick it up
_hands.TryPickup(fugi, report);
}
}

private Entity<PaperComponent> SpawnReport(FugitiveRuleComponent rule, TransformComponent xform)
{
var report = Spawn(rule.ReportPaper, xform.Coordinates);
var paper = Comp<PaperComponent>(report);
var ent = (report, paper);
_paper.SetContent(ent, rule.Report);
return ent;
}

private FormattedMessage GenerateReport(EntityUid uid, FugitiveRuleComponent rule)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Systems;
using Content.Shared.Destructible.Thresholds;

namespace Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Components;

/// <summary>
/// Raises or lowers glimmer when this artifact is triggered.
/// </summary>
[RegisterComponent, Access(typeof(GlimmerArtifactSystem))]
public sealed partial class GlimmerArtifactComponent : Component
{
/// <summary>
/// If glimmer is not in this range it won't do anything.
/// Prevents the trigger being too extreme or too beneficial.
/// </summary>
[DataField(required: true)]
public MinMax Range;

/// <summary>
/// Number to add to glimmer when triggering.
/// </summary>
[DataField(required: true)]
public int Change;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Systems;

namespace Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Components;

/// <summary>
/// Makes people in a radius around it psionic when triggered.
/// </summary>
[RegisterComponent, Access(typeof(PsionicProducingArtifactSystem))]
public sealed partial class PsionicProducingArtifactComponent : Component
{
/// <summary>
/// Range to look for potential psionics in.
/// </summary>
[DataField(required: true)]
public float Range;

/// <summary>
/// Number of times this node can trigger before it switches to doing nothing.
/// </summary>
[DataField]
public int Limit = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Psionics.Glimmer;

namespace Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Systems;

public sealed class GlimmerArtifactSystem : EntitySystem
{
[Dependency] private readonly GlimmerSystem _glimmer = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<GlimmerArtifactComponent, ArtifactActivatedEvent>(OnActivated);
}

private void OnActivated(Entity<GlimmerArtifactComponent> ent, ref ArtifactActivatedEvent args)
{
var range = ent.Comp.Range;
var current = _glimmer.Glimmer;
if (current < range.Min || current > range.Max)
return;

_glimmer.Glimmer += ent.Comp.Change;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Server.Psionics;

public sealed class PsionicProducingArtifactSystem : EntitySystem
{
[Dependency] private readonly ArtifactSystem _artifact = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly PsionicsSystem _psionics = default!;

public const string NodeDataPsionicAmount = "nodeDataPsionicAmount";

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<PsionicProducingArtifactComponent, ArtifactActivatedEvent>(OnActivated);
}

private void OnActivated(Entity<PsionicProducingArtifactComponent> ent, ref ArtifactActivatedEvent args)
{
var (uid, comp) = ent;
if (!_artifact.TryGetNodeData(uid, NodeDataPsionicAmount, out int amount))
amount = 0;

if (amount >= comp.Limit)
return;

var coords = Transform(uid).Coordinates;
foreach (var target in _lookup.GetEntitiesInRange<PotentialPsionicComponent>(coords, comp.Range))
{
_psionics.TryMakePsionic(target);
}

_artifact.SetNodeData(uid, NodeDataPsionicAmount, amount + 1);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Triggers.Components;

/// <summary>
/// Triggers if a psionic power is used nearby.
/// Requires <c>MetapsionicPowerComponent</c> to be added too.
/// </summary>
[RegisterComponent]
public sealed partial class ArtifactMetapsionicTriggerComponent : Component;
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Content.Server.DeltaV.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
using Content.Shared.Abilities.Psionics;

namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;

public sealed class ArtifactMetapsionicTriggerSystem : EntitySystem
{
[Dependency] private readonly ArtifactSystem _artifact = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ArtifactMetapsionicTriggerComponent, PsionicPowerDetectedEvent>(OnPowerDetected);
}

private void OnPowerDetected(Entity<ArtifactMetapsionicTriggerComponent> ent, ref PsionicPowerDetectedEvent args)
{
_artifact.TryActivateArtifact(ent);
}
}
24 changes: 17 additions & 7 deletions Content.Server/Nyanotrasen/Psionics/PsionicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,31 @@ private void OnStamHit(EntityUid uid, AntiPsionicWeaponComponent component, Stam
args.FlatModifier += component.PsychicStaminaDamage;
}

public void RollPsionics(EntityUid uid, PotentialPsionicComponent component, bool applyGlimmer = true, float multiplier = 1f)
/// <summary>
/// Makes the entity psionic if it is possible.
/// Ignores rolling and rerolling prevention.
/// </summary>
public bool TryMakePsionic(Entity<PotentialPsionicComponent> ent)
{
if (HasComp<PsionicComponent>(uid))
return;
if (HasComp<PsionicComponent>(ent))
return false;

if (!_cfg.GetCVar(CCVars.PsionicRollsEnabled))
return;
return false;

var warn = CompOrNull<PsionicBonusChanceComponent>(ent)?.Warn ?? true;
_psionicAbilitiesSystem.AddPsionics(ent, warn);
return true;
}

public void RollPsionics(EntityUid uid, PotentialPsionicComponent component, bool applyGlimmer = true, float multiplier = 1f)
{

var chance = component.Chance;
var warn = true;
if (TryComp<PsionicBonusChanceComponent>(uid, out var bonus))
{
chance *= bonus.Multiplier;
chance += bonus.FlatBonus;
warn = bonus.Warn;
}

if (applyGlimmer)
Expand All @@ -153,7 +163,7 @@ public void RollPsionics(EntityUid uid, PotentialPsionicComponent component, boo
chance = Math.Clamp(chance, 0, 1);

if (_random.Prob(chance))
_psionicAbilitiesSystem.AddPsionics(uid, warn);
TryMakePsionic((uid, component));
}

public void RerollPsionics(EntityUid uid, PotentialPsionicComponent? psionic = null, float bonusMuliplier = 1f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void OnShutdown(EntityUid uid, MassSleepPowerComponent component, Compon

private void OnPowerUsed(EntityUid uid, MassSleepPowerComponent component, MassSleepPowerActionEvent args)
{
var duration = 30; // Duration of the mass sleep
var duration = 5; // Duration of the mass sleep
foreach (var entity in _lookup.GetEntitiesInRange(args.Target, component.Radius))
{
if (HasComp<MobStateComponent>(entity) && entity != uid && !HasComp<PsionicInsulationComponent>(entity))
Expand Down
Loading

0 comments on commit 4e6a60c

Please sign in to comment.