mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
Fix killer tomato visual bug after mutation, cleanup Plant*System IComponentFactory instances. (#46201)
* MutationSystem: take GrowthStages from new plant * get the rest of the IComponentFactory instances might as well * todo bem
This commit is contained in:
parent
28ad6ceaea
commit
cdd526ee0a
4 changed files with 22 additions and 7 deletions
|
|
@ -12,7 +12,6 @@ namespace Content.Server.EntityEffects.Effects.Botany.PlantAttributes;
|
|||
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
|
||||
public sealed partial class PlantChangeStatEntityEffectSystem : EntityEffectSystem<PlantComponent, PlantChangeStat>
|
||||
{
|
||||
[Dependency] private IComponentFactory _componentFactory = default!;
|
||||
[Dependency] private IRobustRandom _random = default!;
|
||||
[Dependency] private PlantHolderSystem _plantHolder = default!;
|
||||
[Dependency] private SharedEntityEffectsSystem _entityEffects = default!;
|
||||
|
|
@ -25,7 +24,7 @@ public sealed partial class PlantChangeStatEntityEffectSystem : EntityEffectSyst
|
|||
var targetDataField = args.Effect.TargetDataField;
|
||||
var targetComponent = args.Effect.TargetComponent;
|
||||
|
||||
if (!_componentFactory.TryGetRegistration(targetComponent, out var registration))
|
||||
if (!Factory.TryGetRegistration(targetComponent, out var registration))
|
||||
{
|
||||
Log.Error($"{nameof(PlantChangeStat)} Error: Component '{targetComponent}' is not a valid component name.");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ namespace Content.Shared.Botany.Systems;
|
|||
|
||||
public sealed partial class BotanySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private IComponentFactory _componentFactory = default!;
|
||||
[Dependency] private IGameTiming _timing = default!;
|
||||
[Dependency] private MetaDataSystem _metaData = default!;
|
||||
[Dependency] private PlantSystem _plant = default!;
|
||||
|
|
@ -87,7 +86,7 @@ public sealed partial class BotanySystem : EntitySystem
|
|||
if (!ProtoMan.TryIndex(plantProtoId.Value, out var proto))
|
||||
return false;
|
||||
|
||||
return proto.TryComp(out plant, _componentFactory);
|
||||
return proto.TryComp(out plant, Factory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -193,7 +192,7 @@ public sealed partial class BotanySystem : EntitySystem
|
|||
return false;
|
||||
|
||||
if (!ProtoMan.Resolve(ent.Comp2.PacketPrototype, out var seedProto)
|
||||
|| !seedProto.TryComp<SeedComponent>(out var seedComp, _componentFactory))
|
||||
|| !seedProto.TryComp<SeedComponent>(out var seedComp, Factory))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public sealed partial class PlantMutationSystem : EntitySystem
|
|||
_botany.DeletePlantSnapshot(snapshot);
|
||||
|
||||
ChemicalsSpeciesChange(newPlantUid, newPlantProto);
|
||||
PlantSpeciesChange(newPlantUid, newPlantProto);
|
||||
|
||||
if (_plant.TryGetTray(oldPlant.Owner, out var trayEnt))
|
||||
_plantTray.PlantingPlantInTray(trayEnt.AsNullable(), newPlantUid);
|
||||
|
|
@ -121,6 +122,23 @@ public sealed partial class PlantMutationSystem : EntitySystem
|
|||
Dirty(plantUid, oldPlantChemicals);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies information from the PlantComponent on a prototype over to a given plant.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see cref="PlantComponent.GrowthStages"/> must stay true for the given plant.
|
||||
/// TODO: better support excluding fields depending on clone context.
|
||||
/// </remarks>
|
||||
private void PlantSpeciesChange(EntityUid plantUid, EntProtoId plantProto)
|
||||
{
|
||||
if (!_botany.TryGetPlantComponent<PlantComponent>(null, plantProto, out var newSpecies)
|
||||
|| !_plantQuery.TryComp(plantUid, out var plant))
|
||||
return;
|
||||
|
||||
plant.GrowthStages = newSpecies.GrowthStages;
|
||||
DirtyField(plantUid, plant, nameof(PlantComponent.GrowthStages));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Combines mutations from the pollen and target plants.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -13,14 +13,13 @@ namespace Content.Shared.EntityEffects.Effects.Botany.PlantAttributes;
|
|||
public sealed partial class PlantChangeTraitsEntityEffectSystem : EntityEffectSystem<PlantComponent, PlantChangeTraits>
|
||||
{
|
||||
[Dependency] private PlantHolderSystem _plantHolder = default!;
|
||||
[Dependency] private IComponentFactory _componentFactory = default!;
|
||||
|
||||
protected override void Effect(Entity<PlantComponent> entity, ref EntityEffectEvent<PlantChangeTraits> args)
|
||||
{
|
||||
if (_plantHolder.IsDead(entity.Owner))
|
||||
return;
|
||||
|
||||
var traitType = _componentFactory.GetComponent(args.Effect.Trait);
|
||||
var traitType = Factory.GetComponent(args.Effect.Trait);
|
||||
if (traitType is not PlantTraitsComponent)
|
||||
{
|
||||
Log.Error(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue