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

Traits for roundstart species size #4

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Content.Server/Traits/Assorted/HeightComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Content.Server.Traits.Assorted
{
[RegisterComponent]
public sealed partial class HeightComponent : Component
Copy link
Collaborator

Choose a reason for hiding this comment

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

Переменная isShort и isTall идея плохая, лучше сделай прототипы роста, или хотя бы enum значение

{
[DataField("tall")]

Choose a reason for hiding this comment

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

Suggested change
[DataField("tall")]
[DataField]

public bool Tall = false;

[DataField("short")]

Choose a reason for hiding this comment

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

Suggested change
[DataField("short")]
[DataField]

public bool Short = false;

public readonly float TallScale = 1.10f;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Сделай это череp [DataField]

public readonly float ShortScale = 0.90f;

}
Comment on lines +14 to +15

Choose a reason for hiding this comment

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

Suggested change
}
}

}
63 changes: 63 additions & 0 deletions Content.Server/Traits/Assorted/HeightSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Robust.Server.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Systems;
using System.Numerics;

namespace Content.Server.Traits.Assorted
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

Этот блок лишний

public sealed class HeightSystem : EntitySystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HeightComponent, ComponentStartup>(InitComponent);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Убирать изменение роста при удалении компонента

}

private void InitComponent(EntityUid uid, HeightComponent component, ComponentStartup args)
{
if (TryComp<HeightTraitBlacklistComponent>(uid, out var comp))

Choose a reason for hiding this comment

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

Suggested change
if (TryComp<HeightTraitBlacklistComponent>(uid, out var comp))
if (HasComp<HeightTraitBlacklistComponent>(uid))

return;

if (component.Short)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Как говорил выше, реализация отвратительная

{
Scale(uid, component.ShortScale);
}
else if (component.Tall)
{
Scale(uid, component.TallScale);
}


}
private void Scale(EntityUid uid, float scale)
Comment on lines +33 to +34

Choose a reason for hiding this comment

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

Suggested change
}
private void Scale(EntityUid uid, float scale)
}
private void Scale(EntityUid uid, float scale)

{
var physics = _entityManager.System<SharedPhysicsSystem>();
var appearance = _entityManager.System<AppearanceSystem>();
Comment on lines +36 to +37

Choose a reason for hiding this comment

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

Почему это не может быть [Dependency] вместо использования .System()?

Copy link
Author

Choose a reason for hiding this comment

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

Разве это критично важно? Часть кода изменения размера была взята из репы движка, где команда /scale

Choose a reason for hiding this comment

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

ну ты каждый раз про вызове метода Scale получаешь систему вместо того, чтобы один раз инжектнуть Dependency

Copy link
Author

Choose a reason for hiding this comment

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

ну ты каждый раз про вызове метода Scale получаешь систему вместо того, чтобы один раз инжектнуть Dependency

В целом, логично. Тогда отправлю комит с новым кодом на основе всех названных ошибок. Я прост не очень силён в кодинге на шарпе, особенно в связке с таким большим проектом.


_entityManager.EnsureComponent<ScaleVisualsComponent>(uid);

var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid);
Comment on lines +39 to +41

Choose a reason for hiding this comment

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

EnsureComp?

if (!appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent))
oldScale = Vector2.One;

appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent);

if (_entityManager.TryGetComponent(uid, out FixturesComponent? manager))

Choose a reason for hiding this comment

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

инвертируй if-блок + TryComp

{
foreach (var (id, fixture) in manager.Fixtures)
{
switch (fixture.Shape)
{
case PhysShapeCircle circle:
physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager);
break;
default:
throw new NotImplementedException();

Choose a reason for hiding this comment

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

Suggested change
throw new NotImplementedException();
break;

}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Server.Traits.Assorted
{
[RegisterComponent]
public sealed partial class HeightTraitBlacklistComponent : Component
{ }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Этот блок лишний просто ставь ;

}
4 changes: 4 additions & 0 deletions Resources/Prototypes/Corvax/Traits/categories.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: traitCategory
id: HeightTraits
name: Рост
Copy link
Collaborator

Choose a reason for hiding this comment

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

используй loc файлы

maxTraitPoints: 1
25 changes: 25 additions & 0 deletions Resources/Prototypes/Corvax/Traits/height.yml
Copy link
Collaborator

Choose a reason for hiding this comment

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

используй loc файлы

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- type: trait
id: Tall
name: Высокий
description: Станьте большой дылдой.
category: HeightTraits
cost: 1
blacklist:
components:
- HeightTraitBlacklist
components:
- type: Height
tall: true

- type: trait
id: Short
name: Низкий
description: Ваш персонаж маленького роста.
category: HeightTraits
cost: 1
blacklist:
components:
- HeightTraitBlacklist
components:
- type: Height
short: true
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
32:
sprite: Mobs/Species/Human/displacement.rsi
state: jumpsuit-female
- type: HeightTraitBlacklist # Corvax-Next

- type: entity
parent: BaseSpeciesDummy
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/Traits/categories.yml
Copy link
Collaborator

Choose a reason for hiding this comment

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

Убери не нужные изменения

Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

- type: traitCategory
id: Quirks
name: trait-category-quirks
name: trait-category-quirks