Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

важное #145

Merged
merged 11 commits into from
Sep 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private RadialMenu FormMenu()

var mainContainer = new RadialContainer
{
Radius = 36f / MathF.Sin(MathF.PI / crafting.Prototypes.Count)
Radius = 36f / MathF.Sin(MathF.PI / 2f / crafting.Prototypes.Count)
};

foreach (var protoId in crafting.Prototypes)
Expand Down
34 changes: 34 additions & 0 deletions Content.Server/Chemistry/ReagentEffects/ChemAddMoodlet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Mood;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;

namespace Content.Server.Chemistry.ReagentEffects;

/// <summary>
/// Adds a moodlet to an entity.
/// </summary>
[UsedImplicitly]
public sealed partial class ChemAddMoodlet : ReagentEffect
{
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
var protoMan = IoCManager.Resolve<IPrototypeManager>();
return Loc.GetString("reagent-effect-guidebook-add-moodlet",
("amount", protoMan.Index<MoodEffectPrototype>(MoodPrototype.Id).MoodChange),
("timeout", protoMan.Index<MoodEffectPrototype>(MoodPrototype.Id).Timeout));
}

/// <summary>
/// The mood prototype to be applied to the using entity.
/// </summary>
[DataField(required: true)]
public ProtoId<MoodEffectPrototype> MoodPrototype = default!;

public override void Effect(ReagentEffectArgs args)
{
var entityManager = IoCManager.Resolve<EntityManager>();
var ev = new MoodEffectEvent(MoodPrototype);
entityManager.EventBus.RaiseLocalEvent(args.SolutionEntity, ev);
}
}
30 changes: 19 additions & 11 deletions Content.Server/Mood/MoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public override void Initialize()
SubscribeLocalEvent<MoodComponent, DamageChangedEvent>(OnDamageChange);
SubscribeLocalEvent<MoodComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMoveSpeed);
SubscribeLocalEvent<MoodComponent, MoodRemoveEffectEvent>(OnRemoveEffect);

SubscribeLocalEvent<MoodModifyTraitComponent, ComponentStartup>(OnTraitStartup);
}

private void OnShutdown(EntityUid uid, MoodComponent component, ComponentShutdown args)
Expand Down Expand Up @@ -101,15 +99,6 @@ private void OnRefreshMoveSpeed(EntityUid uid, MoodComponent component, RefreshM
args.ModifySpeed(1, modifier);
}

private void OnTraitStartup(EntityUid uid, MoodModifyTraitComponent component, ComponentStartup args)
{
if (_debugMode
|| component.MoodId is null)
return;

RaiseLocalEvent(uid, new MoodEffectEvent($"{component.MoodId}"));
}

private void OnMoodEffect(EntityUid uid, MoodComponent component, MoodEffectEvent args)
{
if (_debugMode
Expand Down Expand Up @@ -195,9 +184,28 @@ private void RemoveTimedOutEffect(EntityUid uid, string prototypeId, string? cat
comp.CategorisedEffects.Remove(category);
}

ReplaceMood(uid, prototypeId);
RefreshMood(uid, comp);
}

/// <summary>
/// Some moods specifically create a moodlet upon expiration. This is normally used for "Addiction" type moodlets,
/// such as a positive moodlet from an addictive substance that becomes a negative moodlet when a timer ends.
/// </summary>
/// <remarks>
/// Moodlets that use this should probably also share a category with each other, but this isn't necessarily required.
/// Only if you intend that "Re-using the drug" should also remove the negative moodlet.
/// </remarks>
private void ReplaceMood(EntityUid uid, string prototypeId)
{
if (!_prototypeManager.TryIndex<MoodEffectPrototype>(prototypeId, out var proto)
|| proto.MoodletOnEnd is null)
return;

var ev = new MoodEffectEvent(proto.MoodletOnEnd);
EntityManager.EventBus.RaiseLocalEvent(uid, ev);
}

private void OnMobStateChanged(EntityUid uid, MoodComponent component, MobStateChangedEvent args)
{
if (_debugMode)
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Power/Components/ActiveChargerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Power;

namespace Content.Server.Power.Components;

[RegisterComponent]
public sealed partial class ActiveChargerComponent : Component { }
19 changes: 0 additions & 19 deletions Content.Server/Power/Components/ChargingComponent.cs

This file was deleted.

16 changes: 0 additions & 16 deletions Content.Server/Power/EntitySystems/BatterySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public override void Initialize()
SubscribeLocalEvent<BatteryComponent, RejuvenateEvent>(OnBatteryRejuvenate);
SubscribeLocalEvent<BatteryComponent, PriceCalculationEvent>(CalculateBatteryPrice);
SubscribeLocalEvent<BatteryComponent, EmpPulseEvent>(OnEmpPulse);
SubscribeLocalEvent<BatteryComponent, EmpDisabledRemoved>(OnEmpDisabledRemoved);

SubscribeLocalEvent<NetworkBatteryPreSync>(PreSync);
SubscribeLocalEvent<NetworkBatteryPostSync>(PostSync);
Expand Down Expand Up @@ -106,17 +105,6 @@ private void OnEmpPulse(EntityUid uid, BatteryComponent component, ref EmpPulseE
UseCharge(uid, args.EnergyConsumption, component);
}

// if a disabled battery is put into a recharged,
// allow the recharger to start recharging again after the disable ends
private void OnEmpDisabledRemoved(EntityUid uid, BatteryComponent component, ref EmpDisabledRemoved args)
{
if (!TryComp<ChargingComponent>(uid, out var charging))
return;

var ev = new ChargerUpdateStatusEvent();
RaiseLocalEvent<ChargerUpdateStatusEvent>(charging.ChargerUid, ref ev);
}

public float UseCharge(EntityUid uid, float value, BatteryComponent? battery = null)
{
if (value <= 0 || !Resolve(uid, ref battery) || battery.CurrentCharge == 0)
Expand Down Expand Up @@ -191,10 +179,6 @@ public bool IsFull(EntityUid uid, BatteryComponent? battery = null)
if (!Resolve(uid, ref battery))
return false;

// If the battery is full, remove its charging component.
if (TryComp<ChargingComponent>(uid, out _))
RemComp<ChargingComponent>(uid);

return battery.CurrentCharge / battery.MaxCharge >= 0.99f;
}
}
Expand Down
Loading
Loading