mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
Adds a way to specify traits in the jobs special area.
Hashset so you can specify multiple traits. Tested on Nuclear14 to give
the tribals a specific language in a friendly way.
```
special:
- !type:AddTraitSpecial
traits: [ LanguageTribal, LanguageChinese ]
```
(cherry picked from commit bc0708ab3f602f5f348f2e0a0585effac9f5c3e8)
31 lines
987 B
C#
31 lines
987 B
C#
using Content.Server.Traits;
|
|
using Content.Shared.Roles;
|
|
using Content.Shared.Traits;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Server.Jobs;
|
|
|
|
|
|
[UsedImplicitly]
|
|
public sealed partial class AddTraitSpecial : JobSpecial
|
|
{
|
|
// Datafield for storing multiple trait prototype IDs as strings
|
|
[DataField(required: true)]
|
|
public HashSet<string> Traits { get; private set; } = new();
|
|
|
|
public override void AfterEquip(EntityUid mob)
|
|
{
|
|
// Resolve the necessary systems
|
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
|
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
|
var traitSystem = entityManager.System<TraitSystem>();
|
|
|
|
// Iterate through each trait and add it to the entity
|
|
foreach (var traitId in Traits)
|
|
if (prototypeManager.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
|
|
|
|
traitSystem.AddTrait(mob, traitPrototype);
|
|
}
|
|
}
|