-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into upstream180224
- Loading branch information
Showing
539 changed files
with
1,632,169 additions
and
65,390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Content.Server/ADT/SizeAttribute/SizeAttributeComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Content.Shared.ADT.Cloning; | ||
|
||
namespace Content.Server.SizeAttribute | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class SizeAttributeComponent : Component, ITransferredByCloning | ||
{ | ||
[DataField("short")] | ||
public bool Short = false; | ||
|
||
[DataField("tall")] | ||
public bool Tall = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
using System.Numerics; | ||
using Robust.Server.GameObjects; | ||
using Robust.Shared.Physics; | ||
using Robust.Shared.Physics.Collision.Shapes; | ||
using Robust.Shared.Physics.Systems; | ||
using Content.Shared.Item.PseudoItem; | ||
|
||
namespace Content.Server.SizeAttribute | ||
{ | ||
public sealed class SizeAttributeSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly SharedPhysicsSystem _physics = default!; | ||
[Dependency] private readonly AppearanceSystem _appearance = default!; | ||
[Dependency] private readonly FixtureSystem _fixtures = default!; | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<SizeAttributeComponent, ComponentInit>(OnComponentInit); | ||
} | ||
|
||
private void OnComponentInit(EntityUid uid, SizeAttributeComponent component, ComponentInit args) | ||
{ | ||
if (!TryComp<SizeAttributeWhitelistComponent>(uid, out var whitelist)) | ||
return; | ||
|
||
if (whitelist.Tall && component.Tall) | ||
{ | ||
Scale(uid, component, whitelist.TallScale, whitelist.TallDensity, whitelist.TallCosmeticOnly); | ||
PseudoItem(uid, component, whitelist.TallPseudoItem); | ||
} | ||
else if (whitelist.Short && component.Short) | ||
{ | ||
Scale(uid, component, whitelist.ShortScale, whitelist.ShortDensity, whitelist.ShortCosmeticOnly); | ||
PseudoItem(uid, component, whitelist.ShortPseudoItem); | ||
} | ||
} | ||
|
||
private void PseudoItem(EntityUid uid, SizeAttributeComponent component, bool active) | ||
{ | ||
if (active) | ||
{ | ||
if (TryComp<PseudoItemComponent>(uid, out var pseudoI)) | ||
return; | ||
|
||
_entityManager.AddComponent<PseudoItemComponent>(uid); | ||
} | ||
else | ||
{ | ||
if (!TryComp<PseudoItemComponent>(uid, out var pseudoI)) | ||
return; | ||
|
||
_entityManager.RemoveComponent<PseudoItemComponent>(uid); | ||
} | ||
} | ||
|
||
private void Scale(EntityUid uid, SizeAttributeComponent component, float scale, float density, bool cosmeticOnly) | ||
{ | ||
if (scale <= 0f && density <= 0f) | ||
return; | ||
|
||
_entityManager.EnsureComponent<ScaleVisualsComponent>(uid); | ||
|
||
var appearanceComponent = _entityManager.EnsureComponent<AppearanceComponent>(uid); | ||
if (!_appearance.TryGetData<Vector2>(uid, ScaleVisuals.Scale, out var oldScale, appearanceComponent)) | ||
oldScale = Vector2.One; | ||
|
||
_appearance.SetData(uid, ScaleVisuals.Scale, oldScale * scale, appearanceComponent); | ||
|
||
if (!cosmeticOnly && _entityManager.TryGetComponent(uid, out FixturesComponent? manager)) | ||
{ | ||
foreach (var (id, fixture) in manager.Fixtures) | ||
{ | ||
if (!fixture.Hard || fixture.Density <= 1f) | ||
continue; // This will skip the flammable fixture and any other fixture that is not supposed to contribute to mass | ||
|
||
switch (fixture.Shape) | ||
{ | ||
case PhysShapeCircle circle: | ||
_physics.SetPositionRadius(uid, id, fixture, circle, circle.Position * scale, circle.Radius * scale, manager); | ||
break; | ||
default: | ||
throw new NotImplementedException(); | ||
} | ||
|
||
_physics.SetDensity(uid, id, fixture, density); | ||
} | ||
} | ||
} | ||
} | ||
|
||
[ByRefEvent] | ||
public readonly record struct ScaleEntityEvent(EntityUid Uid) { } | ||
} |
40 changes: 40 additions & 0 deletions
40
Content.Server/ADT/SizeAttribute/SizeAttributeWhitelistComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Robust.Shared.Physics.Collision.Shapes; | ||
|
||
namespace Content.Server.SizeAttribute | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class SizeAttributeWhitelistComponent : Component | ||
{ | ||
// Short | ||
[DataField("short")] | ||
public bool Short = false; | ||
|
||
[DataField("shortscale")] | ||
public float ShortScale = 0f; | ||
|
||
[DataField("shortDensity")] | ||
public float ShortDensity = 0f; | ||
|
||
[DataField("shortPseudoItem")] | ||
public bool ShortPseudoItem = false; | ||
|
||
[DataField("shortCosmeticOnly")] | ||
public bool ShortCosmeticOnly = true; | ||
|
||
// Tall | ||
[DataField("tall")] | ||
public bool Tall = false; | ||
|
||
[DataField("tallscale")] | ||
public float TallScale = 0f; | ||
|
||
[DataField("tallDensity")] | ||
public float TallDensity = 0f; | ||
|
||
[DataField("tallPseudoItem")] | ||
public bool TallPseudoItem = false; | ||
|
||
[DataField("tallCosmeticOnly")] | ||
public bool TallCosmeticOnly = true; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Content.Server/ADT/StationEvents/Components/TraderSpawnRuleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Content.Server.StationEvents.Events; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
namespace Content.Server.StationEvents.Components; | ||
|
||
[RegisterComponent, Access(typeof(TraderSpawnRule))] | ||
public sealed partial class TraderSpawnRuleComponent : Component | ||
{ | ||
[DataField("TraderShuttlePath")] | ||
public string TraderShuttlePath = "Maps/Shuttles/trader.yml"; | ||
} |
26 changes: 26 additions & 0 deletions
26
Content.Server/ADT/StationEvents/Events/TraderSpawnRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Robust.Server.GameObjects; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Map; | ||
using Content.Server.GameTicking.Rules.Components; | ||
using Content.Server.StationEvents.Components; | ||
|
||
namespace Content.Server.StationEvents.Events; | ||
|
||
public sealed class TraderSpawnRule : StationEventSystem<TraderSpawnRuleComponent> | ||
{ | ||
[Dependency] private readonly IMapManager _mapManager = default!; | ||
[Dependency] private readonly MapLoaderSystem _map = default!; | ||
|
||
protected override void Started(EntityUid uid, TraderSpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args) | ||
{ | ||
base.Started(uid, component, gameRule, args); | ||
var shuttleMap = _mapManager.CreateMap(); | ||
var options = new MapLoadOptions | ||
{ | ||
LoadMap = true, | ||
}; | ||
|
||
_map.TryLoad(shuttleMap, component.TraderShuttlePath, out _, options); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Content.Shared.ADT.Cloning; | ||
|
||
/// <summary> | ||
/// Indicates that this Component should be transferred to the new entity when the entity is cloned (for example, using a cloner) | ||
/// </summary> | ||
public interface ITransferredByCloning | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Shared.ADT.Cloning; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; | ||
|
||
namespace Content.Shared.Item.PseudoItem; | ||
/// <summary> | ||
/// For entities that behave like an item under certain conditions, | ||
/// but not under most conditions. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class PseudoItemComponent : Component, ITransferredByCloning | ||
{ | ||
[DataField("size", customTypeSerializer: typeof(PrototypeIdSerializer<ItemSizePrototype>))] | ||
public string Size = "Huge"; | ||
|
||
public bool Active = false; | ||
|
||
[DataField] | ||
public EntityUid? SleepAction; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.