This commit is contained in:
Rane
2022-04-23 21:05:02 -04:00
committed by GitHub
parent 18220b6488
commit 98cd4fdb58
44 changed files with 1160 additions and 15 deletions

View File

@@ -0,0 +1,16 @@
namespace Content.Shared.Vehicle.Components
{
/// <summary>
/// Added to objects inside a vehicle to stop people besides the rider from
/// removing them.
/// </summary>
[RegisterComponent]
public sealed class InVehicleComponent : Component
{
/// <summary>
/// The vehicle this rider is currently riding.
/// </summary>
[ViewVariables]
public VehicleComponent Vehicle = default!;
}
}

View File

@@ -0,0 +1,16 @@
namespace Content.Shared.Vehicle.Components
{
/// <summary>
/// Added to people when they are riding in a vehicle
/// used mostly to keep track of them for entityquery.
/// </summary>
[RegisterComponent]
public sealed class RiderComponent : Component
{
/// <summary>
/// The vehicle this rider is currently riding.
/// </summary>
[ViewVariables]
public VehicleComponent Vehicle = default!;
}
}

View File

@@ -0,0 +1,98 @@
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Sound;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Audio;
using Robust.Shared.Utility;
using Content.Shared.Whitelist;
namespace Content.Shared.Vehicle.Components
{
/// <summary>
/// This is particularly for vehicles that use
/// buckle. Stuff like clown cars may need a different
/// component at some point.
/// All vehicles should have Physics, Strap, and SharedPlayerInputMover components.
/// </summary>
[RegisterComponent]
public sealed class VehicleComponent : Component
{
/// <summary>
/// Whether someone is currently riding the vehicle
/// </summary
public bool HasRider = false;
/// <summary>
/// The entity currently riding the vehicle.
/// </summary>
[ViewVariables]
public EntityUid? Rider;
/// <summary>
/// Whether the vehicle should treat north as it's unique direction in its visualizer
/// </summary>
[DataField("northOnly")]
public bool NorthOnly = false;
/// <summary>
/// What the y buckle offset should be in north / south
/// </summary>
[DataField("northOverride")]
public float NorthOverride = 0f;
/// <summary>
/// What the y buckle offset should be in north / south
/// </summary>
[DataField("southOverride")]
public float SouthOverride = 0f;
/// <summary>
/// The base offset for the vehicle (when facing east)
/// </summary>
public Vector2 BaseBuckleOffset = Vector2.Zero;
/// <summary>
/// The sound that the horn makes
/// </summary>
[DataField("hornSound")]
public SoundSpecifier? HornSound = new SoundPathSpecifier("/Audio/Effects/Vehicle/carhorn.ogg");
/// <summary>
/// Whether the horn is a siren or not.
/// </summary>
[DataField("hornIsSiren")]
public bool HornIsLooping = false;
/// <summary>
/// If this vehicle has a siren currently playing.
/// </summary>
public bool LoopingHornIsPlaying = false;
public IPlayingAudioStream? SirenPlayingStream;
/// Use ambient sound component for the idle sound.
/// <summary>
/// The action for the horn (if any)
/// </summary>
[DataField("hornAction")]
public InstantAction HornAction = new()
{
UseDelay = TimeSpan.FromSeconds(3.4),
Icon = new SpriteSpecifier.Texture(new ResourcePath("Objects/Fun/bikehorn.rsi/icon.png")),
Name = "action-name-honk",
Description = "action-desc-honk",
Event = new HonkActionEvent(),
};
/// <summary>
/// The prototype ID of the key that was inserted so it can be
/// spawned when the key is removed.
/// </summary>
public ItemSlot KeySlot = new();
/// <summary>
/// Whether the vehicle has a key currently inside it or not.
/// </summary>
public bool HasKey = false;
}
}

View File

@@ -0,0 +1,51 @@
using Content.Shared.Vehicle.Components;
using Content.Shared.Actions;
using Content.Shared.Item;
using Robust.Shared.Serialization;
/// <summary>
/// Stores the VehicleVisuals and shared event
/// Nothing for a system but these need to be put somewhere in
/// Content.Shared
/// </summary>
namespace Content.Shared.Vehicle
{
public sealed class SharedVehicleSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<InVehicleComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
}
private void OnPickupAttempt(EntityUid uid, InVehicleComponent component, GettingPickedUpAttemptEvent args)
{
if (component.Vehicle == null || !component.Vehicle.HasRider)
return;
if (component.Vehicle.Rider != args.User)
args.Cancel();
}
}
/// <summary>
/// Stores the vehicle's draw depth mostly
/// </summary>
[Serializable, NetSerializable]
public enum VehicleVisuals : byte
{
/// <summary>
/// What layer the vehicle should draw on (assumed integer)
/// </summary>
DrawDepth,
/// <summary>
/// Whether the wheels should be turning
/// </summary>
AutoAnimate
}
/// <summary>
/// Raised when someone honks a vehicle horn
/// </summary>
public sealed class HonkActionEvent : InstantActionEvent { }
}