-
Notifications
You must be signed in to change notification settings - Fork 6
bugfix #76
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
bugfix #76
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,28 @@ | ||
| using Content.Shared.Weapons.Ranged.Components; | ||
| using Content.Shared.Weapons.Ranged.Events; | ||
|
|
||
| namespace Content.Client.Weapons.Ranged.Systems; | ||
|
|
||
| public sealed partial class GunSystem | ||
| { | ||
| private void InitializeHybrid() | ||
| { | ||
| SubscribeLocalEvent<HybridAmmoProviderComponent, UpdateAmmoCounterEvent>(OnHybridUpdateAmmo); | ||
| SubscribeLocalEvent<HybridAmmoProviderComponent, AmmoCounterControlEvent>(OnHybridControl); | ||
| } | ||
|
|
||
| private void OnHybridUpdateAmmo(EntityUid uid, HybridAmmoProviderComponent component, UpdateAmmoCounterEvent args) | ||
| { | ||
| if (args.Control is DefaultStatusControl control) | ||
| { | ||
| var ev = new GetAmmoCountEvent(); | ||
| RaiseLocalEvent(uid, ref ev, false); | ||
| control.Update(ev.Count, ev.Capacity); | ||
| } | ||
| } | ||
|
|
||
| private void OnHybridControl(EntityUid uid, HybridAmmoProviderComponent component, AmmoCounterControlEvent args) | ||
| { | ||
| args.Control = new DefaultStatusControl(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,125 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Weapons.Ranged.Components; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Weapons.Ranged.Events; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Server.Power.EntitySystems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Shared.Power.Components; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Containers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Map; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using Content.Server.Power.Components; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace Content.Server.Weapons.Ranged.Systems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public sealed partial class GunSystem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void InitializeHybrid() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SubscribeLocalEvent<HybridAmmoProviderComponent, TakeAmmoEvent>(OnHybridTakeAmmo); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SubscribeLocalEvent<HybridAmmoProviderComponent, GetAmmoCountEvent>(OnHybridGetAmmoCount); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SubscribeLocalEvent<HybridAmmoProviderComponent, EntInsertedIntoContainerMessage>(OnHybridMagazineInsert); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SubscribeLocalEvent<HybridAmmoProviderComponent, EntRemovedFromContainerMessage>(OnHybridMagazineRemove); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void OnHybridMagazineInsert(EntityUid uid, HybridAmmoProviderComponent component, EntInsertedIntoContainerMessage args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (component.MagazineSlot != args.Container.ID) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UpdateAmmoCount(uid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void OnHybridMagazineRemove(EntityUid uid, HybridAmmoProviderComponent component, EntRemovedFromContainerMessage args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (component.MagazineSlot != args.Container.ID) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UpdateAmmoCount(uid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void OnHybridTakeAmmo(EntityUid uid, HybridAmmoProviderComponent component, TakeAmmoEvent args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 1. Получаем магазин из слота | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var magazineEntity = GetMagazineEntity(uid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (magazineEntity == null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-no-magazine"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 2. Проверяем патроны (BallisticAmmoProvider) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!TryComp<BallisticAmmoProviderComponent>(magazineEntity.Value, out var ballistic)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-no-ammo"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Получаем текущее количество патронов | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var currentCount = GetBallisticShots(ballistic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (currentCount <= 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-no-ammo"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 3. Проверяем энергию (BatteryComponent) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!TryComp<BatteryComponent>(magazineEntity.Value, out var battery)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-no-battery"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (battery.CurrentCharge < component.FireCost) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-not-enough-energy"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+60
to
+70
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. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Батарея берётся только из магазина.
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 4. Тратим патрон: удаляем последний патрон из контейнера или уменьшаем UnspawnedCount | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ballistic.Entities.Count > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var lastEntity = ballistic.Entities[^1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ballistic.Entities.RemoveAt(ballistic.Entities.Count - 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Containers.Remove(lastEntity, ballistic.Container); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| QueueDel(lastEntity); // Удаляем сущность патрона (гильза не нужна) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else if (ballistic.UnspawnedCount > 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ballistic.UnspawnedCount--; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Reason = Loc.GetString("gun-no-ammo"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+72
to
+88
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Не изменяйте
Удаляйте патрон только через контейнер и проверяйте результат. 🐛 Предлагаемое исправление if (ballistic.Entities.Count > 0)
{
var lastEntity = ballistic.Entities[^1];
- ballistic.Entities.RemoveAt(ballistic.Entities.Count - 1);
- Containers.Remove(lastEntity, ballistic.Container);
+ if (!Containers.Remove(lastEntity, ballistic.Container))
+ {
+ args.Reason = Loc.GetString("gun-no-ammo");
+ return;
+ }
QueueDel(lastEntity); // Удаляем сущность патрона (гильза не нужна)
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 5. Тратим энергию | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| _battery.UseCharge(magazineEntity.Value, component.FireCost); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 6. Создаём снаряд в координатах выстрела | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var fromCoordinates = args.Coordinates; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var mapCoords = fromCoordinates.ToMap(EntityManager, TransformSystem); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var projectile = Spawn(component.Prototype, mapCoords); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 7. Добавляем снаряд в список для выстрела (основной GunSystem обработает его) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Ammo.Add((projectile, EnsureShootable(projectile))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 8. Обновляем счётчик на клиенте | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Dirty(magazineEntity.Value, ballistic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UpdateAmmoCount(uid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+35
to
+104
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. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Обработчик игнорирует
Оберните шаги 2–7 в цикл по 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private void OnHybridGetAmmoCount(EntityUid uid, HybridAmmoProviderComponent component, ref GetAmmoCountEvent args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| var magazineEntity = GetMagazineEntity(uid); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (magazineEntity != null && TryComp<BallisticAmmoProviderComponent>(magazineEntity.Value, out var ballistic)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Count = GetBallisticShots(ballistic); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Capacity = ballistic.Capacity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Count = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| args.Capacity = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private int GetBallisticShots(BallisticAmmoProviderComponent component) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return component.UnspawnedCount + component.Entities.Count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| using Robust.Shared.GameStates; | ||
| using Robust.Shared.Prototypes; | ||
| using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
|
||
| namespace Content.Shared.Weapons.Ranged.Components; | ||
|
|
||
| [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] | ||
| public sealed partial class HybridAmmoProviderComponent : Component | ||
| { | ||
| [DataField("proto", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))] | ||
| public string Prototype = default!; | ||
|
|
||
| [DataField("capacity"), AutoNetworkedField] | ||
| public int Capacity = 10; | ||
|
|
||
| [DataField("count"), AutoNetworkedField] | ||
| public int Count = 10; | ||
|
|
||
| [DataField("fireCost")] | ||
| public float FireCost = 100f; | ||
|
|
||
| // Ссылка на батарею (если null, используем свой uid) | ||
| [DataField("battery")] | ||
| public EntityUid? BatteryEntity; | ||
|
|
||
| // Ссылка на слот магазина (для автоматической загрузки патронов) | ||
| [DataField("magazineSlot")] | ||
| public string? MagazineSlot; | ||
|
Comment on lines
+13
to
+28
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. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift Контракт
📍 Affects 3 files
🤖 Prompt for AI Agents📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win Уберите неиспользуемые поля или начните их использовать. Поля Дополнительно: ♻️ Предлагаемое изменение- [DataField("capacity"), AutoNetworkedField]
- public int Capacity = 10;
-
- [DataField("count"), AutoNetworkedField]
- public int Count = 10;
-
[DataField("fireCost")]
public float FireCost = 100f;
- // Ссылка на батарею (если null, используем свой uid)
- [DataField("battery")]
- public EntityUid? BatteryEntity;
+ // Ссылка на батарею (если null, используем магазин)
+ public EntityUid? BatteryEntity;
// Ссылка на слот магазина (для автоматической загрузки патронов)
[DataField("magazineSlot")]
public string? MagazineSlot;🤖 Prompt for AI Agents |
||
| } | ||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Echo-DreamMaker/Sirius_Fallout
Length of output: 305
🏁 Script executed:
Repository: Echo-DreamMaker/Sirius_Fallout
Length of output: 37095
Добавьте ключи локализации для сообщений оружия.
Ключи
gun-no-magazine,gun-no-ammo,gun-no-batteryиgun-not-enough-energyотсутствуют во всех.ftl. Они также используются вSharedFlamerAmmoSystem.cs.🤖 Prompt for AI Agents