Fix psionics power pool - #1144
Conversation
WalkthroughДобавлен компонент ИзмененияСистема пользовательских пулов псионических сил
Оценка сложности рецензии🎯 2 (Simple) | ⏱️ ~12 минут Рекомендуемые метки
Рекомендуемые рецензенты
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
до ньюпсионики заживёт |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
Content.Server/Psionics/PsionicsSystem.cs (1)
236-237:⚠️ Potential issue | 🟠 Major | ⚡ Quick winДобавьте нижнюю границу для
NextPowerCost, иначе возможен бесконечный цикл.Если
calculatedCostстановится0, условие вwhile (component.Potentia >= component.NextPowerCost)всегда истинно и обработка зависнет.Возможный фикс
- float calculatedCost = Math.Abs(component.BaselinePowerCost * MathF.Pow(2, component.PowerSlotsTaken)); //wwdp edit - component.NextPowerCost = Math.Min(calculatedCost, maxPowerCost); + var calculatedCost = Math.Abs(component.BaselinePowerCost * MathF.Pow(2, component.PowerSlotsTaken)); //wwdp edit + component.NextPowerCost = Math.Clamp(calculatedCost, 1f, maxPowerCost);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Content.Server/Psionics/PsionicsSystem.cs` around lines 236 - 237, The NextPowerCost assignment can become zero and cause an infinite loop in the while (component.Potentia >= component.NextPowerCost) check; clamp NextPowerCost to a sensible minimum when computing it in the block that calculates calculatedCost (using component.BaselinePowerCost and component.PowerSlotsTaken) — e.g., compute calculatedCost as now, then set component.NextPowerCost = Math.Min(calculatedCost, maxPowerCost) and then ensure component.NextPowerCost = Math.Max(component.NextPowerCost, minPowerCost) (or another nonzero minimum) so the loop condition can eventually become false; adjust or introduce a minPowerCost constant/variable and reference NextPowerCost, calculatedCost, BaselinePowerCost, PowerSlotsTaken, and Potentia in your change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@Content.Server/Psionics/PsionicsSystem.cs`:
- Around line 236-237: The NextPowerCost assignment can become zero and cause an
infinite loop in the while (component.Potentia >= component.NextPowerCost)
check; clamp NextPowerCost to a sensible minimum when computing it in the block
that calculates calculatedCost (using component.BaselinePowerCost and
component.PowerSlotsTaken) — e.g., compute calculatedCost as now, then set
component.NextPowerCost = Math.Min(calculatedCost, maxPowerCost) and then ensure
component.NextPowerCost = Math.Max(component.NextPowerCost, minPowerCost) (or
another nonzero minimum) so the loop condition can eventually become false;
adjust or introduce a minPowerCost constant/variable and reference
NextPowerCost, calculatedCost, BaselinePowerCost, PowerSlotsTaken, and Potentia
in your change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 25636037-01f9-47be-a074-d97f0f4b4a8c
📒 Files selected for processing (5)
Content.Server/Abilities/Psionics/PsionicAbilitiesSystem.Functions.csContent.Server/Psionics/PsionicsSystem.csContent.Shared/_White/Psionics/CustomPsionicPoolComponent.csResources/Prototypes/Traits/Psionics/casterTypes.ymlResources/Prototypes/_White/Traits/Psionics/typeCaster.yml
| PsionicPowerPrototype proto) | ||
| { | ||
| psionicComponent.PowerPool = PowerPool; | ||
| if (string.IsNullOrEmpty(psionicComponent.PowerPool) || psionicComponent.PowerPool == "RandomPsionicPowerPool") //WWDP EDIT |
There was a problem hiding this comment.
psionicComponent.PowerPool == "RandomPsionicPowerPool"
рак
| namespace Content.Shared._White.Psionics; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class CustomPsionicPoolComponent : Component |
There was a problem hiding this comment.
В чём смысл этого компонента? Для чего он существует?
Описание PR
немного костыльная починка того, что на сервере шанс 50 на 50 получить псионику по трейду.
теперь в трейтах выдаётся ещё и компонент CustomPsionicPoolComponent, он хранит в себе powerPool, а в системе псионики при выдаче псиопики будет выставлять паверпулл который есть в этом компоненте, он должен работать нормально.
Медиа
Список
Изменения
🆑