-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||
{ | ||||||||
[DataField("tall")] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
public bool Tall = false; | ||||||||
|
||||||||
[DataField("short")] | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
public bool Short = false; | ||||||||
|
||||||||
public readonly float TallScale = 1.10f; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
} |
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 | ||||||||||||
{ | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
return; | ||||||||||||
|
||||||||||||
if (component.Short) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
{ | ||||||||||||
var physics = _entityManager.System<SharedPhysicsSystem>(); | ||||||||||||
var appearance = _entityManager.System<AppearanceSystem>(); | ||||||||||||
Comment on lines
+36
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Почему это не может быть There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Разве это критично важно? Часть кода изменения размера была взята из репы движка, где команда /scale There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ну ты каждый раз про вызове метода Scale получаешь систему вместо того, чтобы один раз инжектнуть Dependency There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
В целом, логично. Тогда отправлю комит с новым кодом на основе всех названных ошибок. Я прост не очень силён в кодинге на шарпе, особенно в связке с таким большим проектом. |
||||||||||||
|
||||||||||||
_entityManager.EnsureComponent<ScaleVisualsComponent>(uid); | ||||||||||||
|
||||||||||||
var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid); | ||||||||||||
Comment on lines
+39
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||
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)) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. инвертируй if-блок + |
||||||||||||
{ | ||||||||||||
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(); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
} | ||||||||||||
} | ||||||||||||
} | ||||||||||||
} | ||||||||||||
} | ||||||||||||
} |
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 | ||
{ } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Этот блок лишний просто ставь |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- type: traitCategory | ||
id: HeightTraits | ||
name: Рост | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. используй |
||
maxTraitPoints: 1 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. используй |
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 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Убери не нужные изменения |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,4 @@ | |
|
||
- type: traitCategory | ||
id: Quirks | ||
name: trait-category-quirks | ||
name: trait-category-quirks |
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.
Переменная
isShort
иisTall
идея плохая, лучше сделай прототипы роста, или хотя бы enum значение