Fix and update VehicleSystem.cs (#15284)
This commit is contained in:
@@ -7,6 +7,7 @@ using Content.Shared.Movement.Components;
|
|||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
using Content.Shared.Vehicle;
|
using Content.Shared.Vehicle;
|
||||||
using Content.Shared.Vehicle.Components;
|
using Content.Shared.Vehicle.Components;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Physics.Systems;
|
using Robust.Shared.Physics.Systems;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -89,7 +90,8 @@ namespace Content.Server.Vehicle
|
|||||||
|
|
||||||
// Update appearance stuff, add actions
|
// Update appearance stuff, add actions
|
||||||
UpdateBuckleOffset(Transform(uid), component);
|
UpdateBuckleOffset(Transform(uid), component);
|
||||||
UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component.NorthOnly));
|
if (TryComp<InputMoverComponent>(uid, out var mover))
|
||||||
|
UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component, mover.RelativeRotation.Degrees));
|
||||||
|
|
||||||
if (TryComp<ActionsComponent>(args.BuckledEntity, out var actions) && TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
if (TryComp<ActionsComponent>(args.BuckledEntity, out var actions) && TryComp<UnpoweredFlashlightComponent>(uid, out var flashlight))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,15 +58,24 @@ namespace Content.Shared.Vehicle.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the vehicle has a key currently inside it or not.
|
/// Whether the vehicle has a key currently inside it or not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[DataField("hasKey")]
|
||||||
public bool HasKey = false;
|
public bool HasKey = false;
|
||||||
|
|
||||||
// TODO: Fix this
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the vehicle should treat north as its unique direction in its visualizer
|
/// Determines from which side the vehicle will be displayed on top of the player.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("northOnly")]
|
|
||||||
public bool NorthOnly = false;
|
[DataField("southOver")]
|
||||||
|
public bool SouthOver = false;
|
||||||
|
|
||||||
|
[DataField("northOver")]
|
||||||
|
public bool NorthOver = false;
|
||||||
|
|
||||||
|
[DataField("westOver")]
|
||||||
|
public bool WestOver = false;
|
||||||
|
|
||||||
|
[DataField("eastOver")]
|
||||||
|
public bool EastOver = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// What the y buckle offset should be in north / south
|
/// What the y buckle offset should be in north / south
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ using Robust.Shared.Serialization;
|
|||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Content.Shared.Tag;
|
using Content.Shared.Tag;
|
||||||
using Content.Shared.Audio;
|
using Content.Shared.Audio;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Content.Shared.Vehicle;
|
namespace Content.Shared.Vehicle;
|
||||||
|
|
||||||
@@ -50,7 +51,8 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
private void OnEntInserted(EntityUid uid, VehicleComponent component, EntInsertedIntoContainerMessage args)
|
private void OnEntInserted(EntityUid uid, VehicleComponent component, EntInsertedIntoContainerMessage args)
|
||||||
{
|
{
|
||||||
if (args.Container.ID != KeySlot ||
|
if (args.Container.ID != KeySlot ||
|
||||||
!_tagSystem.HasTag(args.Entity, "VehicleKey")) return;
|
!_tagSystem.HasTag(args.Entity, "VehicleKey"))
|
||||||
|
return;
|
||||||
|
|
||||||
// Enable vehicle
|
// Enable vehicle
|
||||||
var inVehicle = EnsureComp<InVehicleComponent>(args.Entity);
|
var inVehicle = EnsureComp<InVehicleComponent>(args.Entity);
|
||||||
@@ -107,7 +109,8 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateBuckleOffset(args.Component, component);
|
UpdateBuckleOffset(args.Component, component);
|
||||||
UpdateDrawDepth(uid, GetDrawDepth(args.Component, component.NorthOnly));
|
if (TryComp<InputMoverComponent>(uid, out var mover))
|
||||||
|
UpdateDrawDepth(uid, GetDrawDepth(args.Component, component, mover.RelativeRotation));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnVehicleStartup(EntityUid uid, VehicleComponent component, ComponentStartup args)
|
private void OnVehicleStartup(EntityUid uid, VehicleComponent component, ComponentStartup args)
|
||||||
@@ -129,26 +132,36 @@ public abstract partial class SharedVehicleSystem : EntitySystem
|
|||||||
/// change its draw depth. Vehicles can choose between special drawdetph
|
/// change its draw depth. Vehicles can choose between special drawdetph
|
||||||
/// when facing north or south. East and west are easy.
|
/// when facing north or south. East and west are easy.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int GetDrawDepth(TransformComponent xform, bool northOnly)
|
protected int GetDrawDepth(TransformComponent xform, VehicleComponent component, Angle cameraAngle)
|
||||||
{
|
{
|
||||||
// TODO: I can't even
|
var itemDirection = cameraAngle.GetDir() switch
|
||||||
if (northOnly)
|
|
||||||
{
|
{
|
||||||
return xform.LocalRotation.Degrees switch
|
Direction.South => xform.LocalRotation.GetDir(),
|
||||||
{
|
Direction.North => xform.LocalRotation.RotateDir(Direction.North),
|
||||||
< 135f => (int) DrawDepth.DrawDepth.Doors,
|
Direction.West => xform.LocalRotation.RotateDir(Direction.East),
|
||||||
<= 225f => (int) DrawDepth.DrawDepth.WallMountedItems,
|
Direction.East => xform.LocalRotation.RotateDir(Direction.West),
|
||||||
_ => 5
|
_ => Direction.South
|
||||||
};
|
};
|
||||||
}
|
|
||||||
return xform.LocalRotation.Degrees switch
|
return itemDirection switch
|
||||||
{
|
{
|
||||||
< 45f => (int) DrawDepth.DrawDepth.Doors,
|
Direction.North => component.NorthOver
|
||||||
<= 315f => (int) DrawDepth.DrawDepth.WallMountedItems,
|
? (int) DrawDepth.DrawDepth.Doors
|
||||||
_ => (int) DrawDepth.DrawDepth.Doors,
|
: (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||||
|
Direction.South => component.SouthOver
|
||||||
|
? (int) DrawDepth.DrawDepth.Doors
|
||||||
|
: (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||||
|
Direction.West => component.WestOver
|
||||||
|
? (int) DrawDepth.DrawDepth.Doors
|
||||||
|
: (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||||
|
Direction.East => component.EastOver
|
||||||
|
? (int) DrawDepth.DrawDepth.Doors
|
||||||
|
: (int) DrawDepth.DrawDepth.WallMountedItems,
|
||||||
|
_ => (int) DrawDepth.DrawDepth.WallMountedItems
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change the buckle offset based on what direction the vehicle is facing and
|
/// Change the buckle offset based on what direction the vehicle is facing and
|
||||||
/// teleport any buckled entities to it. This is the most crucial part of making
|
/// teleport any buckled entities to it. This is the most crucial part of making
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 750 # Grand Theft Auto.
|
price: 750 # Grand Theft Auto.
|
||||||
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: VehicleJanicart
|
id: VehicleJanicart
|
||||||
parent: BaseVehicle
|
parent: BaseVehicle
|
||||||
@@ -86,6 +87,9 @@
|
|||||||
description: The janitor's trusty steed.
|
description: The janitor's trusty steed.
|
||||||
components:
|
components:
|
||||||
- type: Vehicle
|
- type: Vehicle
|
||||||
|
southOver: true
|
||||||
|
westOver: true
|
||||||
|
eastOver: true
|
||||||
northOverride: -0.15
|
northOverride: -0.15
|
||||||
southOverride: 0.22
|
southOverride: 0.22
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -175,7 +179,9 @@
|
|||||||
description: The future of transportation. Popularized by St. James, the patron saint of security officers and internet forum moderators.
|
description: The future of transportation. Popularized by St. James, the patron saint of security officers and internet forum moderators.
|
||||||
components:
|
components:
|
||||||
- type: Vehicle
|
- type: Vehicle
|
||||||
northOnly: true
|
northOver: true
|
||||||
|
westOver: true
|
||||||
|
eastOver: true
|
||||||
northOverride: -0.1
|
northOverride: -0.1
|
||||||
southOverride: 0.1
|
southOverride: 0.1
|
||||||
hornSound:
|
hornSound:
|
||||||
@@ -222,6 +228,8 @@
|
|||||||
description: All-Tile Vehicle.
|
description: All-Tile Vehicle.
|
||||||
components:
|
components:
|
||||||
- type: Vehicle
|
- type: Vehicle
|
||||||
|
southOver: true
|
||||||
|
northOver: true
|
||||||
northOverride: -0.1
|
northOverride: -0.1
|
||||||
southOverride: 0.1
|
southOverride: 0.1
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -275,7 +283,9 @@
|
|||||||
description: Be an enemy of the corporation, in style.
|
description: Be an enemy of the corporation, in style.
|
||||||
components:
|
components:
|
||||||
- type: Vehicle
|
- type: Vehicle
|
||||||
northOnly: true
|
southOver: true
|
||||||
|
westOver: true
|
||||||
|
eastOver: true
|
||||||
northOverride: -0.1
|
northOverride: -0.1
|
||||||
southOverride: 0.1
|
southOverride: 0.1
|
||||||
hornSound:
|
hornSound:
|
||||||
@@ -317,6 +327,8 @@
|
|||||||
description: Bad to the Bone.
|
description: Bad to the Bone.
|
||||||
components:
|
components:
|
||||||
- type: Vehicle
|
- type: Vehicle
|
||||||
|
southOver: true
|
||||||
|
northOver: true
|
||||||
northOverride: -0.1
|
northOverride: -0.1
|
||||||
southOverride: 0.1
|
southOverride: 0.1
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
|||||||
Reference in New Issue
Block a user