-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port frontier station 14's sizeattribute system #965
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Content.Server._NF.Cloning; | ||
|
||
/// <summary> | ||
/// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner) | ||
/// </summary> | ||
public interface ITransferredByCloning | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Content.Server._NF.Cloning; | ||
|
||
namespace Content.Server._NF.SizeAttribute | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class SizeAttributeComponent : Component, ITransferredByCloning | ||
{ | ||
[DataField("short")] | ||
public bool Short = false; | ||
|
||
[DataField("tall")] | ||
public bool Tall = false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System.Numerics; | ||
using Content.Server.SizeAttribute; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Collision.Shapes; | ||
using Robust.Shared.Physics.Systems; | ||
using Content.Shared.Item.PseudoItem; | ||
using Content.Shared.Nyanotrasen.Item.PseudoItem; | ||
|
||
namespace Content.Server._NF.SizeAttribute | ||
{ | ||
public sealed class SizeAttributeSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
[Dependency] private readonly AppearanceSystem _appearance = default!; | ||
[Dependency] private readonly FixtureSystem _fixtures = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<SizeAttributeComponent, ComponentInit>(OnComponentInit); | ||
} | ||
|
||
private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args) | ||
{ | ||
if (!TryComp<SizeAttributeWhitelistComponent>(uid, out var whitelist)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since by introducing this system to Metempsychosis means having the possibility for entities to be handed a SizeAttribute after character creation, you now need to account for SizeAttribute being handed to an entity that potentially doesn't have SizeAttributeWhitelist. Since we're exiting out if a species isn't whitelisted for SizeAttribute, you might as well cleanup by RemComping the component if for whatever reason it was handed to a species lacking the whitelist. That will also be useful if for example someone hits AddComponent in VV without first doing so with SizeAttributeWhitelist. |
||
return; | ||
|
||
if (whitelist.Tall && component.Tall) | ||
{ | ||
Scale(uid, component, whitelist.TallScale, whitelist.TallDensity, whitelist.TallCosmeticOnly); | ||
PseudoItem(uid, component, whitelist.TallPseudoItem); | ||
} | ||
else if (whitelist.Short && component.Short) | ||
{ | ||
Scale(uid, component, whitelist.ShortScale, whitelist.ShortDensity, whitelist.ShortCosmeticOnly); | ||
// deltav: added PseudoItemShape | ||
PseudoItem(uid, component, whitelist.ShortPseudoItem, whitelist.PseudoItemShape); | ||
} | ||
} | ||
|
||
// deltav: added a shape argument and refactored the method | ||
private void PseudoItem(EntityUid uid, SizeAttributeComponent component, bool active, List<Box2i>? shape = null) | ||
{ | ||
if (active) | ||
{ | ||
var pseudoItem = EnsureComp<PseudoItemComponent>(uid); | ||
pseudoItem.Shape = shape; | ||
} | ||
else | ||
{ | ||
if (!TryComp<PseudoItemComponent>(uid, out var pseudoI)) | ||
return; | ||
RemComp(uid, pseudoI); | ||
} | ||
} | ||
|
||
private void Scale(EntityUid uid, SizeAttributeComponent component, float scale, float density, bool cosmeticOnly) | ||
{ | ||
if (scale <= 0f && density <= 0f) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would probably be better to do Alternatively you could put in a check for if scale is a negative number, and then set it to *= -1 to get a natural number again. |
||
return; | ||
|
||
_entityManager.EnsureComponent<ScaleVisualsComponent>(uid); | ||
|
||
var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid); | ||
if (!_appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) | ||
oldScale = Vector2.One; | ||
|
||
_appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); | ||
|
||
if (!cosmeticOnly && _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(); | ||
} | ||
|
||
_physics.SetDensity(uid, id, fixture, density); | ||
} | ||
} | ||
} | ||
} | ||
|
||
[ByRefEvent] | ||
public readonly record struct ScaleEntityEvent(EntityUid Uid) { } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Robust.Shared.Physics.Collision.Shapes; | ||
|
||
namespace Content.Server.SizeAttribute | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class SizeAttributeWhitelistComponent : Component | ||
{ | ||
// Short | ||
[DataField("short")] | ||
public bool Short = false; | ||
|
||
[DataField("shortscale")] | ||
public float ShortScale = 0f; | ||
|
||
[DataField("shortDensity")] | ||
public float ShortDensity = 0f; | ||
|
||
[DataField("shortPseudoItem")] | ||
public bool ShortPseudoItem = false; | ||
|
||
[DataField("shortCosmeticOnly")] | ||
public bool ShortCosmeticOnly = true; | ||
|
||
// Delta-v: added custom pseudo-item shape | ||
/// <summary> | ||
/// An optional override for the shape of the item within the grid storage. | ||
/// If null, a default shape will be used based on <see cref="Size"/>. | ||
/// </summary> | ||
[DataField("pseudoItemShape")] | ||
public List<Box2i>? PseudoItemShape; | ||
|
||
// Tall | ||
[DataField("tall")] | ||
public bool Tall = false; | ||
|
||
[DataField("tallscale")] | ||
public float TallScale = 0f; | ||
|
||
[DataField("tallDensity")] | ||
public float TallDensity = 0f; | ||
|
||
[DataField("tallPseudoItem")] | ||
public bool TallPseudoItem = false; | ||
|
||
[DataField("tallCosmeticOnly")] | ||
public bool TallCosmeticOnly = true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,6 +97,16 @@ | |
Female: FemaleVulpkanin | ||
Unsexed: MaleVulpkanin | ||
- type: DogVision | ||
- type: SizeAttributeWhitelist # Frontier - tall/short traits | ||
short: true | ||
shortscale: 0.8 | ||
shortDensity: 140 | ||
shortPseudoItem: true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Felinid mains are going to be upset when they find out Smol dogs have their gimmick too LOL. If you're going to do this to Vulps, you might as well do this to Harpies too. |
||
shortCosmeticOnly: false | ||
pseudoItemShape: # Delta-v - custom pseudo-item shape | ||
- 0,0,1,4 | ||
- 0,2,3,4 | ||
- 4,0,5,4 | ||
|
||
- type: entity | ||
save: false | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
- type: trait | ||
id: Tall | ||
name: Tall | ||
whitelist: | ||
components: | ||
- SizeAttributeWhitelist | ||
blacklist: | ||
components: | ||
- SizeAttribute | ||
components: | ||
- type: SizeAttribute | ||
tall: true | ||
|
||
- type: trait | ||
id: Short | ||
name: Short | ||
whitelist: | ||
components: | ||
- SizeAttributeWhitelist | ||
blacklist: | ||
components: | ||
- SizeAttribute | ||
components: | ||
- type: SizeAttribute | ||
short: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need you to move "Transfer of Special Components" down into the FetchAndSpawnMob function, and then split it into two different conditions. We don't actually have Wizden cloning, we instead have a hybrid system that handles both Cloning and Metempsychosis based on checking for a bool. By placing this function up here, you are essentially making it so that when someone is reincarnated into a new body by the Metem machine, it transfers their tallness/shortness from old body to new body. Which is a big problem if for example their old body was a small vulpkanin and the new body is an Oni.
This instead needs to be done only if the entity was cloned and not reincarnated. If they are instead reincarnated, an alternative behavior needs to be performed where it has a random chance of giving them the tallness/shortness(I would say at most 10% tall, 10% short, 80% normal).