Merge remote-tracking branch 'upstream/master' into ups

This commit is contained in:
Jabak
2024-06-21 21:53:12 +03:00
103 changed files with 2092 additions and 340 deletions

View File

@@ -29,6 +29,7 @@ using Content.Shared._White.Mood;
using Content.Shared.Cloning;
using Content.Shared.Mind;
using Content.Shared.NPC.Systems;
using Robust.Server.Containers;
using Robust.Server.Player;
namespace Content.Server._White.Cult.GameRule;
@@ -50,6 +51,7 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly GulagSystem _gulag = default!;
[Dependency] private readonly BloodSpearSystem _bloodSpear = default!;
[Dependency] private readonly ContainerSystem _container = default!;
private const int PlayerPerCultist = 10;
private int _minStartingCultists;
@@ -160,22 +162,18 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
private void OnCultistComponentInit(EntityUid uid, CultistComponent component, ComponentInit args)
{
RaiseLocalEvent(uid, new MoodEffectEvent("CultFocused"));
var query = QueryActiveRules();
while (query.MoveNext(out _, out var cult, out _))
{
if (!TryComp<MindContainerComponent>(uid, out var mindComponent))
return;
if (!mindComponent.HasMind)
return;
cult.CurrentCultists.Add(component);
var name = Name(uid);
if (TryComp<ActorComponent>(uid, out var actor) && !cult.CultistsCache.ContainsKey(name))
if (TryComp<ActorComponent>(uid, out var actor))
{
cult.CultistsCache.Add(name, actor.PlayerSession.Name);
cult.CultistsCache.TryAdd(name, actor.PlayerSession.Name);
}
UpdateCultistsAppearance(cult);
@@ -203,17 +201,23 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
while (query.MoveNext(out _, out var cult, out _))
{
cult.CurrentCultists.Remove(component);
_bloodSpear.DetachSpearFromUser((uid, component));
foreach (var empower in component.SelectedEmpowers)
{
_actions.RemoveAction(uid, GetEntity(empower));
}
RemoveCultistAppearance(uid);
CheckRoundShouldEnd();
}
if (!TerminatingOrDeleted(uid))
{
RemoveAllCultistItems(uid);
RemoveCultistAppearance(uid);
RaiseLocalEvent(uid, new MoodRemoveEffectEvent("CultFocused"));
}
_bloodSpear.DetachSpearFromUser((uid, component));
foreach (var empower in component.SelectedEmpowers)
{
_actions.RemoveAction(uid, GetEntity(empower));
}
CheckRoundShouldEnd();
}
private void OnCultistsStateChanged(EntityUid uid, CultistComponent component, MobStateChangedEvent ev)
@@ -422,8 +426,6 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
_factionSystem.RemoveFaction(cultist, "NanoTrasen", false);
_factionSystem.AddFaction(cultist, "Cultist");
RaiseLocalEvent(cultist, new MoodEffectEvent("CultFocused"));
if (_inventorySystem.TryGetSlotEntity(cultist, "back", out var backPack))
{
foreach (var itemPrototype in rule.StartingItems)
@@ -442,6 +444,20 @@ public sealed class CultRuleSystem : GameRuleSystem<CultRuleComponent>
return true;
}
private void RemoveAllCultistItems(EntityUid uid)
{
if (!_inventorySystem.TryGetContainerSlotEnumerator(uid, out var enumerator))
return;
while (enumerator.MoveNext(out var container))
{
if (container.ContainedEntity != null && HasComp<CultItemComponent>(container.ContainedEntity.Value))
{
_container.Remove(container.ContainedEntity.Value, container, true, true);
}
}
}
public void TransferRole(EntityUid transferFrom, EntityUid transferTo)
{
if (HasComp<PentagramComponent>(transferFrom))

View File

@@ -1,18 +1,11 @@
using System.Threading;
using Content.Server._White.Cult.GameRule;
using Content.Server.Objectives.Components;
using Content.Server.Popups;
using Content.Server.Roles;
using Content.Server.Stunnable;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.IdentityManagement;
using Content.Shared.Inventory;
using Content.Shared._White.Cult.Components;
using Content.Shared._White.Mood;
using Content.Shared.Jittering;
using Content.Shared.Mind;
using JetBrains.Annotations;
using Robust.Server.Containers;
using Robust.Shared.Prototypes;
using CultistComponent = Content.Shared._White.Cult.Components.CultistComponent;
using Timer = Robust.Shared.Timing.Timer;
@@ -60,26 +53,10 @@ public sealed partial class DeconvertCultist : ReagentEffect
cultist.HolyConvertToken = null;
var inventory = entityManager.System<InventorySystem>();
var containerSystem = entityManager.System<ContainerSystem>();
if (!inventory.TryGetContainerSlotEnumerator(uid, out var enumerator))
return;
while (enumerator.MoveNext(out var container))
{
if (container.ContainedEntity != null &&
entityManager.HasComponent<CultItemComponent>(container.ContainedEntity.Value))
{
containerSystem.Remove(container.ContainedEntity.Value, container, true, true);
}
}
entityManager.RemoveComponent<CultistComponent>(uid);
entityManager.RemoveComponent<PentagramComponent>(uid);
var cultRuleSystem = entityManager.System<CultRuleSystem>();
cultRuleSystem.RemoveObjectiveAndRole(uid);
entityManager.EventBus.RaiseLocalEvent(uid, new MoodRemoveEffectEvent("CultFocused"));
}
}

View File

@@ -10,4 +10,7 @@ public sealed partial class CultRobeModifierComponent : Component
public string DamageModifierSetId = "CultRobe";
public string? StoredDamageSetId { get; set; }
[ViewVariables]
public bool Active;
}

View File

@@ -29,18 +29,22 @@ public sealed class CultRobeModifierSystem : EntitySystem
if (args.Slot != "outerClothing")
return;
component.Active = true;
ModifySpeed(args.Equipee, component, true);
ModifyDamage(args.Equipee, component, true);
}
private void OnUnequip(EntityUid uid, CultRobeModifierComponent component, GotUnequippedEvent args)
{
if (!HasComp<CultistComponent>(args.Equipee))
if (!component.Active)
return;
if (args.Slot != "outerClothing")
return;
component.Active = false;
ModifySpeed(args.Equipee, component, false);
ModifyDamage(args.Equipee, component, false);
}

View File

@@ -0,0 +1,24 @@
using Content.Server.Power.Components;
using Content.Shared._White.Lighting;
using Content.Shared._White.Lighting.PointLight.Airlock;
using Content.Shared.Doors.Components;
namespace Content.Server._White.Lighting.Pointlight.Airlock;
public sealed class PointLightAirlockSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PointLightAirlockComponent, PowerChangedEvent>(OnPowerChanged);
}
private void OnPowerChanged(EntityUid uid, PointLightAirlockComponent component, PowerChangedEvent args)
{
if (!TryComp<DoorComponent>(uid, out var door))
return;
RaiseLocalEvent(uid, new DoorlightsChangedEvent(args.Powered ? door.State : null, args.Powered), true);
}
}

View File

@@ -1,4 +1,4 @@
namespace Content.Server._White.Lighting;
namespace Content.Server._White.Lighting.Pointlight.Battery;
[RegisterComponent]
public sealed partial class PointLightBatteryComponent : Component

View File

@@ -1,8 +1,10 @@
using Content.Shared.Lightning;
using Content.Server.Power.Components;
using Content.Shared.Lightning;
using Content.Shared.PowerCell;
using Content.Shared.PowerCell.Components;
using Content.Shared.Weapons.Ranged.Components;
namespace Content.Server._White.Lighting;
namespace Content.Server._White.Lighting.Pointlight.Battery;
public sealed class PointLightBatterySystem : SharedLightningSystem
{
@@ -12,6 +14,7 @@ public sealed class PointLightBatterySystem : SharedLightningSystem
{
base.Initialize();
SubscribeLocalEvent<PointLightBatteryComponent, PowerCellChangedEvent>(OnBatteryLoose);
SubscribeLocalEvent<PointLightBatteryComponent, ChargeChangedEvent>(OnBatteryChargeChanged);
}
private void OnBatteryLoose(EntityUid uid, PointLightBatteryComponent component, PowerCellChangedEvent args)
@@ -27,4 +30,18 @@ public sealed class PointLightBatterySystem : SharedLightningSystem
RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged && !args.Ejected), true);
}
private void OnBatteryChargeChanged(EntityUid uid, PointLightBatteryComponent component, ChargeChangedEvent args)
{
if (!component.RequireBattery)
return;
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
return;
var isBatteryCharged = TryComp<ProjectileBatteryAmmoProviderComponent>(uid, out var projectileBattery) && projectileBattery.Shots > 0;
_pointLightSystem.SetEnabled(uid, isBatteryCharged, pointLightComponent);
RaiseLocalEvent(uid, new PointLightToggleEvent(isBatteryCharged), true);
}
}

View File

@@ -0,0 +1,63 @@
using Content.Server.Power.Components;
using Content.Shared.PowerCell;
using Content.Shared.Rounding;
namespace Content.Server._White.Lighting.PointLight.RealBattery;
public sealed class PointLightRealBatterySystem : EntitySystem
{
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PointLightRealBatteryComponent, ChargeChangedEvent>(OnChargeChanged);
SubscribeLocalEvent<PointLightRealBatteryComponent, ComponentInit>(OnComponentInit);
}
public void ToggleLight(EntityUid uid, string hex, bool enable = true)
{
if (!_pointLightSystem.TryGetLight(uid, out var pointLightComponent))
return;
if (enable)
{
var color = Color.FromHex(hex);
_pointLightSystem.SetColor(uid, color, pointLightComponent);
}
_pointLightSystem.SetEnabled(uid, enable, pointLightComponent);
RaiseLocalEvent(uid, new PointLightToggleEvent(enable), true);
}
public void OnComponentInit(EntityUid uid, PointLightRealBatteryComponent component, ComponentInit args)
{
if (!TryComp<BatteryComponent>(uid, out var battery))
return;
var ev = new ChargeChangedEvent(battery.CurrentCharge, battery.MaxCharge);
RaiseLocalEvent(uid, ref ev);
}
public void OnChargeChanged(EntityUid uid, PointLightRealBatteryComponent component, ChargeChangedEvent args)
{
var frac = args.Charge / args.MaxCharge;
var level = (byte) ContentHelpers.RoundToNearestLevels(frac, 1, PowerCellComponent.PowerCellVisualsLevels);
switch (level)
{
case 2:
ToggleLight(uid, component.GreenColor);
break;
case 1:
ToggleLight(uid, component.YellowColor);
break;
case 0:
ToggleLight(uid, string.Empty, false);
break;
}
}
}

View File

@@ -0,0 +1,15 @@
namespace Content.Server._White.Lighting.PointLight.RealBattery;
[RegisterComponent]
public sealed partial class PointLightRealBatteryComponent : Component
{
[DataField, ViewVariables]
public string RedColor = "#D56C6C";
[DataField, ViewVariables]
public string GreenColor = "#7FC080";
[DataField, ViewVariables]
public string YellowColor = "#BDC07F";
}

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared._White.Telescope;
using Content.Shared._White.WeaponModules;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
@@ -11,7 +12,7 @@ public sealed class WeaponModulesSystem : EntitySystem
{
protected static readonly Dictionary<string, Enum> Slots = new()
{
{ "handguard_module", ModuleVisualState.HandGuardModule }, { "barrel_module", ModuleVisualState.BarrelModule }
{ "handguard_module", ModuleVisualState.HandGuardModule }, { "barrel_module", ModuleVisualState.BarrelModule }, { "aim_module", ModuleVisualState.AimModule }
};
[Dependency] private readonly PointLightSystem _lightSystem = default!;
@@ -36,6 +37,9 @@ public sealed class WeaponModulesSystem : EntitySystem
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotInsertedIntoContainerMessage>(AcceleratorModuleOnInsert);
SubscribeLocalEvent<AcceleratorModuleComponent, EntGotRemovedFromContainerMessage>(AcceleratorModuleOnEject);
SubscribeLocalEvent<AimModuleComponent, EntGotInsertedIntoContainerMessage>(EightAimModuleOnInsert);
SubscribeLocalEvent<AimModuleComponent, EntGotRemovedFromContainerMessage>(EightAimModuleOnEject);
}
private bool TryInsertModule(EntityUid module, EntityUid weapon, BaseModuleComponent component,
@@ -154,6 +158,18 @@ public sealed class WeaponModulesSystem : EntitySystem
_gunSystem.SetFireRate(weapon, component.OldFireRate + component.FireRateAdd);
}
private void EightAimModuleOnInsert(EntityUid module, AimModuleComponent component, EntGotInsertedIntoContainerMessage args)
{
EntityUid weapon = args.Container.Owner;
if (!TryComp<GunComponent>(weapon, out var gunComp)) return;
if(!TryInsertModule(module, weapon, component, args.Container.ID, out var weaponModulesComponent))
return;
EnsureComp<TelescopeComponent>(weapon).Divisor = component.Divisor;
}
#endregion
#region EjectModules
@@ -213,5 +229,15 @@ public sealed class WeaponModulesSystem : EntitySystem
_gunSystem.SetFireRate(weapon, component.OldFireRate);
}
private void EightAimModuleOnEject(EntityUid module, AimModuleComponent component, EntGotRemovedFromContainerMessage args)
{
EntityUid weapon = args.Container.Owner;
if(!TryEjectModule(module, weapon, args.Container.ID, out var weaponModulesComponent))
return;
RemComp<TelescopeComponent>(weapon);
}
#endregion
}

View File

@@ -1,5 +1,6 @@
using System.Linq;
using System.Numerics;
using Content.Server._White.Cult;
using Content.Server._White.IncorporealSystem;
using Content.Server._White.Wizard.Magic.Amaterasu;
using Content.Server._White.Wizard.Magic.Other;
@@ -24,7 +25,6 @@ using Content.Shared._White.Wizard;
using Content.Shared._White.Wizard.Magic;
using Content.Shared.Actions;
using Content.Shared.Borer;
using Content.Shared.Changeling;
using Content.Shared.Cluwne;
using Content.Shared.Coordinates.Helpers;
using Content.Shared.Hands.Components;
@@ -36,6 +36,7 @@ using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Item;
using Content.Shared.Magic;
using Content.Shared.Maps;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Content.Shared.Popups;
@@ -85,6 +86,7 @@ public sealed class WizardSpellsSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<StopTimeSpellEvent>(OnTimeStop);
SubscribeLocalEvent<MindswapSpellEvent>(OnMindswapSpell);
SubscribeLocalEvent<TeleportSpellEvent>(OnTeleportSpell);
SubscribeLocalEvent<InstantRecallSpellEvent>(OnInstantRecallSpell);
@@ -103,6 +105,25 @@ public sealed class WizardSpellsSystem : EntitySystem
SubscribeLocalEvent<MagicComponent, BeforeCastSpellEvent>(OnBeforeCastSpell);
}
#region Timestop
private void OnTimeStop(StopTimeSpellEvent msg)
{
if (!CanCast(msg))
return;
var ent = Spawn(msg.Prototype, Transform(msg.Performer).Coordinates);
_transformSystem.AttachToGridOrMap(ent);
var comp = EnsureComp<PreventCollideComponent>(ent);
comp.Uid = msg.Performer;
msg.Handled = true;
Speak(msg);
}
#endregion
#region Mindswap
private void OnMindswapSpell(MindswapSpellEvent msg)
@@ -113,17 +134,12 @@ public sealed class WizardSpellsSystem : EntitySystem
var target = msg.Target;
var uid = msg.Performer;
if (HasComp<ChangelingComponent>(target) || HasComp<RevolutionaryComponent>(target) ||
HasComp<CultistComponent>(target))
{
_popupSystem.PopupEntity("Не работает на культистов, генокрадов и революционеров.", uid, uid,
PopupType.MediumCaution);
if (!TryComp(target, out MobStateComponent? mobState) || mobState.CurrentState != MobState.Alive)
return;
}
if (TryComp(target, out InfestedBorerComponent? borer) && borer.ControllingBrain)
{
_popupSystem.PopupEntity("Им уже кто-то управляет.", uid, uid, PopupType.MediumCaution);
_popupSystem.PopupEntity(Loc.GetString("mindswap-borer-failed"), uid, uid, PopupType.MediumCaution);
return;
}
@@ -138,7 +154,7 @@ public sealed class WizardSpellsSystem : EntitySystem
if (targetHasMind)
{
_mindSystem.TransferTo(targetMindId, uid, mind: targetMind);
_popupSystem.PopupEntity(Loc.GetString("Ваш разум подменили!"), uid, uid, PopupType.LargeCaution);
_popupSystem.PopupEntity(Loc.GetString("mindswap-success"), uid, uid, PopupType.LargeCaution);
}
TransferAllMagicActions(uid, target);
@@ -149,23 +165,11 @@ public sealed class WizardSpellsSystem : EntitySystem
msg.Handled = true;
Speak(msg);
var hasWiz = HasComp<WizardComponent>(uid);
var targetHasWiz = HasComp<WizardComponent>(target);
if (hasWiz == targetHasWiz)
return;
if (hasWiz)
{
RemComp<WizardComponent>(uid);
EnsureComp<WizardComponent>(target);
}
if (targetHasWiz)
{
RemComp<WizardComponent>(target);
EnsureComp<WizardComponent>(uid);
}
SwapComponent<WizardComponent>(uid, target);
SwapComponent<RevolutionaryComponent>(uid, target);
SwapComponent<HeadRevolutionaryComponent>(uid, target);
SwapComponent<PentagramComponent>(uid, target);
SwapComponent<CultistComponent>(uid, target);
}
#endregion
@@ -919,5 +923,26 @@ public sealed class WizardSpellsSystem : EntitySystem
}
}
private void SwapComponent<T>(EntityUid uid1, EntityUid uid2) where T : Component, new()
{
var hasComp = HasComp<T>(uid1);
var targetHasComp = HasComp<T>(uid2);
if (hasComp == targetHasComp)
return;
if (hasComp)
{
EnsureComp<T>(uid2);
RemComp<T>(uid1);
}
if (targetHasComp)
{
EnsureComp<T>(uid1);
RemComp<T>(uid2);
}
}
#endregion
}