forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Kirus59/Mi-Go-rave-fix
MiGomycelium rave fix
- Loading branch information
Showing
3 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
Content.Server/SS220/EntityEffects/EffectConditions/HasComponentsCondition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
Resources/Locale/ru-RU/ss220/guidebook/chemistry/conditions.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters