-
Notifications
You must be signed in to change notification settings - Fork 110
Pullable Helmet. Ивентовый Контент. Механика Забрала. H/M #566
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
base: develop
Are you sure you want to change the base?
Changes from 1 commit
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,43 @@ | ||
| using Content.Shared.Storage; | ||
| using Robust.Shared.Audio; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.GameStates; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
| using Content.Shared.Inventory; | ||
| namespace Content.Server.Imperial.HamMaggotson.PullableHelmet.Components; | ||
|
|
||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class PullableHelmetComponent : Component | ||
| { | ||
| [DataField("toggledPrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
| public string ToggledPrototype = string.Empty; | ||
|
|
||
| [DataField("untoggledPrototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
| [AutoNetworkedField] | ||
| public string UntoggledPrototype = string.Empty; | ||
|
|
||
| [DataField("toggled"), AutoNetworkedField] | ||
| public bool Toggled = false; | ||
| [DataField] | ||
| public SlotFlags? Slot; | ||
| [DataField("requiredSlot")] | ||
| public SlotFlags RequiredFlags = SlotFlags.HEAD; | ||
| [DataField] | ||
| public LocId PullDownText = "pulldownhelmet-verb"; | ||
|
|
||
| [DataField] | ||
| public LocId PullUpText = "pulluphelmet-verb"; | ||
| [DataField] | ||
| public TimeSpan Delay = TimeSpan.FromSeconds(2); | ||
| [DataField] | ||
| public SoundSpecifier PullUpSound { get; set; } = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pullup.ogg"); | ||
| [DataField] | ||
| public SoundSpecifier PullDownSound { get; set; } = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pulldown.ogg"); | ||
|
Comment on lines
+34
to
+37
Contributor
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. 🧹 Nitpick | 🔵 Trivial Несогласованность: свойства с
Исправление [DataField]
- public SoundSpecifier PullUpSound { get; set; } = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pullup.ogg");
+ public SoundSpecifier PullUpSound = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pullup.ogg");
[DataField]
- public SoundSpecifier PullDownSound { get; set; } = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pulldown.ogg");
+ public SoundSpecifier PullDownSound = new SoundPathSpecifier("/Audio/Imperial/HamMaggotson/helmet_pulldown.ogg");🤖 Prompt for AI Agents |
||
| [DataField] | ||
| public EntProtoId PullAction = "ToggleK63Helmet"; | ||
|
|
||
| [DataField] | ||
| public EntityUid? Action; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| using Content.Shared.Clothing.Components; | ||
| using Content.Shared.Foldable; | ||
| using Content.Shared.Inventory; | ||
| using Content.Shared.Item; | ||
| using Content.Shared.Clothing.EntitySystems; | ||
| using Content.Shared.Verbs; | ||
| using Content.Server.Imperial.HamMaggotson.PullableHelmet.Components; | ||
| using Content.Shared.Popups; | ||
| using Content.Shared.DoAfter; | ||
| using Robust.Shared.Containers; | ||
| using Content.Shared.Imperial.HamMaggotson.PullableHelmet; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Content.Shared.Actions; | ||
| namespace Content.Server.Imperial.HamMaggotson.PullableHelmet.Systems; | ||
|
|
||
| public sealed class PullableHelmetSystem : EntitySystem | ||
| { | ||
| [Dependency] private readonly ClothingSystem _clothingSystem = default!; | ||
| [Dependency] private readonly SharedContainerSystem _container = default!; | ||
| [Dependency] private readonly InventorySystem _inventory = default!; | ||
| [Dependency] private readonly SharedItemSystem _itemSystem = default!; | ||
| [Dependency] private readonly SharedPopupSystem _popup = default!; | ||
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; | ||
| [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; | ||
| [Dependency] private readonly ActionContainerSystem _actionContainer = default!; | ||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<PullableHelmetComponent, GetVerbsEvent<AlternativeVerb>>(AddPullVerb); | ||
| SubscribeLocalEvent<PullableHelmetComponent, PullHelmetDoAfterEvent>(TryToggleHelmet); | ||
| SubscribeLocalEvent<PullableHelmetComponent, PullHelmetActionEvent>(TryStartDoAfter); | ||
| SubscribeLocalEvent<PullableHelmetComponent, MapInitEvent>(OnMapInit); | ||
| SubscribeLocalEvent<PullableHelmetComponent, GetItemActionsEvent>(OnGetActions); | ||
| } | ||
|
|
||
| private void AddPullVerb(EntityUid uid, PullableHelmetComponent component, GetVerbsEvent<AlternativeVerb> args) | ||
| { | ||
| if (!args.CanAccess || !args.CanInteract || args.Hands == null) | ||
| return; | ||
|
|
||
| AlternativeVerb verb = new() | ||
| { | ||
| Act = () => TryStartDoAfter(args.User, (uid, component)), | ||
| Text = component.Toggled ? Loc.GetString(component.PullUpText) : Loc.GetString(component.PullDownText), | ||
| Priority = component.Toggled ? 0 : 2, | ||
| }; | ||
|
|
||
| args.Verbs.Add(verb); | ||
| } | ||
|
|
||
| private void TryStartDoAfter(EntityUid user, Entity<PullableHelmetComponent> ent) | ||
| { | ||
| _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, | ||
| user, | ||
| ent.Comp.Delay, | ||
| new PullHelmetDoAfterEvent(), | ||
| ent, | ||
| ent) | ||
| { | ||
| NeedHand = true, | ||
| }); | ||
| } | ||
|
|
||
| private void TryStartDoAfter(Entity<PullableHelmetComponent> ent, ref PullHelmetActionEvent args) | ||
| { | ||
| _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, | ||
| args.Performer, | ||
| ent.Comp.Delay, | ||
| new PullHelmetDoAfterEvent(), | ||
| ent, | ||
| ent) | ||
| { | ||
| NeedHand = true, | ||
| }); | ||
| } | ||
|
Comment on lines
+66
to
+77
Contributor
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. 🧹 Nitpick | 🔵 Trivial Дублирование логики DoAfter между двумя перегрузками Строки 53-64 и 66-77 содержат практически идентичную логику создания Рефакторинг private void TryStartDoAfter(Entity<PullableHelmetComponent> ent, ref PullHelmetActionEvent args)
{
- _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager,
- args.Performer,
- ent.Comp.Delay,
- new PullHelmetDoAfterEvent(),
- ent,
- ent)
- {
- NeedHand = true,
- });
+ TryStartDoAfter(args.Performer, ent);
}🤖 Prompt for AI Agents |
||
|
|
||
| public void TryToggleHelmet(EntityUid uid, PullableHelmetComponent component, ref PullHelmetDoAfterEvent args) | ||
| { | ||
| var user = args.User; | ||
| if (!_inventory.InSlotWithFlags(uid, component.RequiredFlags)) | ||
| return; | ||
| component.Toggled = !component.Toggled; | ||
| var newPrototype = component.Toggled ? component.ToggledPrototype : component.UntoggledPrototype; | ||
| var sound = component.Toggled ? component.PullDownSound : component.PullUpSound; | ||
| var newEntity = Spawn(newPrototype, Transform(uid).Coordinates); | ||
| if (!TryComp<PullableHelmetComponent>(newEntity, out var hlm)) | ||
| { | ||
| QueueDel(newEntity); | ||
| return; | ||
| } | ||
| hlm.Toggled = component.Toggled; | ||
| if (_inventory.TryGetContainingSlot(uid, out var slot)) | ||
| { | ||
| _inventory.TryUnequip(user, slot.Name); | ||
| _inventory.TryEquip(user, newEntity, slot.Name); | ||
| QueueDel(uid); | ||
| _audio.PlayPvs(sound, user); | ||
| } | ||
| } | ||
|
Comment on lines
+79
to
+101
Contributor
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. Критично: отсутствует проверка
Кроме того, если Также метод Предлагаемое исправление- public void TryToggleHelmet(EntityUid uid, PullableHelmetComponent component, ref PullHelmetDoAfterEvent args)
+ private void TryToggleHelmet(EntityUid uid, PullableHelmetComponent component, ref PullHelmetDoAfterEvent args)
{
+ if (args.Cancelled || args.Handled)
+ return;
+
+ args.Handled = true;
+
var user = args.User;
if (!_inventory.InSlotWithFlags(uid, component.RequiredFlags))
return;
component.Toggled = !component.Toggled;
var newPrototype = component.Toggled ? component.ToggledPrototype : component.UntoggledPrototype;
var sound = component.Toggled ? component.PullDownSound : component.PullUpSound;
var newEntity = Spawn(newPrototype, Transform(uid).Coordinates);
if (!TryComp<PullableHelmetComponent>(newEntity, out var hlm))
{
QueueDel(newEntity);
return;
}
hlm.Toggled = component.Toggled;
if (_inventory.TryGetContainingSlot(uid, out var slot))
{
- _inventory.TryUnequip(user, slot.Name);
- _inventory.TryEquip(user, newEntity, slot.Name);
- QueueDel(uid);
- _audio.PlayPvs(sound, user);
+ if (_inventory.TryUnequip(user, slot.Name) &&
+ _inventory.TryEquip(user, newEntity, slot.Name))
+ {
+ QueueDel(uid);
+ _audio.PlayPvs(sound, user);
+ }
+ else
+ {
+ QueueDel(newEntity);
+ }
+ }
+ else
+ {
+ QueueDel(newEntity);
}
}🤖 Prompt for AI Agents |
||
| private void OnGetActions(EntityUid uid, PullableHelmetComponent component, GetItemActionsEvent args) | ||
| { | ||
| if (component.Action != null | ||
| && (args.SlotFlags & component.RequiredFlags) == component.RequiredFlags) | ||
| { | ||
| args.AddAction(component.Action.Value); | ||
| } | ||
| } | ||
|
|
||
| private void OnMapInit(EntityUid uid, PullableHelmetComponent component, MapInitEvent args) | ||
| { | ||
| if (_actionContainer.EnsureAction(uid, ref component.Action, out var action, component.PullAction)) | ||
| _actionsSystem.SetEntityIcon((component.Action.Value, action), uid); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| using Content.Shared.Actions; | ||
| namespace Content.Shared.Imperial.HamMaggotson.PullableHelmet; | ||
| public sealed partial class PullHelmetActionEvent : InstantActionEvent | ||
| {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| using Content.Shared.DoAfter; | ||
| using Robust.Shared.Serialization; | ||
|
|
||
| namespace Content.Shared.Imperial.HamMaggotson.PullableHelmet; | ||
|
|
||
| [Serializable, NetSerializable] | ||
| public sealed partial class PullHelmetDoAfterEvent : SimpleDoAfterEvent; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| pulldownhelmet-verb = Опустить забрало | ||
| pulluphelmet-verb = Поднять забрало |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,9 @@ | |
| suffix: DeadSector | ||
| components: | ||
| - type: Sprite | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3.rsi | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi | ||
| - type: Clothing | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3.rsi | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi | ||
| quickEquip: true | ||
| clothingVisuals: | ||
| head: | ||
|
|
@@ -21,20 +21,125 @@ | |
| Blunt: 0.7 | ||
| Slash: 0.7 | ||
| Piercing: 0.93 | ||
| Heat: 0.93 | ||
| Shock: 0.8 | ||
| - type: ExplosionResistance | ||
| damageCoefficient: 0.7 | ||
| damageCoefficient: 0.75 | ||
| - type: HideLayerClothing | ||
| slots: | ||
| - Hair | ||
| - HeadTop | ||
| - type: PullableHelmet | ||
| untoggledPrototype: ClothingHeadHelmetK63 | ||
| toggledPrototype: ClothingHeadHelmetK63Lowered | ||
| pullAction: ToggleK63Helmet | ||
|
|
||
| - type: entity | ||
| id: ClothingHeadHelmetK63Lowered | ||
| parent: ClothingHeadHelmetK63 | ||
| name: fire helmet | ||
| categories: [ HideSpawnMenu ] | ||
| description: An atmos tech's best friend. Provides some heat resistance and looks cool. | ||
| suffix: DeadSector | ||
| components: | ||
| - type: Sprite | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi | ||
| - type: Clothing | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi | ||
| quickEquip: true | ||
| clothingVisuals: | ||
| head: | ||
| - state: on-equipped-HELMET | ||
| - type: Item | ||
| size: Normal | ||
| - type: Armor | ||
| modifiers: | ||
| coefficients: | ||
| Blunt: 0.7 | ||
| Slash: 0.7 | ||
| Piercing: 0.75 | ||
| Heat: 0.75 | ||
| Shock: 0.75 | ||
| - type: ExplosionResistance | ||
| damageCoefficient: 0.5 | ||
| - type: HideLayerClothing | ||
| slots: | ||
| - Hair | ||
| - HeadTop | ||
| - type: IngestionBlocker | ||
|
Comment on lines
+35
to
+68
Contributor
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. 🧹 Nitpick | 🔵 Trivial Избыточное дублирование компонентов в
Пример минимального определения - type: entity
id: ClothingHeadHelmetK63Lowered
parent: ClothingHeadHelmetK63
name: fire helmet
categories: [ HideSpawnMenu ]
description: An atmos tech's best friend. Provides some heat resistance and looks cool.
suffix: DeadSector
components:
- - type: Sprite
- sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi
- type: Clothing
sprite: Imperial/Clothing/Head/Helmets/k6_3_new.rsi
quickEquip: true
clothingVisuals:
head:
- state: on-equipped-HELMET
- - type: Item
- size: Normal
- type: Armor
modifiers:
coefficients:
Blunt: 0.7
Slash: 0.7
Piercing: 0.75
Heat: 0.75
Shock: 0.75
- type: ExplosionResistance
damageCoefficient: 0.5
- - type: HideLayerClothing
- slots:
- - Hair
- - HeadTop
- type: IngestionBlocker🤖 Prompt for AI Agents |
||
|
|
||
| # gloves | ||
| - type: entity | ||
| id: ToggleK63Helmet | ||
| name: Toggle ninja gloves | ||
| description: Toggles all glove actions on left click. Includes your doorjack, draining power, stunning enemies and hacking certain computers. | ||
| components: | ||
| - type: InstantAction | ||
| event: !type:ToggleActionEvent {} | ||
| event: !type:PullHelmetActionEvent | ||
| - type: Action | ||
| itemIconStyle: BigItem | ||
| useDelay: 1 | ||
|
Comment on lines
70
to
+79
Contributor
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. Копипаста из ниндзя-перчаток — некорректные
Предлагаемое исправление - type: entity
id: ToggleK63Helmet
- name: Toggle ninja gloves
- description: Toggles all glove actions on left click. Includes your doorjack, draining power, stunning enemies and hacking certain computers.
+ name: Toggle helmet visor
+ description: Pull the helmet visor up or down.
components:🤖 Prompt for AI Agents |
||
|
|
||
| - type: entity | ||
| id: ClothingHeadHelmetK63Alternate | ||
| parent: ClothingHeadHelmetBase | ||
| name: fire helmet | ||
| description: An atmos tech's best friend. Provides some heat resistance and looks cool. | ||
| suffix: DeadSector | ||
| components: | ||
| - type: Sprite | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new_alt.rsi | ||
| - type: Clothing | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new_alt.rsi | ||
| quickEquip: true | ||
| clothingVisuals: | ||
| head: | ||
| - state: off-equipped-HELMET | ||
| - type: Item | ||
| size: Normal | ||
| - type: Armor | ||
| modifiers: | ||
| coefficients: | ||
| Blunt: 0.7 | ||
| Slash: 0.7 | ||
| Piercing: 0.93 | ||
| - type: ExplosionResistance | ||
| damageCoefficient: 0.7 | ||
| - type: HideLayerClothing | ||
| slots: | ||
| - Hair | ||
| - HeadTop | ||
| - type: PullableHelmet | ||
| untoggledPrototype: ClothingHeadHelmetK63Alternate | ||
| toggledPrototype: ClothingHeadHelmetK63AlternateLowered | ||
| pullAction: ToggleK63Helmet | ||
|
Comment on lines
+81
to
+113
Contributor
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. Альтернативный шлем — структура корректна, но проверьте коэффициент взрывоустойчивости. У 🤖 Prompt for AI Agents |
||
| - type: entity | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id: ClothingHeadHelmetK63AlternateLowered | ||
| parent: ClothingHeadHelmetK63Alternate | ||
| name: fire helmet | ||
| categories: [ HideSpawnMenu ] | ||
| description: An atmos tech's best friend. Provides some heat resistance and looks cool. | ||
| suffix: DeadSector | ||
| components: | ||
| - type: Sprite | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new_alt.rsi | ||
| - type: Clothing | ||
| sprite: Imperial/Clothing/Head/Helmets/k6_3_new_alt.rsi | ||
| quickEquip: true | ||
| clothingVisuals: | ||
| head: | ||
| - state: on-equipped-HELMET | ||
| - type: Item | ||
| size: Normal | ||
| - type: Armor | ||
| modifiers: | ||
| coefficients: | ||
| Blunt: 0.7 | ||
| Slash: 0.7 | ||
| Piercing: 0.75 | ||
| Heat: 0.75 | ||
| Shock: 0.75 | ||
| - type: ExplosionResistance | ||
| damageCoefficient: 0.5 | ||
| - type: HideLayerClothing | ||
| slots: | ||
| - Hair | ||
| - HeadTop | ||
| - type: IngestionBlocker | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,3 +21,5 @@ | |
| - type: StaminaResistance | ||
| damageCoefficient: 0.85 | ||
| # Imperial Space Stamina Resistance End | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||
| { | ||||||
| "version": 1, | ||||||
| "license": "CC-BY-SA-3.0", | ||||||
| "copyright": "Create by @lune_felix", | ||||||
|
Contributor
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. Исправьте грамматическую ошибку в поле copyright. В строке copyright указано "Create by", но должно быть "Created by" для правильной грамматики английского языка. 📝 Предлагаемое исправление- "copyright": "Create by `@lune_felix`",
+ "copyright": "Created by `@lune_felix`",📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| "size": { | ||||||
| "x": 32, | ||||||
| "y": 32 | ||||||
| }, | ||||||
| "states": [ | ||||||
| { | ||||||
| "name": "icon" | ||||||
| }, | ||||||
| { | ||||||
| "name": "off-equipped-HELMET", | ||||||
| "directions": 4 | ||||||
| }, | ||||||
| { | ||||||
| "name": "inhand-right", | ||||||
| "directions": 4 | ||||||
| }, | ||||||
| { | ||||||
| "name": "on-equipped-HELMET", | ||||||
| "directions": 4 | ||||||
| }, | ||||||
| { | ||||||
| "name": "inhand-left", | ||||||
| "directions": 4 | ||||||
| } | ||||||
| ] | ||||||
| } | ||||||
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.
Дублированный
usingи потенциально неиспользуемый импорт.Строка 3 и строка 5 — дублирование
using Robust.Shared.Prototypes;. Такжеusing Content.Shared.Storage;(строка 1) не используется в файле — нет ссылок на типы из этого пространства имён.Исправление
📝 Committable suggestion
🤖 Prompt for AI Agents