Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Jan 22, 2025
2 parents bc7f191 + f85b746 commit f61ca58
Show file tree
Hide file tree
Showing 71 changed files with 707 additions and 431 deletions.
28 changes: 28 additions & 0 deletions Content.Client/NPC/Systems/NpcFactionSpriteStateSetterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

using Content.Shared.NPC.Components;
using Content.Shared.NPC.Events;
using Robust.Client.GameObjects;
using Robust.Shared.Reflection;

namespace Content.Client.NPC.Systems;
public sealed partial class NpcFactionSpriteStateSetterSystem : EntitySystem
{
[Dependency] private readonly SpriteSystem _spriteSystem = default!;
[Dependency] private readonly EntityManager _entityManager = default!;

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

SubscribeLocalEvent<NpcFactionMemberComponent, NpcFactionAddedEvent>(OnFactionAdded);
}

private void OnFactionAdded(Entity<NpcFactionMemberComponent > entity, ref NpcFactionAddedEvent args)
{
if (!_entityManager.HasComponent(entity, typeof(NpcFactionSpriteStateSetterComponent)))
return;

SpriteComponent spriteComponent = _entityManager.GetComponent<SpriteComponent>(entity);
spriteComponent.LayerSetState(0, new Robust.Client.Graphics.RSI.StateId(args.FactionID));
}
}
7 changes: 0 additions & 7 deletions Content.Client/Shadowkin/ShadowkinSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,6 @@ public override void Update(float frameTime)
// intensity = clamp intensity min, max

var tintIntensity = 0.65f;
if (TryComp<PsionicComponent>(uid, out var magic))
{
var min = 0.45f;
var max = 0.75f;
tintIntensity = Math.Clamp(min + (magic.Mana / magic.MaxMana) * 0.333f, min, max);
}

UpdateShader(new Vector3(humanoid.EyeColor.R, humanoid.EyeColor.G, humanoid.EyeColor.B), tintIntensity);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void OnPowerUsed(DarkSwapActionEvent args)
args.Handled = true;
}
}
else if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap", args.ManaCost))
else if (_psionics.OnAttemptPowerUse(args.Performer, "DarkSwap"))
{
var newethereal = EnsureComp<EtherealComponent>(args.Performer);
newethereal.Darken = true;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Abilities/Psionics/AnomalyPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Initialize()

private void OnPowerUsed(EntityUid uid, PsionicComponent component, AnomalyPowerActionEvent args)
{
if (!_psionics.OnAttemptPowerUse(args.Performer, args.Settings.PowerName, args.Settings.ManaCost, args.Settings.CheckInsulation))
if (!_psionics.OnAttemptPowerUse(args.Performer, args.Settings.PowerName, args.Settings.CheckInsulation))
return;

var overcharged = args.Settings.DoSupercritical ? _glimmerSystem.GlimmerOutput * component.CurrentAmplification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,34 +432,6 @@ public override void OnAddPsionic(
}
}

[UsedImplicitly]
public sealed partial class PsionicModifyMana : PsionicPowerFunction
{
[DataField]
public float MaxManaModifier;

[DataField]
public float ManaGainModifier;

[DataField]
public float ManaGainMultiplierModifier;

public override void OnAddPsionic(
EntityUid uid,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager,
ISharedPlayerManager playerManager,
ILocalizationManager loc,
PsionicComponent psionicComponent,
PsionicPowerPrototype proto)
{
psionicComponent.MaxMana += MaxManaModifier;
psionicComponent.ManaGain += ManaGainModifier;
psionicComponent.ManaGainMultiplier += ManaGainMultiplierModifier;
}
}

[UsedImplicitly]
public sealed partial class PsionicModifyGlimmer : PsionicPowerFunction
{
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Abilities/Psionics/PsionicFamiliarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Initialize()
private void OnSummon(EntityUid uid, PsionicComponent psionicComponent, SummonPsionicFamiliarActionEvent args)
{
if (psionicComponent.Familiars.Count >= psionicComponent.FamiliarLimit
|| !_psionics.OnAttemptPowerUse(args.Performer, args.PowerName, args.ManaCost, args.CheckInsulation)
|| !_psionics.OnAttemptPowerUse(args.Performer, args.PowerName, args.CheckInsulation)
|| args.Handled || args.FamiliarProto is null)
return;

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Administration/Commands/SetOutfitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static bool SetOutfit(EntityUid target, string gear, IEntityManager entit
return true; //Fuck it, nuclear option for not Cluwning an IPC because that causes a crash that SOMEHOW ignores null checks.
if (entityManager.HasComponent<EncryptionKeyHolderComponent>(target))
{
var encryption = new InternalEncryptionKeySpawner();
var encryption = entityManager.System<InternalEncryptionKeySpawner>();
encryption.TryInsertEncryptionKey(target, startingGear, entityManager);
}
return true;
Expand Down
38 changes: 0 additions & 38 deletions Content.Server/Alert/Click/CheckMana.cs

This file was deleted.

17 changes: 9 additions & 8 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public bool TryMakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? se
/// </summary>
public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, bool ignoreSpawner = false)
{
var antagEnt = (EntityUid?) null;
EntityUid? antagEnt = null;
var isSpawner = false;

if (session != null)
Expand All @@ -266,17 +266,16 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi
{
var getEntEv = new AntagSelectEntityEvent(session, ent);
RaiseLocalEvent(ent, ref getEntEv, true);

if (!getEntEv.Handled)
{
throw new InvalidOperationException($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player.");
}

antagEnt = getEntEv.Entity;
}

if (antagEnt is not { } player)
{
Log.Error($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player.");
if (session != null)
ent.Comp.SelectedSessions.Remove(session);
return;
}

var getPosEv = new AntagSelectLocationEvent(session, ent);
RaiseLocalEvent(ent, ref getPosEv, true);
Expand All @@ -291,7 +290,9 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi
{
if (!TryComp<GhostRoleAntagSpawnerComponent>(player, out var spawnerComp))
{
Log.Error("Antag spawner with GhostRoleAntagSpawnerComponent.");
Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent.");
if (session != null)
ent.Comp.SelectedSessions.Remove(session);
return;
}

Expand Down
1 change: 1 addition & 0 deletions Content.Server/Clothing/Systems/LoadoutSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public override void Initialize()
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent ev)
{
if (ev.JobId == null || Deleted(ev.Mob) || !Exists(ev.Mob)
|| !HasComp<MetaDataComponent>(ev.Mob) // TODO: FIND THE STUPID RACE CONDITION THAT IS MAKING ME CHECK FOR THIS.
|| !_protoMan.TryIndex<JobPrototype>(ev.JobId, out _)
|| !_configurationManager.GetCVar(CCVars.GameLoadoutsEnabled))
return;
Expand Down
17 changes: 16 additions & 1 deletion Content.Server/Humanoid/Systems/RandomHumanoidSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Humanoid.Components;
using Content.Server.RandomMetadata;
using Content.Shared.Humanoid.Prototypes;
Expand All @@ -19,6 +20,8 @@ public sealed class RandomHumanoidSystem : EntitySystem

[Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!;

private HashSet<string> _notRoundStartSpecies = new();

/// <inheritdoc/>
public override void Initialize()
{
Expand All @@ -31,14 +34,26 @@ private void OnMapInit(EntityUid uid, RandomHumanoidSpawnerComponent component,
QueueDel(uid);
if (component.SettingsPrototypeId != null)
SpawnRandomHumanoid(component.SettingsPrototypeId, Transform(uid).Coordinates, MetaData(uid).EntityName);

var speciesList = _prototypeManager.EnumeratePrototypes<SpeciesPrototype>()
.Where(x => !x.RoundStart)
.Select(x => x.Prototype.Id)
.ToHashSet();

_notRoundStartSpecies = speciesList;
}

public EntityUid SpawnRandomHumanoid(string prototypeId, EntityCoordinates coordinates, string name)
{
if (!_prototypeManager.TryIndex<RandomHumanoidSettingsPrototype>(prototypeId, out var prototype))
throw new ArgumentException("Could not get random humanoid settings");

var profile = HumanoidCharacterProfile.Random(prototype.SpeciesBlacklist);
var blacklist = prototype.SpeciesBlacklist;

if (!prototype.SpeciesBlacklist.Any())
blacklist = _notRoundStartSpecies;

var profile = HumanoidCharacterProfile.Random(blacklist);
var speciesProto = _prototypeManager.Index<SpeciesPrototype>(profile.Species);
var humanoid = EntityManager.CreateEntityUninitialized(speciesProto.Prototype, coordinates);

Expand Down
5 changes: 5 additions & 0 deletions Content.Server/NPC/Systems/NPCCombatSystem.Melee.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using Content.Server.NPC.Components;
using Content.Server.NPC.HTN;
using Content.Shared.CombatMode;
using Content.Shared.NPC;
using Robust.Shared.Map;
Expand All @@ -10,6 +11,7 @@ namespace Content.Server.NPC.Systems;

public sealed partial class NPCCombatSystem
{
[Dependency] private readonly IRobustRandom _rng = default!;
private const float TargetMeleeLostRange = 14f;

private void InitializeMelee()
Expand Down Expand Up @@ -114,5 +116,8 @@ private void Attack(EntityUid uid, NPCMeleeCombatComponent component, TimeSpan c
{
_melee.AttemptLightAttack(uid, weaponUid, weapon, component.Target);
}

if (Comp<HTNComponent>(uid).Blackboard.TryGetValue<float>("AttackDelayDeviation", out var dev, EntityManager))
weapon.NextAttack += TimeSpan.FromSeconds(_rng.NextFloat(-dev, dev));
}
}
3 changes: 2 additions & 1 deletion Content.Server/Paint/PaintSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ public void Paint(Entity<PaintComponent> entity, EntityUid target, EntityUid use
public void Paint(EntityWhitelist? whitelist, EntityWhitelist? blacklist, EntityUid target, Color color)
{
if (_whitelist.IsWhitelistFail(whitelist, target)
|| _whitelist.IsBlacklistPass(blacklist, target))
|| _whitelist.IsBlacklistPass(blacklist, target)
|| !HasComp<MetaDataComponent>(target)) // TODO: FIND THE STUPID RACE CONDITION THAT IS MAKING ME CHECK FOR THIS.
return;

EnsureComp<PaintedComponent>(target, out var paint);
Expand Down
16 changes: 0 additions & 16 deletions Content.Server/Psionics/PsionicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public override void Initialize()
SubscribeLocalEvent<PsionicComponent, MobStateChangedEvent>(OnMobstateChanged);
SubscribeLocalEvent<PsionicComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<PsionicComponent, AttackAttemptEvent>(OnAttackAttempt);
SubscribeLocalEvent<PsionicComponent, OnManaUpdateEvent>(OnManaUpdate);

SubscribeLocalEvent<PsionicComponent, ComponentStartup>(OnInit);
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove);
Expand Down Expand Up @@ -180,8 +179,6 @@ private void CheckAntiPsionic(EntityUid entity, AntiPsionicWeaponComponent compo

private void OnInit(EntityUid uid, PsionicComponent component, ComponentStartup args)
{
UpdateManaAlert(uid, component);

component.AmplificationSources.Add(BaselineAmplification, _random.NextFloat(component.BaselineAmplification.Item1, component.BaselineAmplification.Item2));
component.DampeningSources.Add(BaselineDampening, _random.NextFloat(component.BaselineDampening.Item1, component.BaselineDampening.Item2));

Expand All @@ -195,25 +192,12 @@ private void OnInit(EntityUid uid, PsionicComponent component, ComponentStartup

private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove args)
{
_alerts.ClearAlert(uid, component.ManaAlert);

if (!HasComp<NpcFactionMemberComponent>(uid))
return;

_npcFactonSystem.RemoveFaction(uid, "PsionicInterloper");
}

public void UpdateManaAlert(EntityUid uid, PsionicComponent component)
{
var severity = (short) ContentHelpers.RoundToLevels(component.Mana, component.MaxMana, 8);
_alerts.ShowAlert(uid, component.ManaAlert, severity);
}

private void OnManaUpdate(EntityUid uid, PsionicComponent component, ref OnManaUpdateEvent args)
{
UpdateManaAlert(uid, component);
}

private void OnStamHit(EntityUid uid, AntiPsionicWeaponComponent component, TakeStaminaDamageEvent args)
{
if (!HasComp<PsionicComponent>(args.Target))
Expand Down
3 changes: 0 additions & 3 deletions Content.Server/Shadowkin/EtherealStunItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ private void OnUseInHand(EntityUid uid, EtherealStunItemComponent component, Use

if (TryComp<StaminaComponent>(ent, out var stamina))
_stamina.TakeStaminaDamage(ent, stamina.CritThreshold, stamina, ent);

if (TryComp<PsionicComponent>(ent, out var magic))
magic.Mana = 0;
}

if (!component.DeleteOnUse)
Expand Down
Loading

0 comments on commit f61ca58

Please sign in to comment.