Skip to content

Commit

Permalink
Merge pull request #73 from Kirus59/Mi-Go-rave-fix
Browse files Browse the repository at this point in the history
MiGomycelium rave fix
  • Loading branch information
SkaldetSkaeg authored Dec 26, 2024
2 parents 560ae83 + 0ddb604 commit 6e8164e
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Content.Shared.EntityEffects;
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Serilog;

namespace Content.Server.SS220.EntityEffects.EffectConditions;

[UsedImplicitly]
public sealed partial class HasComponentsCondition : EntityEffectCondition
{
[DataField(required: true)]
public string[] Components;

[DataField]
public bool RequireAll = false;

[DataField]
public bool Inverted = false;

public override bool Condition(EntityEffectBaseArgs args)
{
if (Components.Length == 0)
return true;

var condition = RequireAll;
var factory = IoCManager.Resolve<IComponentFactory>();
foreach (var component in Components)
{
var availability = factory.GetComponentAvailability(component);
if (!factory.TryGetRegistration(component, out var registration) ||
availability != ComponentAvailability.Available)
continue;
else if (availability == ComponentAvailability.Unknown)
Log.Error($"Unknown component name {component} passed to {this.ToString()}!");

if (args.EntityManager.HasComponent(args.TargetEntity, registration.Type))
{
if (!RequireAll)
{
condition = true;
break;
}
}
else if (RequireAll)
{
condition = false;
break;
}
}

return condition ^ Inverted;
}

public override string GuidebookExplanation(IPrototypeManager prototype)
{
if (Components.Length == 0)
return string.Empty;

var components = string.Empty;
for (var i = 0; i < Components.Length; i++)
{
components += i + 1 != Components.Length
? Components[i] + ","
: Components[i];
}

return Loc.GetString("reagent-effect-condition-guidebook-has-components", ("inverted", Inverted),
("requireAll", RequireAll), ("components", components));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
reagent-effect-condition-guidebook-has-components =
цель { $inverted ->
[true] не имеет
*[false] имеет
} { $requireAll ->
[true] все компоненты:
*[false] хотя бы 1 из компонентов:
} {$components}
4 changes: 4 additions & 0 deletions Resources/Prototypes/SS220/Reagents/cultYogg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
- !type:ReagentThreshold
reagent: TheBloodOfYogg
min: 2
- !type:HasComponentsCondition
inverted: true
components:
- CultYogg

- type: reagent
id: ElixirOfLiberation
Expand Down

0 comments on commit 6e8164e

Please sign in to comment.