-
Notifications
You must be signed in to change notification settings - Fork 18
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
[Tweak] Вход в гостбар больше не влияет на время до возвращения в раунд #262
Conversation
WalkthroughВ данном изменении добавлено новое публичное поле Changes
Suggested labels
Suggested reviewers
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs (1)
137-139
: Сохранение времени смерти при уходе из гостбара.Код правильно копирует значение
TimeOfDeath
из компонентаGhostBarPlayerComponent
в компонентMindComponent
, однако отсутствует проверка на наличие соответствующих компонентов.// wwdp start -_entityManager.GetComponent<MindComponent>(args.Mind).TimeOfDeath = _entityManager.GetComponent<GhostBarPlayerComponent>(uid).TimeOfDeath; +if (_entityManager.TryGetComponent<MindComponent>(args.Mind, out var mindComp) && + _entityManager.TryGetComponent<GhostBarPlayerComponent>(uid, out var ghostBarComp)) + mindComp.TimeOfDeath = ghostBarComp.TimeOfDeath; // wwdp end
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Content.Server/_Goobstation/Ghostbar/Components/GhostBarPlayerComponent.cs
(1 hunks)Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs
(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: build (ubuntu-latest)
- GitHub Check: Test Packaging
- GitHub Check: YAML Linter
- GitHub Check: YAML map schema validator
🔇 Additional comments (2)
Content.Server/_Goobstation/Ghostbar/Components/GhostBarPlayerComponent.cs (1)
9-12
: Добавлено новое поле для отслеживания времени смерти.Новое поле
TimeOfDeath
добавлено для хранения времени смерти игрока, что позволяет сохранять это значение при перемещении в гостбар и обратно.Content.Server/_Goobstation/Ghostbar/GhostBarSystem.cs (1)
15-15
: Добавлено новое пространство имен.Добавлен новый using для пространства имен
Content.Shared.Mind
, что необходимо для работы с компонентомMindComponent
и его свойствомTimeOfDeath
.
// wwdp edit start | ||
if(player.AttachedEntity != null) | ||
_entityManager.GetComponent<GhostBarPlayerComponent>(mobUid).TimeOfDeath = _entityManager.GetComponent<GhostComponent>((Robust.Shared.GameObjects.EntityUid) player.AttachedEntity).TimeOfDeath; | ||
if(mind.TimeOfDeath.HasValue) | ||
_entityManager.GetComponent<GhostBarPlayerComponent>(mobUid).TimeOfDeath = mind.TimeOfDeath.Value; | ||
// wwdp edit end |
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.
🛠️ Refactor suggestion
Сохранение времени смерти при переходе в гостбар.
Код сохраняет время смерти игрока при перемещении в гостбар, но имеет несколько проблем:
- Используется избыточное приведение типов
(Robust.Shared.GameObjects.EntityUid)
, которое не требуется, еслиplayer.AttachedEntity
уже имеет типEntityUid
. - Нет проверки на наличие компонента
GhostComponent
перед его получением. - Логика не учитывает возможность, когда оба условия истинны - второе условие перезапишет значение, установленное первым.
// wwdp edit start
if(player.AttachedEntity != null)
- _entityManager.GetComponent<GhostBarPlayerComponent>(mobUid).TimeOfDeath = _entityManager.GetComponent<GhostComponent>((Robust.Shared.GameObjects.EntityUid) player.AttachedEntity).TimeOfDeath;
+ if (_entityManager.TryGetComponent<GhostComponent>(player.AttachedEntity, out var ghostComp))
+ _entityManager.GetComponent<GhostBarPlayerComponent>(mobUid).TimeOfDeath = ghostComp.TimeOfDeath;
-if(mind.TimeOfDeath.HasValue)
+else if(mind.TimeOfDeath.HasValue)
_entityManager.GetComponent<GhostBarPlayerComponent>(mobUid).TimeOfDeath = mind.TimeOfDeath.Value;
// wwdp edit end
Committable suggestion skipped: line range outside the PR's diff.
Ты кода новую ветку делаешь, то делай ее из мастера, а не из предыдущей ветки |
я из мастера все ветки делаю, получается в мастер ничего мержить не надо, а просто синхронизировать из основного репозитория? |
Да |
🆑 3189