Skip to content

Commit

Permalink
Commit Suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Nov 8, 2024
1 parent 71ef14f commit fe9f99d
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 29 deletions.
41 changes: 13 additions & 28 deletions Content.Server/Traits/TraitSystem.Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Content.Server.Language;
using Content.Shared.Mood;
using Content.Server.NPC.Systems;
using Robust.Shared.Serialization;

namespace Content.Server.Traits;

Expand All @@ -29,12 +28,11 @@ public override void OnPlayerSpawn(EntityUid uid,
foreach (var (name, data) in Components)
{
var component = (Component) factory.GetComponent(name);
component.Owner = uid;

var temp = (object) component;
serializationManager.CopyTo(data.Component, ref temp);
entityManager.RemoveComponent(uid, temp!.GetType());
entityManager.AddComponent(uid, (Component) temp);
entityManager.AddComponent(uid, (Component) temp, true);
}
}
}
Expand All @@ -57,9 +55,8 @@ public override void OnPlayerSpawn(EntityUid uid,
foreach (var (name, _) in Components)
{
var component = (Component) factory.GetComponent(name);
component.Owner = uid;

entityManager.AddComponent(uid, component);
entityManager.AddComponent(uid, component, true);
}
}
}
Expand All @@ -86,16 +83,13 @@ public override void OnPlayerSpawn(EntityUid uid,
public sealed partial class TraitAddActions : TraitFunction
{
[DataField, AlwaysPushInheritance]
public List<EntProtoId>? Actions { get; private set; } = default!;
public List<EntProtoId> Actions { get; private set; } = default!;

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
if (Actions is null)
return;

var actionSystem = entityManager.System<SharedActionsSystem>();

foreach (var id in Actions)
Expand Down Expand Up @@ -133,7 +127,7 @@ public override void OnPlayerSpawn(EntityUid uid,
public sealed partial class TraitAddPsionics : TraitFunction
{
[DataField, AlwaysPushInheritance]
public List<string>? PsionicPowers { get; private set; } = default!;
public List<ProtoId<PsionicPowerPrototype>> PsionicPowers { get; private set; } = default!;

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
Expand All @@ -142,11 +136,9 @@ public override void OnPlayerSpawn(EntityUid uid,
{
var prototype = IoCManager.Resolve<IPrototypeManager>();
var psionic = entityManager.System<PsionicAbilitiesSystem>();
if (PsionicPowers is null)
return;

foreach (var powerProto in PsionicPowers)
if (prototype.TryIndex<PsionicPowerPrototype>(powerProto, out var psionicPower))
if (prototype.TryIndex(powerProto, out var psionicPower))
psionic.InitializePsionicPower(uid, psionicPower, false);
}
}
Expand Down Expand Up @@ -202,16 +194,14 @@ public sealed partial class TraitAddMoodlets : TraitFunction
{
/// The list of all Moodlets that this trait adds.
[DataField, AlwaysPushInheritance]
public List<ProtoId<MoodEffectPrototype>>? MoodEffects { get; private set; } = default!;
public List<ProtoId<MoodEffectPrototype>> MoodEffects { get; private set; } = default!;

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
var prototype = IoCManager.Resolve<IPrototypeManager>();
if (MoodEffects is null)
return;

foreach (var moodProto in MoodEffects)
if (prototype.TryIndex(moodProto, out var moodlet))
Expand All @@ -230,7 +220,7 @@ public sealed partial class TraitModifyFactions : TraitFunction
/// I can't actually Validate these because the proto lives in Shared.
/// </remarks>
[DataField, AlwaysPushInheritance]
public List<string>? RemoveFactions { get; private set; } = default!;
public List<string> RemoveFactions { get; private set; } = default!;

/// <summary>
/// The list of all Factions that this trait adds.
Expand All @@ -239,7 +229,7 @@ public sealed partial class TraitModifyFactions : TraitFunction
/// I can't actually Validate these because the proto lives in Shared.
/// </remarks>
[DataField, AlwaysPushInheritance]
public List<string>? AddFactions { get; private set; } = default!;
public List<string> AddFactions { get; private set; } = default!;

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
Expand All @@ -248,13 +238,11 @@ public override void OnPlayerSpawn(EntityUid uid,
{
var factionSystem = entityManager.System<NpcFactionSystem>();

if (RemoveFactions is not null)
foreach (var faction in RemoveFactions)
factionSystem.RemoveFaction(uid, faction);
foreach (var faction in RemoveFactions)
factionSystem.RemoveFaction(uid, faction);

if (AddFactions is not null)
foreach (var faction in AddFactions)
factionSystem.AddFaction(uid, faction);
foreach (var faction in AddFactions)
factionSystem.AddFaction(uid, faction);
}
}

Expand All @@ -263,16 +251,13 @@ public override void OnPlayerSpawn(EntityUid uid,
public sealed partial class TraitVVEdit : TraitFunction
{
[DataField, AlwaysPushInheritance]
public Dictionary<string, string>? VVEdit { get; private set; }
public Dictionary<string, string> VVEdit { get; private set; }

public override void OnPlayerSpawn(EntityUid uid,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
if (VVEdit is null)
return;

var vvm = IoCManager.Resolve<IViewVariablesManager>();
foreach (var (path, value) in VVEdit)
vvm.WritePath(path, value);
Expand Down
31 changes: 31 additions & 0 deletions Resources/Prototypes/Traits/mental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
species:
- Oni
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- LowPotential
functions:
- !type:TraitReplaceComponent
components:
Expand Down Expand Up @@ -64,6 +68,10 @@
species:
- Oni
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- HighPotential
functions:
- !type:TraitReplaceComponent
components:
Expand Down Expand Up @@ -101,6 +109,11 @@
inverted: true
species:
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- HighAmplification
- PowerOverwhelming
functions:
- !type:TraitAddPsionics
psionicPowers:
Expand Down Expand Up @@ -137,6 +150,11 @@
inverted: true
species:
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- LowAmplification
- PowerOverwhelming
functions:
- !type:TraitAddPsionics
psionicPowers:
Expand Down Expand Up @@ -173,6 +191,11 @@
inverted: true
species:
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- LowAmplification
- HighAmplification
functions:
- !type:TraitAddPsionics
psionicPowers:
Expand Down Expand Up @@ -209,6 +232,10 @@
inverted: true
species:
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- HighDampening
functions:
- !type:TraitAddPsionics
psionicPowers:
Expand Down Expand Up @@ -245,6 +272,10 @@
inverted: true
species:
- Shadowkin
- !type:CharacterTraitRequirement
inverted: true
traits:
- LowDampening
functions:
- !type:TraitAddPsionics
psionicPowers:
Expand Down
60 changes: 59 additions & 1 deletion Resources/Prototypes/Traits/physical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- WillToDie
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -32,6 +36,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- WillToLive
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -52,6 +60,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- GlassJaw
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -72,6 +84,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- Tenacity
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -88,6 +104,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- Lethargy
- !type:CharacterSpeciesRequirement
inverted: true
species:
Expand All @@ -109,6 +129,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- Vigor
- !type:CharacterSpeciesRequirement
inverted: true
species:
Expand All @@ -133,6 +157,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- AdrenalDysfunction
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -154,6 +182,10 @@
inverted: true
species:
- IPC
- !type:CharacterTraitRequirement
inverted: true
traits:
- HighAdrenaline
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -170,6 +202,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- LowPainTolerance
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -187,6 +223,10 @@
jobs:
- Borg
- MedicalBorg
- !type:CharacterTraitRequirement
inverted: true
traits:
- Masochism
functions:
- !type:TraitReplaceComponent
components:
Expand Down Expand Up @@ -265,6 +305,10 @@
species:
- Harpy # Harpies already have talons
- Arachnid # Apparently they have a "piercing" bite
- !type:CharacterTraitRequirement
inverted: true
traits:
- Claws
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -289,6 +333,10 @@
- Reptilian # Reptilians also have cat claws.
- Shadowkin # Shadowkins also have claws.
# - Vulpkanin # Vulpkanin have "Blunt" claws. One could argue this trait "Sharpens" their claws.
- !type:CharacterTraitRequirement
inverted: true
traits:
- Talons
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -313,6 +361,11 @@
- Human
- Oni
- SlimePerson
- !type:CharacterTraitRequirement
inverted: true
traits:
- Talons
- Claws
functions:
- !type:TraitReplaceComponent
components:
Expand All @@ -338,6 +391,11 @@
species:
- Human # Entirely arbitrary, I've decided I want a trait unique to humans. Since they don't normally get anything exciting.
# When we get the Character Records system in, I also want to make this require certain Backgrounds.
- !type:CharacterTraitRequirement
inverted: true
traits:
- Claws
- Talons
- !type:CharacterLogicOrRequirement
requirements:
- !type:CharacterTraitRequirement
Expand Down Expand Up @@ -412,7 +470,7 @@
inverted: true
species:
- IPC
functions:
functions: # TODO: Code Platelet factories as an actual obtainable implant, and replace this with TraitAddImplant
- !type:TraitReplaceComponent
components:
- type: PassiveDamage
Expand Down
Loading

0 comments on commit fe9f99d

Please sign in to comment.