Skip to content
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

[PORT] Smooth Light #977

Merged
merged 1 commit into from
Dec 13, 2024
Merged

[PORT] Smooth Light #977

merged 1 commit into from
Dec 13, 2024

Conversation

trest100
Copy link
Contributor

@trest100 trest100 commented Dec 10, 2024

Описание PR

теперь свет фонарика следует за вашей мышкой

Медиа

Тип PR

  • Feature
  • Fix
  • Tweak
  • Balance
  • Refactor
  • Port
  • Translate
  • Resprite

Original PR:
WWhiteDreamProject/wwdpublic#141

🆑 Trest100

  • tweak: Fonarik

Summary by CodeRabbit

  • Новые функции
    • Добавлено свойство SmoothRotation для улучшения поведения компонента вращения мыши в боевом режиме.
  • Исправления ошибок
    • Улучшена логика настройки компонента вращения мыши в зависимости от нового свойства SmoothRotation.
  • Документация
    • Удалены закомментированные блоки кода, связанные с сообщениями о статусе боевого режима.

@trest100 trest100 requested a review from Rxup as a code owner December 10, 2024 03:35
Copy link
Contributor

coderabbitai bot commented Dec 10, 2024

Walkthrough

В классе CombatModeComponent в файле Content.Shared/CombatMode/CombatModeComponent.cs добавлено новое булевое свойство SmoothRotation, которое изменяет поведение MouseRotatorComponent при входе в боевой режим. Если SmoothRotation установлено в true, AngleTolerance устанавливается на 1 градус, а Simple4DirMode отключается. В классе SharedCombatModeSystem обновлен метод SetMouseRotatorComponents, который теперь учитывает новое свойство при настройке компонента вращения мыши. Удален закомментированный код, связанный с сообщениями для игрока.

Changes

File Path Change Summary
Content.Shared/CombatMode/CombatModeComponent.cs Добавлено новое булевое свойство public bool SmoothRotation в класс CombatModeComponent.
Content.Shared/CombatMode/SharedCombatModeSystem.cs Обновлен метод SetMouseRotatorComponents для учета свойства SmoothRotation, изменяющего параметры вращения мыши. Удален закомментированный код.

Poem

В бою теперь, о, как весело,
Вращение плавно, словно в танце!
С новым свойством, что добавлено,
Мышь ведет, как в сказочном шансе.
В бой мы идем, с радостью в сердце,
Сражаться будем, смех и веселье! 🐰✨


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Outside diff range and nitpick comments (1)
Content.Shared/CombatMode/SharedCombatModeSystem.cs (1)

109-113: Улучшите обработку значений и проверки

  1. Значение 1 для AngleTolerance является магическим числом. Рекомендуется вынести его в константу с понятным названием.
  2. Комментарий о проверке на null можно заменить более явным утверждением в коде.
+private const float SmoothRotationAngleTolerance = 1f;

-if (TryComp<CombatModeComponent>(uid, out var comp) && comp.SmoothRotation)
+if (TryComp<CombatModeComponent>(uid, out var comp) && comp is { SmoothRotation: true })
{
-    rot.AngleTolerance = Angle.FromDegrees(1);
+    rot.AngleTolerance = Angle.FromDegrees(SmoothRotationAngleTolerance);
     rot.Simple4DirMode = false;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between ecbc219 and df8250b.

📒 Files selected for processing (2)
  • Content.Shared/CombatMode/CombatModeComponent.cs (1 hunks)
  • Content.Shared/CombatMode/SharedCombatModeSystem.cs (1 hunks)
🔇 Additional comments (1)
Content.Shared/CombatMode/SharedCombatModeSystem.cs (1)

107-114: Проверьте удаление механизма обратной связи

Был удален код всплывающих сообщений без явной замены. Пользователю может быть неочевидно, включен ли боевой режим.

Запустим проверку наличия альтернативного механизма обратной связи:

Рассмотрите альтернативные способы информирования пользователя о состоянии боевого режима:

  1. Визуальный индикатор в UI
  2. Звуковой сигнал
  3. Анимация персонажа
✅ Verification successful

Let's check the content of these files to see if there are alternative feedback mechanisms.


Let's check for UI-related files and combat mode indicators more broadly.


Let's check the content of the CombatModeSystem.cs to understand the status indicator implementation.


Based on the code analysis, I can now provide a final response:

Механизм обратной связи присутствует через визуальные индикаторы

В коде реализован визуальный индикатор боевого режима через:

  • Статусную иконку, которая отображается при включенном боевом режиме
  • Спрайт-индикатор из "Backmen/Effects/combat_mode.rsi"
  • Системный компонент CombatModeIndicatorsOverlay

Удаление всплывающих сообщений не влияет на информирование пользователя, так как основной механизм обратной связи реализован через визуальные индикаторы.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Поиск других механизмов обратной связи при переключении режима
rg -l "combat.*mode.*enabled|combat.*mode.*disabled" --type cs

Length of output: 168


Script:

#!/bin/bash
# Check content of the found files
echo "=== Content.Shared/Interaction/SharedInteractionSystem.cs ==="
rg "combat.*mode.*(enabled|disabled)" -A 5 -B 5 Content.Shared/Interaction/SharedInteractionSystem.cs

echo -e "\n=== Content.Client/Weapons/Melee/MeleeWeaponSystem.cs ==="
rg "combat.*mode.*(enabled|disabled)" -A 5 -B 5 Content.Client/Weapons/Melee/MeleeWeaponSystem.cs

# Let's also check for UI indicators
echo -e "\n=== Checking for UI indicators ==="
rg "CombatMode.*UI" --type cs -A 5 -B 5

Length of output: 1836


Script:

#!/bin/bash
# Поиск UI-компонентов, связанных с боевым режимом
echo "=== Checking UI components ==="
rg -l "CombatMode" Content.Client/UserInterface --type cs

# Поиск визуальных индикаторов
echo -e "\n=== Checking visual indicators ==="
rg "CombatMode.*\.(Sprite|Icon|Indicator|Visual)" --type cs

# Поиск звуковых эффектов
echo -e "\n=== Checking sound effects ==="
rg "CombatMode.*\.(Sound|Audio|Play)" --type cs

# Поиск любых других индикаторов состояния
echo -e "\n=== Checking status indicators ==="
rg "CombatMode.*Status" --type cs

Length of output: 836


Script:

#!/bin/bash
# Проверим реализацию индикатора статуса
echo "=== Content.Client/CombatMode/CombatModeSystem.cs ==="
cat Content.Client/CombatMode/CombatModeSystem.cs

# Проверим связанные события
echo -e "\n=== Checking GetStatusIconsEvent usage ==="
rg "GetStatusIconsEvent" --type cs -A 5 -B 5

Length of output: 30227

Comment on lines +54 to +67

// BACKMEN START
/// <summary>
/// If true, sets <see cref="MouseRotatorComponent.AngleTolerance"/> to 1 degree and <see cref="MouseRotatorComponent.Simple4DirMode"/>
/// to false when the owner enters combatmode. This is currently being tested as of 06.12.24,
/// so a simple bool switch should suffice.
/// Leaving AutoNetworking just in case shitmins need to disable it for someone. Will only take effect when re-enabling combat mode.
/// </summary>
/// <remarks>
/// No effect if <see cref="ToggleMouseRotator"/> is false.
/// </remarks>
[DataField, AutoNetworkedField]
public bool SmoothRotation = true;
// BACKMEN END
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Рассмотрите значение по умолчанию для SmoothRotation

Установка SmoothRotation = true по умолчанию может неожиданно изменить поведение для существующих сущностей. Рекомендуется:

  1. Установить значение по умолчанию в false для обратной совместимости
  2. Включать новое поведение только для новых сущностей или через явную конфигурацию
-public bool SmoothRotation = true;
+public bool SmoothRotation = false;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// BACKMEN START
/// <summary>
/// If true, sets <see cref="MouseRotatorComponent.AngleTolerance"/> to 1 degree and <see cref="MouseRotatorComponent.Simple4DirMode"/>
/// to false when the owner enters combatmode. This is currently being tested as of 06.12.24,
/// so a simple bool switch should suffice.
/// Leaving AutoNetworking just in case shitmins need to disable it for someone. Will only take effect when re-enabling combat mode.
/// </summary>
/// <remarks>
/// No effect if <see cref="ToggleMouseRotator"/> is false.
/// </remarks>
[DataField, AutoNetworkedField]
public bool SmoothRotation = true;
// BACKMEN END
// BACKMEN START
/// <summary>
/// If true, sets <see cref="MouseRotatorComponent.AngleTolerance"/> to 1 degree and <see cref="MouseRotatorComponent.Simple4DirMode"/>
/// to false when the owner enters combatmode. This is currently being tested as of 06.12.24,
/// so a simple bool switch should suffice.
/// Leaving AutoNetworking just in case shitmins need to disable it for someone. Will only take effect when re-enabling combat mode.
/// </summary>
/// <remarks>
/// No effect if <see cref="ToggleMouseRotator"/> is false.
/// </remarks>
[DataField, AutoNetworkedField]
public bool SmoothRotation = false;
// BACKMEN END

@KayzelW KayzelW merged commit 10a5d9d into master Dec 13, 2024
16 checks passed
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