From b46f032959d1e430438669f946090a56cb80d2ea Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Wed, 11 Sep 2024 17:40:42 +0700 Subject: [PATCH 1/7] Traits for roundstart species size --- Content.Server/Cloning/CloningSystem.cs | 15 +++++ .../Traits/Assorted/SizeAttributeComponent.cs | 14 ++++ .../Traits/Assorted/SizeAttributeSystem.cs | 67 +++++++++++++++++++ .../SizeAttributeWhitelistComponent.cs | 19 ++++++ .../Cloning/ITransferredByCloning.cs | 9 +++ .../Prototypes/Entities/Mobs/Species/base.yml | 5 ++ .../Entities/Mobs/Species/dwarf.yml | 3 + Resources/Prototypes/Traits/categories.yml | 5 ++ Resources/Prototypes/Traits/sizeattribute.yml | 31 +++++++++ 9 files changed, 168 insertions(+) create mode 100644 Content.Server/Traits/Assorted/SizeAttributeComponent.cs create mode 100644 Content.Server/Traits/Assorted/SizeAttributeSystem.cs create mode 100644 Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs create mode 100644 Content.Shared/Cloning/ITransferredByCloning.cs create mode 100644 Resources/Prototypes/Traits/sizeattribute.yml diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 3893f31d25d..00ed10aaaa4 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -33,6 +33,7 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Prototypes; using Robust.Shared.Random; +using Robust.Shared.Serialization.Manager; namespace Content.Server.Cloning { @@ -61,6 +62,9 @@ public sealed class CloningSystem : EntitySystem [Dependency] private readonly MetaDataSystem _metaSystem = default!; [Dependency] private readonly SharedJobSystem _jobs = default!; + // corvax-next + [Dependency] private readonly ISerializationManager _serialization = default!; + public readonly Dictionary ClonesWaitingForMind = new(); public const float EasyModeCloningCost = 0.7f; @@ -213,6 +217,17 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity(OnComponentInit); + } + + private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args) + { + if (!TryComp(uid, out var whitelist)) + return; + + if (whitelist.Tall && component.Tall) + { + Scale(uid, component, whitelist.TallScale); + } + else if (whitelist.Short && component.Short) + { + Scale(uid, component, whitelist.ShortScale); + } + } + + private void Scale(EntityUid uid, SizeAttributeComponent component, float scale) + { + if (scale <= 0f) + return; + + _entityManager.EnsureComponent(uid); + + var appearanceComponent = _entityManager.EnsureComponent(uid); + if (!_appearance.TryGetData(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) + oldScale = Vector2.One; + + _appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); + + if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager)) + { + foreach (var (id, fixture) in manager.Fixtures) + { + if (!fixture.Hard || fixture.Density <= 1f) + continue; // This will skip the flammable fixture and any other fixture that is not supposed to contribute to mass + + switch (fixture.Shape) + { + case PhysShapeCircle circle: + _physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); + break; + default: + throw new NotImplementedException(); + } + } + } + } + } +} diff --git a/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs b/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs new file mode 100644 index 00000000000..62b39d2074a --- /dev/null +++ b/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs @@ -0,0 +1,19 @@ +namespace Content.Server.Traits.Assorted +{ + [RegisterComponent] + public sealed partial class SizeAttributeWhitelistComponent : Component + { + [DataField("short")] + public bool Short = false; + + [DataField("shortscale")] + public float ShortScale = 0f; + + [DataField("tall")] + public bool Tall = false; + + [DataField("tallscale")] + public float TallScale = 0f; + + } +} diff --git a/Content.Shared/Cloning/ITransferredByCloning.cs b/Content.Shared/Cloning/ITransferredByCloning.cs new file mode 100644 index 00000000000..d2504c4c67f --- /dev/null +++ b/Content.Shared/Cloning/ITransferredByCloning.cs @@ -0,0 +1,9 @@ +namespace Content.Shared.Cloning +{ + /// + /// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner) + /// + public interface ITransferredByCloning + { + } +} diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index cbe09c29ad9..972967ff0d3 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -211,6 +211,11 @@ - CanPilot - FootstepSound - DoorBumpOpener + - type: SizeAttributeWhitelist # corvax-next + tall: true + tallscale: 1.1 + short: true + shortscale: 0.90 - type: entity save: false diff --git a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml index 6ce9c80a250..98c05dd5599 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml @@ -63,6 +63,9 @@ 32: sprite: Mobs/Species/Human/displacement.rsi state: jumpsuit-female + - type: SizeAttributeWhitelist # corvax-next + tall: false + short: false - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/Traits/categories.yml b/Resources/Prototypes/Traits/categories.yml index d024b3fcff3..1c9abe3f81a 100644 --- a/Resources/Prototypes/Traits/categories.yml +++ b/Resources/Prototypes/Traits/categories.yml @@ -10,3 +10,8 @@ - type: traitCategory id: Quirks name: trait-category-quirks + +- type: traitCategory # corvax-next + id: SizeTraits + name: Рост + maxTraitPoints: 1 \ No newline at end of file diff --git a/Resources/Prototypes/Traits/sizeattribute.yml b/Resources/Prototypes/Traits/sizeattribute.yml new file mode 100644 index 00000000000..79f168449f3 --- /dev/null +++ b/Resources/Prototypes/Traits/sizeattribute.yml @@ -0,0 +1,31 @@ +- type: trait # corvax-next + id: Tall + name: Высокий + description: У вас проблемы с гигантизмом. + category: SizeTraits + cost: 1 + whitelist: + components: + - SizeAttributeWhitelist + blacklist: + components: + - SizeAttribute + components: + - type: SizeAttribute + tall: true + +- type: trait + id: Short + name: Низкий + description: Вы коротковаты ростом. + category: SizeTraits + cost: 1 + whitelist: + components: + - SizeAttributeWhitelist + blacklist: + components: + - SizeAttribute + components: + - type: SizeAttribute + short: true \ No newline at end of file From 9baacbdc49eaed69690734eab111713979ffae95 Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Thu, 12 Sep 2024 00:29:21 +0700 Subject: [PATCH 2/7] Traits for roundstart species size --- Resources/Prototypes/Corvax/Traits/categories.yml | 4 ++++ Resources/Prototypes/{ => Corvax}/Traits/sizeattribute.yml | 2 +- Resources/Prototypes/Traits/categories.yml | 7 +------ 3 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 Resources/Prototypes/Corvax/Traits/categories.yml rename Resources/Prototypes/{ => Corvax}/Traits/sizeattribute.yml (95%) diff --git a/Resources/Prototypes/Corvax/Traits/categories.yml b/Resources/Prototypes/Corvax/Traits/categories.yml new file mode 100644 index 00000000000..dcf024361bd --- /dev/null +++ b/Resources/Prototypes/Corvax/Traits/categories.yml @@ -0,0 +1,4 @@ +- type: traitCategory # Corvax-Next + id: SizeTraits + name: Рост + maxTraitPoints: 1 \ No newline at end of file diff --git a/Resources/Prototypes/Traits/sizeattribute.yml b/Resources/Prototypes/Corvax/Traits/sizeattribute.yml similarity index 95% rename from Resources/Prototypes/Traits/sizeattribute.yml rename to Resources/Prototypes/Corvax/Traits/sizeattribute.yml index 79f168449f3..dd6f941623d 100644 --- a/Resources/Prototypes/Traits/sizeattribute.yml +++ b/Resources/Prototypes/Corvax/Traits/sizeattribute.yml @@ -1,4 +1,4 @@ -- type: trait # corvax-next +- type: trait # Corvax-Next id: Tall name: Высокий description: У вас проблемы с гигантизмом. diff --git a/Resources/Prototypes/Traits/categories.yml b/Resources/Prototypes/Traits/categories.yml index 1c9abe3f81a..114e115b8a4 100644 --- a/Resources/Prototypes/Traits/categories.yml +++ b/Resources/Prototypes/Traits/categories.yml @@ -9,9 +9,4 @@ - type: traitCategory id: Quirks - name: trait-category-quirks - -- type: traitCategory # corvax-next - id: SizeTraits - name: Рост - maxTraitPoints: 1 \ No newline at end of file + name: trait-category-quirks \ No newline at end of file From 478c73733e4f5fc676d8cbd51185a308a9c6ff33 Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Thu, 12 Sep 2024 18:25:12 +0700 Subject: [PATCH 3/7] Remade PR --- Content.Server/Cloning/CloningSystem.cs | 15 ----- ...tributeComponent.cs => HeightComponent.cs} | 12 ++-- .../Traits/Assorted/HeightSystem.cs | 63 +++++++++++++++++ .../Traits/Assorted/SizeAttributeSystem.cs | 67 ------------------- .../SizeAttributeWhitelistComponent.cs | 19 ------ .../Cloning/ITransferredByCloning.cs | 9 --- .../Assorted/HeightTraitBlacklistComponent.cs | 6 ++ .../Prototypes/Corvax/Traits/categories.yml | 4 +- Resources/Prototypes/Corvax/Traits/height.yml | 25 +++++++ .../Corvax/Traits/sizeattribute.yml | 31 --------- .../Prototypes/Entities/Mobs/Species/base.yml | 5 -- .../Entities/Mobs/Species/dwarf.yml | 4 +- 12 files changed, 104 insertions(+), 156 deletions(-) rename Content.Server/Traits/Assorted/{SizeAttributeComponent.cs => HeightComponent.cs} (56%) create mode 100644 Content.Server/Traits/Assorted/HeightSystem.cs delete mode 100644 Content.Server/Traits/Assorted/SizeAttributeSystem.cs delete mode 100644 Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs delete mode 100644 Content.Shared/Cloning/ITransferredByCloning.cs create mode 100644 Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs create mode 100644 Resources/Prototypes/Corvax/Traits/height.yml delete mode 100644 Resources/Prototypes/Corvax/Traits/sizeattribute.yml diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 00ed10aaaa4..3893f31d25d 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -33,7 +33,6 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Prototypes; using Robust.Shared.Random; -using Robust.Shared.Serialization.Manager; namespace Content.Server.Cloning { @@ -62,9 +61,6 @@ public sealed class CloningSystem : EntitySystem [Dependency] private readonly MetaDataSystem _metaSystem = default!; [Dependency] private readonly SharedJobSystem _jobs = default!; - // corvax-next - [Dependency] private readonly ISerializationManager _serialization = default!; - public readonly Dictionary ClonesWaitingForMind = new(); public const float EasyModeCloningCost = 0.7f; @@ -217,17 +213,6 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity(InitComponent); + } + + private void InitComponent(EntityUid uid, HeightComponent component, ComponentStartup args) + { + if (TryComp(uid, out var comp)) + return; + + if (component.Short) + { + Scale(uid, component.ShortScale); + } + else if (component.Tall) + { + Scale(uid, component.TallScale); + } + + + } + private void Scale(EntityUid uid, float scale) + { + var physics = _entityManager.System(); + var appearance = _entityManager.System(); + + _entityManager.EnsureComponent(uid); + + var appearanceComponent = _entityManager.EnsureComponent(uid); + if (!appearance.TryGetData(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) + oldScale = Vector2.One; + + appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); + + if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager)) + { + foreach (var (id, fixture) in manager.Fixtures) + { + switch (fixture.Shape) + { + case PhysShapeCircle circle: + physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); + break; + default: + throw new NotImplementedException(); + } + } + } + } + } +} diff --git a/Content.Server/Traits/Assorted/SizeAttributeSystem.cs b/Content.Server/Traits/Assorted/SizeAttributeSystem.cs deleted file mode 100644 index 1cc2e560486..00000000000 --- a/Content.Server/Traits/Assorted/SizeAttributeSystem.cs +++ /dev/null @@ -1,67 +0,0 @@ -using Robust.Server.GameObjects; -using Robust.Shared.Physics; -using Robust.Shared.Physics.Collision.Shapes; -using Robust.Shared.Physics.Systems; -using System.Numerics; - -namespace Content.Server.Traits.Assorted -{ - public sealed class SizeAttributeSystem : EntitySystem - { - [Dependency] private readonly IEntityManager _entityManager = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; - [Dependency] private readonly AppearanceSystem _appearance = default!; - public override void Initialize() - { - base.Initialize(); - SubscribeLocalEvent(OnComponentInit); - } - - private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args) - { - if (!TryComp(uid, out var whitelist)) - return; - - if (whitelist.Tall && component.Tall) - { - Scale(uid, component, whitelist.TallScale); - } - else if (whitelist.Short && component.Short) - { - Scale(uid, component, whitelist.ShortScale); - } - } - - private void Scale(EntityUid uid, SizeAttributeComponent component, float scale) - { - if (scale <= 0f) - return; - - _entityManager.EnsureComponent(uid); - - var appearanceComponent = _entityManager.EnsureComponent(uid); - if (!_appearance.TryGetData(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) - oldScale = Vector2.One; - - _appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); - - if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager)) - { - foreach (var (id, fixture) in manager.Fixtures) - { - if (!fixture.Hard || fixture.Density <= 1f) - continue; // This will skip the flammable fixture and any other fixture that is not supposed to contribute to mass - - switch (fixture.Shape) - { - case PhysShapeCircle circle: - _physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); - break; - default: - throw new NotImplementedException(); - } - } - } - } - } -} diff --git a/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs b/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs deleted file mode 100644 index 62b39d2074a..00000000000 --- a/Content.Server/Traits/Assorted/SizeAttributeWhitelistComponent.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Content.Server.Traits.Assorted -{ - [RegisterComponent] - public sealed partial class SizeAttributeWhitelistComponent : Component - { - [DataField("short")] - public bool Short = false; - - [DataField("shortscale")] - public float ShortScale = 0f; - - [DataField("tall")] - public bool Tall = false; - - [DataField("tallscale")] - public float TallScale = 0f; - - } -} diff --git a/Content.Shared/Cloning/ITransferredByCloning.cs b/Content.Shared/Cloning/ITransferredByCloning.cs deleted file mode 100644 index d2504c4c67f..00000000000 --- a/Content.Shared/Cloning/ITransferredByCloning.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Content.Shared.Cloning -{ - /// - /// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner) - /// - public interface ITransferredByCloning - { - } -} diff --git a/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs b/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs new file mode 100644 index 00000000000..172d3fed72a --- /dev/null +++ b/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Server.Traits.Assorted +{ + [RegisterComponent] + public sealed partial class HeightTraitBlacklistComponent : Component + { } +} diff --git a/Resources/Prototypes/Corvax/Traits/categories.yml b/Resources/Prototypes/Corvax/Traits/categories.yml index dcf024361bd..7883b85cfe7 100644 --- a/Resources/Prototypes/Corvax/Traits/categories.yml +++ b/Resources/Prototypes/Corvax/Traits/categories.yml @@ -1,4 +1,4 @@ -- type: traitCategory # Corvax-Next - id: SizeTraits +- type: traitCategory + id: HeightTraits name: Рост maxTraitPoints: 1 \ No newline at end of file diff --git a/Resources/Prototypes/Corvax/Traits/height.yml b/Resources/Prototypes/Corvax/Traits/height.yml new file mode 100644 index 00000000000..97e579d79df --- /dev/null +++ b/Resources/Prototypes/Corvax/Traits/height.yml @@ -0,0 +1,25 @@ +- type: trait + id: Tall + name: Высокий + description: Станьте большой дылдой. + category: HeightTraits + cost: 1 + blacklist: + components: + - HeightTraitBlacklist + components: + - type: Height + tall: true + +- type: trait + id: Short + name: Низкий + description: Ваш персонаж маленького роста. + category: HeightTraits + cost: 1 + blacklist: + components: + - HeightTraitBlacklist + components: + - type: Height + short: true \ No newline at end of file diff --git a/Resources/Prototypes/Corvax/Traits/sizeattribute.yml b/Resources/Prototypes/Corvax/Traits/sizeattribute.yml deleted file mode 100644 index dd6f941623d..00000000000 --- a/Resources/Prototypes/Corvax/Traits/sizeattribute.yml +++ /dev/null @@ -1,31 +0,0 @@ -- type: trait # Corvax-Next - id: Tall - name: Высокий - description: У вас проблемы с гигантизмом. - category: SizeTraits - cost: 1 - whitelist: - components: - - SizeAttributeWhitelist - blacklist: - components: - - SizeAttribute - components: - - type: SizeAttribute - tall: true - -- type: trait - id: Short - name: Низкий - description: Вы коротковаты ростом. - category: SizeTraits - cost: 1 - whitelist: - components: - - SizeAttributeWhitelist - blacklist: - components: - - SizeAttribute - components: - - type: SizeAttribute - short: true \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index 972967ff0d3..cbe09c29ad9 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -211,11 +211,6 @@ - CanPilot - FootstepSound - DoorBumpOpener - - type: SizeAttributeWhitelist # corvax-next - tall: true - tallscale: 1.1 - short: true - shortscale: 0.90 - type: entity save: false diff --git a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml index 98c05dd5599..26a6a918d02 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml @@ -63,9 +63,7 @@ 32: sprite: Mobs/Species/Human/displacement.rsi state: jumpsuit-female - - type: SizeAttributeWhitelist # corvax-next - tall: false - short: false + - type: HeightTraitBlacklist # Corvax-Next - type: entity parent: BaseSpeciesDummy From 21fc49cbdd82e36d6d63b95988503b14fbc6df44 Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Fri, 22 Nov 2024 16:37:37 +0700 Subject: [PATCH 4/7] revert "Remade PR" --- Content.Server/Cloning/CloningSystem.cs | 15 ++++ .../Traits/Assorted/HeightComponent.cs | 16 ---- .../Traits/Assorted/HeightSystem.cs | 63 -------------- .../Traits/Assorted/SizeAttributeComponent.cs | 16 ++++ .../Traits/Assorted/SizeAttributeSystem.cs | 83 +++++++++++++++++++ .../SizeAttributeWhitelistComponent.cs | 23 +++++ .../Assorted/HeightTraitBlacklistComponent.cs | 6 -- .../Cloning/ITransferredByCloning.cs | 9 ++ .../ru-RU/_corvaxnext/traits/traits.ftl | 7 ++ .../Prototypes/Corvax/Traits/categories.yml | 4 - Resources/Prototypes/Corvax/Traits/height.yml | 25 ------ .../Prototypes/Entities/Mobs/Species/base.yml | 5 ++ .../Entities/Mobs/Species/dwarf.yml | 4 +- .../_CorvaxNext/Traits/categories.yml | 4 + .../_CorvaxNext/Traits/sizeattribute.yml | 31 +++++++ 15 files changed, 196 insertions(+), 115 deletions(-) delete mode 100644 Content.Server/Traits/Assorted/HeightComponent.cs delete mode 100644 Content.Server/Traits/Assorted/HeightSystem.cs create mode 100644 Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeComponent.cs create mode 100644 Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeSystem.cs create mode 100644 Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeWhitelistComponent.cs delete mode 100644 Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs create mode 100644 Content.Shared/_CorvaxNext/Cloning/ITransferredByCloning.cs create mode 100644 Resources/Locale/ru-RU/_corvaxnext/traits/traits.ftl delete mode 100644 Resources/Prototypes/Corvax/Traits/categories.yml delete mode 100644 Resources/Prototypes/Corvax/Traits/height.yml create mode 100644 Resources/Prototypes/_CorvaxNext/Traits/categories.yml create mode 100644 Resources/Prototypes/_CorvaxNext/Traits/sizeattribute.yml diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 3893f31d25d..8c65bdc5f95 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -33,6 +33,7 @@ using Robust.Shared.Physics.Components; using Robust.Shared.Prototypes; using Robust.Shared.Random; +using Robust.Shared.Serialization.Manager; namespace Content.Server.Cloning { @@ -61,6 +62,8 @@ public sealed class CloningSystem : EntitySystem [Dependency] private readonly MetaDataSystem _metaSystem = default!; [Dependency] private readonly SharedJobSystem _jobs = default!; + [Dependency] private readonly ISerializationManager _serialization = default!; // Corvax-Next + public readonly Dictionary ClonesWaitingForMind = new(); public const float EasyModeCloningCost = 0.7f; @@ -213,6 +216,18 @@ public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Entity(InitComponent); - } - - private void InitComponent(EntityUid uid, HeightComponent component, ComponentStartup args) - { - if (TryComp(uid, out var comp)) - return; - - if (component.Short) - { - Scale(uid, component.ShortScale); - } - else if (component.Tall) - { - Scale(uid, component.TallScale); - } - - - } - private void Scale(EntityUid uid, float scale) - { - var physics = _entityManager.System(); - var appearance = _entityManager.System(); - - _entityManager.EnsureComponent(uid); - - var appearanceComponent = _entityManager.EnsureComponent(uid); - if (!appearance.TryGetData(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) - oldScale = Vector2.One; - - appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); - - if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager)) - { - foreach (var (id, fixture) in manager.Fixtures) - { - switch (fixture.Shape) - { - case PhysShapeCircle circle: - physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); - break; - default: - throw new NotImplementedException(); - } - } - } - } - } -} diff --git a/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeComponent.cs b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeComponent.cs new file mode 100644 index 00000000000..e5f714ab380 --- /dev/null +++ b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeComponent.cs @@ -0,0 +1,16 @@ +using Content.Shared.Cloning; + +namespace Content.Server.Next.Traits.Assorted +{ + [RegisterComponent] + public sealed partial class SizeAttributeComponent : Component, ITransferredByCloning + { + [ViewVariables(VVAccess.ReadOnly)] + [DataField] + public bool Short = false; + + [ViewVariables(VVAccess.ReadOnly)] + [DataField] + public bool Tall = false; + } +} diff --git a/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeSystem.cs b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeSystem.cs new file mode 100644 index 00000000000..727b00e5ca3 --- /dev/null +++ b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeSystem.cs @@ -0,0 +1,83 @@ +using Robust.Server.GameObjects; +using Robust.Shared.Physics; +using Robust.Shared.Physics.Collision.Shapes; +using Robust.Shared.Physics.Systems; +using System.Numerics; + +namespace Content.Server.Next.Traits.Assorted +{ + public sealed class SizeAttributeSystem : EntitySystem + { + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly AppearanceSystem _appearance = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnComponentInit); + SubscribeLocalEvent(OnComponentShutdown); + } + private void OnComponentShutdown(EntityUid uid, SizeAttributeComponent component, ComponentShutdown args) + { + if (!TryComp(uid, out var whitelist)) + return; + + if (whitelist.Tall && component.Tall) + { + Scale(uid, component, 1 / whitelist.TallScale); + } + else if (whitelist.Short && component.Short) + { + Scale(uid, component, 1 / whitelist.ShortScale); + } + + RemComp(uid); + } + private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args) + { + if (!TryComp(uid, out var whitelist)) + return; + + if (whitelist.Tall && component.Tall) + { + Scale(uid, component, Math.Max(1, whitelist.TallScale)); + } + else if (whitelist.Short && component.Short) + { + Scale(uid, component, Math.Max(Math.Min(1, whitelist.ShortScale), 0)); + } + } + + private void Scale(EntityUid uid, SizeAttributeComponent component, float scale) + { + if (scale <= 0f) + return; + + EnsureComp(uid); + + var appearanceComponent = _entityManager.EnsureComponent(uid); + if (!_appearance.TryGetData(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) + oldScale = Vector2.One; + + _appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); + + if (TryComp(uid, out FixturesComponent? manager)) + { + foreach (var (id, fixture) in manager.Fixtures) + { + if (!fixture.Hard || fixture.Density <= 1f) + continue; // This will skip the flammable fixture and any other fixture that is not supposed to contribute to mass + + switch (fixture.Shape) + { + case PhysShapeCircle circle: + _physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); + break; + default: + break; + } + } + } + } + } +} diff --git a/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeWhitelistComponent.cs b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeWhitelistComponent.cs new file mode 100644 index 00000000000..0cc83e73efe --- /dev/null +++ b/Content.Server/_CorvaxNext/Traits/Assorted/SizeAttributeWhitelistComponent.cs @@ -0,0 +1,23 @@ +namespace Content.Server.Next.Traits.Assorted +{ + [RegisterComponent] + public sealed partial class SizeAttributeWhitelistComponent : Component + { + [ViewVariables(VVAccess.ReadOnly)] + [DataField("short")] + public bool Short = false; + + [ViewVariables(VVAccess.ReadOnly)] + [DataField("shortscale")] + public float ShortScale = 0f; + + [ViewVariables(VVAccess.ReadOnly)] + [DataField("tall")] + public bool Tall = false; + + [ViewVariables(VVAccess.ReadOnly)] + [DataField("tallscale")] + public float TallScale = 0f; + + } +} diff --git a/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs b/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs deleted file mode 100644 index 172d3fed72a..00000000000 --- a/Content.Shared/Traits/Assorted/HeightTraitBlacklistComponent.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Content.Server.Traits.Assorted -{ - [RegisterComponent] - public sealed partial class HeightTraitBlacklistComponent : Component - { } -} diff --git a/Content.Shared/_CorvaxNext/Cloning/ITransferredByCloning.cs b/Content.Shared/_CorvaxNext/Cloning/ITransferredByCloning.cs new file mode 100644 index 00000000000..d2504c4c67f --- /dev/null +++ b/Content.Shared/_CorvaxNext/Cloning/ITransferredByCloning.cs @@ -0,0 +1,9 @@ +namespace Content.Shared.Cloning +{ + /// + /// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner) + /// + public interface ITransferredByCloning + { + } +} diff --git a/Resources/Locale/ru-RU/_corvaxnext/traits/traits.ftl b/Resources/Locale/ru-RU/_corvaxnext/traits/traits.ftl new file mode 100644 index 00000000000..d08795b0082 --- /dev/null +++ b/Resources/Locale/ru-RU/_corvaxnext/traits/traits.ftl @@ -0,0 +1,7 @@ +trait-category-sizetraits = Рост + +trait-tall-name = Высокий +trait-tall-desc = У вас проблемы с гигантизмом. + +trait-short-name = Низкий +trait-short-desc = Вы коротковаты ростом. \ No newline at end of file diff --git a/Resources/Prototypes/Corvax/Traits/categories.yml b/Resources/Prototypes/Corvax/Traits/categories.yml deleted file mode 100644 index 7883b85cfe7..00000000000 --- a/Resources/Prototypes/Corvax/Traits/categories.yml +++ /dev/null @@ -1,4 +0,0 @@ -- type: traitCategory - id: HeightTraits - name: Рост - maxTraitPoints: 1 \ No newline at end of file diff --git a/Resources/Prototypes/Corvax/Traits/height.yml b/Resources/Prototypes/Corvax/Traits/height.yml deleted file mode 100644 index 97e579d79df..00000000000 --- a/Resources/Prototypes/Corvax/Traits/height.yml +++ /dev/null @@ -1,25 +0,0 @@ -- type: trait - id: Tall - name: Высокий - description: Станьте большой дылдой. - category: HeightTraits - cost: 1 - blacklist: - components: - - HeightTraitBlacklist - components: - - type: Height - tall: true - -- type: trait - id: Short - name: Низкий - description: Ваш персонаж маленького роста. - category: HeightTraits - cost: 1 - blacklist: - components: - - HeightTraitBlacklist - components: - - type: Height - short: true \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml index cbe09c29ad9..330f56150b7 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/base.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml @@ -211,6 +211,11 @@ - CanPilot - FootstepSound - DoorBumpOpener + - type: SizeAttributeWhitelist # Corvax-Next + tall: true + tallscale: 1.1 + short: true + shortscale: 0.90 - type: entity save: false diff --git a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml index 26a6a918d02..43753502536 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml @@ -63,7 +63,9 @@ 32: sprite: Mobs/Species/Human/displacement.rsi state: jumpsuit-female - - type: HeightTraitBlacklist # Corvax-Next + - type: SizeAttributeWhitelist # Corvax-Next + tall: false + short: false - type: entity parent: BaseSpeciesDummy diff --git a/Resources/Prototypes/_CorvaxNext/Traits/categories.yml b/Resources/Prototypes/_CorvaxNext/Traits/categories.yml new file mode 100644 index 00000000000..5cb52585309 --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Traits/categories.yml @@ -0,0 +1,4 @@ +- type: traitCategory + id: SizeTraits + name: trait-category-sizetraits + maxTraitPoints: 1 \ No newline at end of file diff --git a/Resources/Prototypes/_CorvaxNext/Traits/sizeattribute.yml b/Resources/Prototypes/_CorvaxNext/Traits/sizeattribute.yml new file mode 100644 index 00000000000..ea0e4cffd4a --- /dev/null +++ b/Resources/Prototypes/_CorvaxNext/Traits/sizeattribute.yml @@ -0,0 +1,31 @@ +- type: trait + id: Tall + name: trait-tall-name + description: trait-tall-desc + category: SizeTraits + cost: 1 + whitelist: + components: + - SizeAttributeWhitelist + blacklist: + components: + - SizeAttribute + components: + - type: SizeAttribute + tall: true + +- type: trait + id: Short + name: trait-short-name + description: trait-short-desc + category: SizeTraits + cost: 1 + whitelist: + components: + - SizeAttributeWhitelist + blacklist: + components: + - SizeAttribute + components: + - type: SizeAttribute + short: true \ No newline at end of file From d72df8367e4dd772eb665861f347174ffcf469a8 Mon Sep 17 00:00:00 2001 From: KillanGenifer <157119956+KillanGenifer@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:43:45 +0700 Subject: [PATCH 5/7] =?UTF-8?q?=D0=BB=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2?= =?UTF-8?q?=20Resources/Prototypes/Traits/categories.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Prototypes/Traits/categories.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Resources/Prototypes/Traits/categories.yml diff --git a/Resources/Prototypes/Traits/categories.yml b/Resources/Prototypes/Traits/categories.yml deleted file mode 100644 index 114e115b8a4..00000000000 --- a/Resources/Prototypes/Traits/categories.yml +++ /dev/null @@ -1,12 +0,0 @@ -- type: traitCategory - id: Disabilities - name: trait-category-disabilities - -- type: traitCategory - id: SpeechTraits - name: trait-category-speech - maxTraitPoints: 2 - -- type: traitCategory - id: Quirks - name: trait-category-quirks \ No newline at end of file From 634a28a650de5c1d98f86bbdab5e2aae28794855 Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Fri, 22 Nov 2024 16:47:12 +0700 Subject: [PATCH 6/7] daun --- Resources/Prototypes/Traits/categories.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Resources/Prototypes/Traits/categories.yml diff --git a/Resources/Prototypes/Traits/categories.yml b/Resources/Prototypes/Traits/categories.yml new file mode 100644 index 00000000000..114e115b8a4 --- /dev/null +++ b/Resources/Prototypes/Traits/categories.yml @@ -0,0 +1,12 @@ +- type: traitCategory + id: Disabilities + name: trait-category-disabilities + +- type: traitCategory + id: SpeechTraits + name: trait-category-speech + maxTraitPoints: 2 + +- type: traitCategory + id: Quirks + name: trait-category-quirks \ No newline at end of file From b6634f3a2586d27b9c26c0f2feb9375abb752a01 Mon Sep 17 00:00:00 2001 From: KillanGenifer Date: Mon, 25 Nov 2024 17:47:58 +0700 Subject: [PATCH 7/7] fix --- Resources/Prototypes/Entities/Mobs/Species/dwarf.yml | 1 - Resources/Prototypes/Traits/categories.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml index 5646e12b67a..ec0b067eba6 100644 --- a/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml +++ b/Resources/Prototypes/Entities/Mobs/Species/dwarf.yml @@ -70,7 +70,6 @@ leftBarePrint: "footprint-left-bare-dwarf" rightBarePrint: "footprint-right-bare-dwarf" - - type: entity parent: BaseSpeciesDummy id: MobDwarfDummy diff --git a/Resources/Prototypes/Traits/categories.yml b/Resources/Prototypes/Traits/categories.yml index 114e115b8a4..d024b3fcff3 100644 --- a/Resources/Prototypes/Traits/categories.yml +++ b/Resources/Prototypes/Traits/categories.yml @@ -9,4 +9,4 @@ - type: traitCategory id: Quirks - name: trait-category-quirks \ No newline at end of file + name: trait-category-quirks