Skip to content

Fix psionics power pool - #1144

Closed
kekoven1 wants to merge 3 commits into
WWhiteDreamProject:masterfrom
kekoven1:fix-psionics-power-pool
Closed

Fix psionics power pool#1144
kekoven1 wants to merge 3 commits into
WWhiteDreamProject:masterfrom
kekoven1:fix-psionics-power-pool

Conversation

@kekoven1

@kekoven1 kekoven1 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Описание PR

немного костыльная починка того, что на сервере шанс 50 на 50 получить псионику по трейду.
теперь в трейтах выдаётся ещё и компонент CustomPsionicPoolComponent, он хранит в себе powerPool, а в системе псионики при выдаче псиопики будет выставлять паверпулл который есть в этом компоненте, он должен работать нормально.


Медиа

Список

Example Media Embed


Изменения

🆑

  • fix: Псикасты работают

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Добавлен компонент CustomPsionicPoolComponent, интегрирован в PsionicsSystem (переопределение PowerPool при генерации), защищён условием в PsionicAbilitiesSystem, и применён к ряду трейтов через YAML-конфигурации.

Изменения

Система пользовательских пулов псионических сил

Layer / File(s) Summary
Определение компонента
Content.Shared/_White/Psionics/CustomPsionicPoolComponent.cs
CustomPsionicPoolComponent — новый ECS-компонент с обязательным полем Pool типа ProtoId<WeightedRandomPrototype> и значением по умолчанию RandomPsionicPowerPool.
Интеграция в систему Psionics
Content.Server/Psionics/PsionicsSystem.cs
Обновлены using-директивы; в DeferRollers добавлена проверка CustomPsionicPoolComponent и переопределение PsionicComponent.PowerPool из customPoolComp.Pool перед расчётом стоимости и генерацией доступных способностей.
Защита логики способностей
Content.Server/Abilities/Psionics/PsionicAbilitiesSystem.Functions.cs
В PsionicChangePowerPool.OnAddPsionic условное обновление PowerPool: присваивание происходит только если текущее значение пусто/null или равно RandomPsionicPowerPool.
Применение к трейтам
Resources/Prototypes/Traits/Psionics/casterTypes.yml, Resources/Prototypes/_White/Traits/Psionics/typeCaster.yml
Трейты (PsychoHistorian, Shadowkin, Infernal, Telekineticist, Priest) получают компонент CustomPsionicPool с указанием соответствующего пул-прототипа (напр., PsychoHistorianPowerPool, ShadowkinPowerPool и т.д.).

Оценка сложности рецензии

🎯 2 (Simple) | ⏱️ ~12 минут

Рекомендуемые метки

Changes: C#, Changes: YML, Status: Needs Review

Рекомендуемые рецензенты

  • Remuchi
  • Spatison
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Название точно описывает основное изменение: исправление проблемы с пулом мощности псионики, что соответствует основной цели PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed Описание PR связано с набором изменений: объясняет проблему (50/50 шанс получить псионику по трейту) и описывает решение (добавление компонента CustomPsionicPoolComponent для хранения и установки powerPool).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kekoven1

kekoven1 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

до ньюпсионики заживёт

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f74be61 and 9c66574.

📒 Files selected for processing (5)
  • Content.Server/Abilities/Psionics/PsionicAbilitiesSystem.Functions.cs
  • Content.Server/Psionics/PsionicsSystem.cs
  • Content.Shared/_White/Psionics/CustomPsionicPoolComponent.cs
  • Resources/Prototypes/Traits/Psionics/casterTypes.yml
  • Resources/Prototypes/_White/Traits/Psionics/typeCaster.yml

@RedFoxIV RedFoxIV left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

что блять?

PsionicPowerPrototype proto)
{
psionicComponent.PowerPool = PowerPool;
if (string.IsNullOrEmpty(psionicComponent.PowerPool) || psionicComponent.PowerPool == "RandomPsionicPowerPool") //WWDP EDIT

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

psionicComponent.PowerPool == "RandomPsionicPowerPool"
рак

namespace Content.Shared._White.Psionics;

[RegisterComponent]
public sealed partial class CustomPsionicPoolComponent : Component

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В чём смысл этого компонента? Для чего он существует?

@kekoven1 kekoven1 closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants