-
Notifications
You must be signed in to change notification settings - Fork 12
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
Revert "Revert "Upstreams"" #577
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 |
---|---|---|
@@ -1,20 +1,83 @@ | ||
using Content.Shared.Body.Systems; | ||
using Content.Shared.Body.Part; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Humanoid.Markings; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Utility; | ||
using Content.Shared.Body.Components; | ||
|
||
namespace Content.Client.Body.Systems; | ||
|
||
public sealed class BodySystem : SharedBodySystem | ||
{ | ||
protected override void UpdateAppearance(EntityUid uid, BodyPartAppearanceComponent component) | ||
[Dependency] private readonly MarkingManager _markingManager = default!; | ||
|
||
private void ApplyMarkingToPart(MarkingPrototype markingPrototype, | ||
IReadOnlyList<Color>? colors, | ||
bool visible, | ||
SpriteComponent sprite) | ||
{ | ||
for (var j = 0; j < markingPrototype.Sprites.Count; j++) | ||
{ | ||
var markingSprite = markingPrototype.Sprites[j]; | ||
|
||
if (markingSprite is not SpriteSpecifier.Rsi rsi) | ||
{ | ||
continue; | ||
} | ||
|
||
var layerId = $"{markingPrototype.ID}-{rsi.RsiState}"; | ||
|
||
if (!sprite.LayerMapTryGet(layerId, out _)) | ||
{ | ||
var layer = sprite.AddLayer(markingSprite, j + 1); | ||
sprite.LayerMapSet(layerId, layer); | ||
sprite.LayerSetSprite(layerId, rsi); | ||
} | ||
|
||
sprite.LayerSetVisible(layerId, visible); | ||
|
||
if (!visible) | ||
{ | ||
continue; | ||
} | ||
|
||
// Okay so if the marking prototype is modified but we load old marking data this may no longer be valid | ||
// and we need to check the index is correct. | ||
// So if that happens just default to white? | ||
if (colors != null && j < colors.Count) | ||
{ | ||
sprite.LayerSetColor(layerId, colors[j]); | ||
} | ||
else | ||
{ | ||
sprite.LayerSetColor(layerId, Color.White); | ||
} | ||
} | ||
} | ||
|
||
protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceComponent component) | ||
{ | ||
if (TryComp(uid, out SpriteComponent? sprite)) | ||
if (!TryComp(target, out SpriteComponent? sprite)) | ||
return; | ||
|
||
if (component.Color != null) | ||
sprite.Color = component.Color.Value; | ||
|
||
foreach (var (visualLayer, markingList) in component.Markings) | ||
{ | ||
if (component.Color != null) | ||
foreach (var marking in markingList) | ||
{ | ||
//TODO a few things need to be adjusted before this is ready to be used - also need to find a way to update the player sprite | ||
//sprite.Color = component.Color.Value; | ||
if (!_markingManager.TryGetMarking(marking, out var markingPrototype)) | ||
continue; | ||
|
||
ApplyMarkingToPart(markingPrototype, marking.MarkingColors, marking.Visible, sprite); | ||
} | ||
} | ||
} | ||
|
||
protected override void RemovePartMarkings(EntityUid target, BodyPartAppearanceComponent partAppearance, HumanoidAppearanceComponent bodyAppearance) | ||
{ | ||
return; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -5,6 +5,7 @@ | |||||||||
using Content.Shared.Body.Part; | ||||||||||
using Content.Shared.Body.Systems; | ||||||||||
using Content.Shared.Damage; | ||||||||||
using Content.Shared.Gibbing.Events; | ||||||||||
using Content.Shared.Humanoid; | ||||||||||
using Content.Shared.Mind; | ||||||||||
using Content.Shared.Mobs.Systems; | ||||||||||
|
@@ -108,7 +109,9 @@ public override HashSet<EntityUid> GibBody( | |||||||||
Vector2? splatDirection = null, | ||||||||||
float splatModifier = 1, | ||||||||||
Angle splatCone = default, | ||||||||||
SoundSpecifier? gibSoundOverride = null) | ||||||||||
SoundSpecifier? gibSoundOverride = null, | ||||||||||
GibType gib = GibType.Gib, | ||||||||||
GibContentsOption contents = GibContentsOption.Drop) | ||||||||||
{ | ||||||||||
if (!Resolve(bodyId, ref body, logMissing: false) | ||||||||||
|| TerminatingOrDeleted(bodyId) | ||||||||||
|
@@ -122,7 +125,8 @@ public override HashSet<EntityUid> GibBody( | |||||||||
return new HashSet<EntityUid>(); | ||||||||||
|
||||||||||
var gibs = base.GibBody(bodyId, gibOrgans, body, launchGibs: launchGibs, | ||||||||||
splatDirection: splatDirection, splatModifier: splatModifier, splatCone: splatCone); | ||||||||||
splatDirection: splatDirection, splatModifier: splatModifier, splatCone: splatCone, | ||||||||||
gib: gib, contents: contents); | ||||||||||
|
||||||||||
var ev = new BeingGibbedEvent(gibs); | ||||||||||
RaiseLocalEvent(bodyId, ref ev); | ||||||||||
|
@@ -164,9 +168,27 @@ public override HashSet<EntityUid> GibPart( | |||||||||
} | ||||||||||
|
||||||||||
// start-backmen: surgery | ||||||||||
protected override void UpdateAppearance(EntityUid uid, BodyPartAppearanceComponent component) | ||||||||||
/*protected override void UpdateAppearance(EntityUid uid, BodyPartAppearanceComponent component) | ||||||||||
{ | ||||||||||
return; | ||||||||||
}*/ | ||||||||||
Comment on lines
+171
to
+174
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. 🛠️ Refactor suggestion Удалите закомментированный код Вместо комментирования метода - /*protected override void UpdateAppearance(EntityUid uid, BodyPartAppearanceComponent component)
- {
- return;
- }*/ 📝 Committable suggestion
Suggested change
|
||||||||||
|
||||||||||
protected override void ApplyPartMarkings(EntityUid target, BodyPartAppearanceComponent component) | ||||||||||
{ | ||||||||||
return; | ||||||||||
} | ||||||||||
Comment on lines
+176
to
+179
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. Реализуйте метод ApplyPartMarkings Пустая реализация метода Нужна помощь в реализации этого метода? |
||||||||||
|
||||||||||
protected override void RemovePartMarkings(EntityUid target, BodyPartAppearanceComponent partAppearance, HumanoidAppearanceComponent bodyAppearance) | ||||||||||
{ | ||||||||||
foreach (var (visualLayer, markingList) in partAppearance.Markings) | ||||||||||
{ | ||||||||||
foreach (var marking in markingList) | ||||||||||
{ | ||||||||||
_humanoidSystem.RemoveMarking(target, marking.MarkingId, sync: false, humanoid: bodyAppearance); | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
Dirty(target, bodyAppearance); | ||||||||||
} | ||||||||||
// end-backmen: surgery | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,45 @@ | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Humanoid.Prototypes; | ||
using Content.Shared.Humanoid.Markings; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
using Robust.Shared.GameStates; | ||
|
||
namespace Content.Shared.Body.Part; | ||
|
||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)] | ||
public sealed partial class BodyPartAppearanceComponent : Component | ||
{ | ||
/// <summary> | ||
/// HumanoidVisualLayer type for this body part. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public HumanoidVisualLayers Type { get; set; } | ||
|
||
/// <summary> | ||
/// Relevant markings for this body part that will be applied on attachment. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public Dictionary<HumanoidVisualLayers, List<Marking>> Markings = new(); | ||
|
||
/// <summary> | ||
/// ID of this custom base layer. Must be a <see cref="HumanoidSpeciesSpriteLayer"/>. | ||
/// </summary> | ||
[DataField("id", customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidSpeciesSpriteLayer>)), AutoNetworkedField] | ||
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<HumanoidSpeciesSpriteLayer>)), AutoNetworkedField] | ||
public string? ID { get; set; } | ||
|
||
/// <summary> | ||
/// Color of this custom base layer. Null implies skin colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin. | ||
/// </summary> | ||
[DataField("color"), AutoNetworkedField] | ||
[DataField, AutoNetworkedField] | ||
public Color? Color { get; set; } | ||
|
||
[DataField("originalBody"), AutoNetworkedField] | ||
/// <summary> | ||
/// Color of this custom base eye layer. Null implies eye colour if the corresponding <see cref="HumanoidSpeciesSpriteLayer"/> is set to match skin. | ||
/// </summary> | ||
[DataField, AutoNetworkedField] | ||
public Color? EyeColor { get; set; } | ||
Comment on lines
+36
to
+40
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. 🛠️ Refactor suggestion Добавление EyeColor требует синхронизации с существующим Color. Новое свойство Предлагаю создать вспомогательный метод для обработки цветов различных частей тела. |
||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid? OriginalBody { get; set; } | ||
|
||
//TODO add other custom variables such as species and markings - in case someone decides to attach a lizard arm to a human for example | ||
|
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.
Реализуйте метод
RemovePartMarkings
или удалите его переопределениеМетод
RemovePartMarkings
переопределен, но содержит только пустойreturn;
, не выполняя никакой логики. Если метод необходим, следует реализовать его функциональность. Если нет, можно удалить его переопределение, чтобы избежать потенциальной путаницы.