Refactors, bugfixs + Crystals (#127)

* fix dwarf displacement map

* Big Fireplace update

* add crystalls placeholder

* bonfire update

* displaccement update

* Update wallmount_torch.yml
This commit is contained in:
Ed
2024-05-03 20:40:31 +03:00
committed by GitHub
parent e5246f1e76
commit dd84d48fed
38 changed files with 365 additions and 94 deletions

View File

@@ -77,5 +77,11 @@ namespace Content.Server.Atmos.Components
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float FirestackFade = -0.1f;
/// <summary>
/// CrystallPunk fireplace fuel
/// </summary>
[DataField]
public float CP14FireplaceFuel = 10f;
}
}

View File

@@ -39,7 +39,7 @@ public sealed class RandomSpriteSystem: SharedRandomSpriteSystem
component.Selected.EnsureCapacity(groups.Count);
Color? previousColor = null;
Color? previousColor = component.CP14InheritBaseColor; //CrystallPunk
foreach (var group in groups)
{

View File

@@ -1,3 +1,5 @@
using Robust.Shared.Audio;
namespace Content.Server._CP14.Temperature.Fireplace;
/// <summary>
@@ -7,6 +9,9 @@ namespace Content.Server._CP14.Temperature.Fireplace;
[RegisterComponent, Access(typeof(CP14FireplaceSystem))]
public sealed partial class CP14FireplaceComponent : Component
{
[DataField]
public string ContainerId = "storagebase";
/// <summary>
/// The abstract amount of fuel that is used to keep a fire burning
/// </summary>
@@ -23,7 +28,7 @@ public sealed partial class CP14FireplaceComponent : Component
/// current fuel quantity
/// </summary>
[DataField]
public float CurrentFuel;
public float CurrentFuel = 10f;
/// <summary>
/// how much fuel is wasted every "UpdateFrequency"
@@ -34,18 +39,9 @@ public sealed partial class CP14FireplaceComponent : Component
[DataField]
public TimeSpan UpdateFrequency = TimeSpan.FromSeconds(2f);
/// <summary>
/// whether fuel can be added by hand
/// </summary>
[DataField]
public bool CanInsertByHand = true;
/// <summary>
/// whether the fuel can be supplied by contact
/// </summary>
[DataField]
public bool CanInsertByCollide = false;
[DataField]
public TimeSpan NextUpdateTime = TimeSpan.Zero;
[DataField]
public SoundSpecifier InsertFuelSound = new SoundPathSpecifier("/Audio/_CP14/Items/campfire_whoosh.ogg");
}

View File

@@ -1,20 +0,0 @@
using Robust.Shared.Audio;
namespace Content.Server._CP14.Temperature.Fireplace;
/// <summary>
/// Allows this object to be used as fuel for a fireplace
/// </summary>
[RegisterComponent, Access(typeof(CP14FireplaceSystem))]
public sealed partial class CP14FireplaceFuelComponent : Component
{
/// <summary>
/// How much fuel will be added in fireplace
/// </summary>
[DataField]
public float Fuel = 10f;
[DataField]
public SoundSpecifier InsertFuelSound = new SoundPathSpecifier("/Audio/_CP14/Items/campfire_whoosh.ogg");
}

View File

@@ -5,6 +5,7 @@ using Content.Shared._CP14.Temperature;
using Content.Shared.Interaction;
using Content.Shared.Throwing;
using Robust.Server.Audio;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Physics.Events;
using Robust.Shared.Timing;
@@ -15,6 +16,7 @@ public sealed partial class CP14FireplaceSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly FlammableSystem _flammable = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
@@ -24,9 +26,6 @@ public sealed partial class CP14FireplaceSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent<CP14FireplaceComponent, OnFireChangedEvent>(OnFireChanged);
SubscribeLocalEvent<CP14FireplaceComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<CP14FireplaceComponent, StartCollideEvent>(OnCollide);
}
private void OnFireChanged(Entity<CP14FireplaceComponent> fireplace, ref OnFireChangedEvent args)
@@ -38,47 +37,37 @@ public sealed partial class CP14FireplaceSystem : EntitySystem
flammable.FirestackFade = 0;
}
private void OnInteractUsing(Entity<CP14FireplaceComponent> fireplace, ref InteractUsingEvent args)
private bool TryFoundFuelInStorage(Entity<CP14FireplaceComponent> fireplace, out Entity<FlammableComponent>? fuel)
{
if (!fireplace.Comp.CanInsertByHand)
return;
fuel = null;
var container = _containerSystem.GetContainer(fireplace, fireplace.Comp.ContainerId);
if (!TryComp<CP14FireplaceFuelComponent>(args.Used, out var fuel))
return;
TryInsertFuel(fireplace, args.Used, fuel);
}
private void OnCollide(Entity<CP14FireplaceComponent> fireplace, ref StartCollideEvent args)
{
if (!fireplace.Comp.CanInsertByCollide)
return;
if (!TryComp<CP14FireplaceFuelComponent>(args.OtherEntity, out var fuel))
return;
TryInsertFuel(fireplace, args.OtherEntity, fuel);
}
private bool TryInsertFuel(Entity<CP14FireplaceComponent> fireplace, EntityUid fuelUid, CP14FireplaceFuelComponent fuel)
{
if (fireplace.Comp.CurrentFuel > fireplace.Comp.MaxFuelLimit)
{
_popupSystem.PopupEntity(Loc.GetString("cp14-fireplace-full", ("target", fireplace)), fireplace);
if (container.ContainedEntities.Count == 0)
return false;
foreach (var ent in container.ContainedEntities)
{
if (!TryComp<FlammableComponent>(ent, out var flammable))
continue;
fuel = new Entity<FlammableComponent>(ent, flammable);
return true;
}
if (!TryComp<FlammableComponent>(fireplace, out var flammable))
return false;
return false;
}
fireplace.Comp.CurrentFuel += fuel.Fuel;
private void ConsumeFuel(EntityUid uid, CP14FireplaceComponent component, Entity<FlammableComponent> fuel)
{
if (!TryComp<FlammableComponent>(uid, out var flammable))
return;
component.CurrentFuel += fuel.Comp.CP14FireplaceFuel;
if (flammable.OnFire)
_audio.PlayPvs(fuel.InsertFuelSound, fireplace);
_audio.PlayPvs(component.InsertFuelSound, uid);
UpdateAppearance(fireplace, fireplace.Comp);
QueueDel(fuelUid);
return true;
QueueDel(fuel);
}
public override void Update(float frameTime)
@@ -104,6 +93,9 @@ public sealed partial class CP14FireplaceSystem : EntitySystem
}
else
{
if (TryFoundFuelInStorage(new Entity<CP14FireplaceComponent>(uid, fireplace), out var fuel) && fuel != null)
ConsumeFuel(uid, fireplace, fuel.Value);
flammable.FirestackFade = -fireplace.FireFadeDelta;
}
}