Ходить человек гусьмопсик давать деньги (#467)

Апдейт жукбокс системы
Добавлен волкман
This commit is contained in:
RavMorgan
2023-10-03 16:33:03 +03:00
committed by Aviu00
parent 8e3d2b3f22
commit a315c02107
12 changed files with 101 additions and 11 deletions

View File

@@ -26,14 +26,12 @@ public sealed class JukeboxSystem : EntitySystem
private readonly Dictionary<JukeboxComponent, JukeboxAudio> _playingJukeboxes = new();
private float _maxAudioRange;
private float _jukeboxVolume;
public override void Initialize()
{
base.Initialize();
_cfg.OnValueChanged(WhiteCVars.MaxJukeboxSoundRange, range => _maxAudioRange = range, true);
_cfg.OnValueChanged(WhiteCVars.JukeboxVolume, JukeboxVolumeChanged, true);
SubscribeLocalEvent<JukeboxComponent, ComponentHandleState>(OnStateChanged);
@@ -116,7 +114,7 @@ public sealed class JukeboxSystem : EntitySystem
foreach (var (jukeboxComponent, jukeboxXform) in jukeboxes)
{
if (jukeboxXform.MapID != playerXform.MapID || (jukeboxXform.MapPosition.Position - playerXform.MapPosition.Position).Length() > _maxAudioRange)
if (jukeboxXform.MapID != playerXform.MapID || (jukeboxXform.MapPosition.Position - playerXform.MapPosition.Position).Length() > jukeboxComponent.MaxAudioRange)
{
if (_playingJukeboxes.TryGetValue(jukeboxComponent, out var stream))
{
@@ -143,7 +141,7 @@ public sealed class JukeboxSystem : EntitySystem
continue;
}
SetOcclusion(playerXform, jukeboxXform, jukeboxAudio);
SetRolloffAndOcclusion(jukeboxComponent, playerXform, jukeboxXform, jukeboxAudio);
SetPosition(jukeboxXform, jukeboxAudio);
}
else
@@ -172,7 +170,7 @@ public sealed class JukeboxSystem : EntitySystem
jukeboxAudio.PlayingStream.Position = jukeboxXform.MapPosition.Position;
}
private void SetOcclusion(TransformComponent playerXform, TransformComponent jukeboxXform, JukeboxAudio jukeboxAudio)
private void SetRolloffAndOcclusion(JukeboxComponent jukeboxComponent, TransformComponent playerXform, TransformComponent jukeboxXform, JukeboxAudio jukeboxAudio)
{
var collisionMask = CollisionGroup.Impassable;
var sourceRelative = playerXform.MapPosition.Position - jukeboxXform.MapPosition.Position;
@@ -186,6 +184,7 @@ public sealed class JukeboxSystem : EntitySystem
}
jukeboxAudio.PlayingStream.Occlusion = occlusion;
jukeboxAudio.PlayingStream.RolloffFactor = (jukeboxXform.MapPosition.Position - playerXform.MapPosition.Position).Length() * jukeboxComponent.RolloffFactor;
}
private void HandleSongChanged(JukeboxAudio jukeboxAudio, JukeboxComponent jukeboxComponent, TransformComponent jukeboxXform, TransformComponent playerXform)
@@ -255,14 +254,13 @@ public sealed class JukeboxSystem : EntitySystem
return null!;
playingStream.Volume = _jukeboxVolume;
playingStream.RolloffFactor = 3.5f;
playingStream.PlaybackPosition = jukeboxComponent.PlayingSongData.PlaybackPosition;
playingStream.Position = jukeboxXform.MapPosition.Position;
var jukeboxAudio = new JukeboxAudio(playingStream!, audio, jukeboxComponent.PlayingSongData);
SetOcclusion(playerXform, jukeboxXform, jukeboxAudio);
SetRolloffAndOcclusion(jukeboxComponent, playerXform, jukeboxXform, jukeboxAudio);
playingStream.StartPlaying();
return jukeboxAudio;

View File

@@ -40,9 +40,15 @@ public sealed partial class JukeboxComponent : Component
[ViewVariables(VVAccess.ReadOnly)]
public bool Repeating { get; set; } = true;
[ViewVariables(VVAccess.ReadOnly)]
[DataField("volume") ,ViewVariables(VVAccess.ReadOnly)]
public float Volume { get; set; }
[DataField("maxAudioRange")]
public float MaxAudioRange { get; set; } = 20f;
[DataField("rolloffFactor")]
public float RolloffFactor { get; set; } = 0.3f;
public PlayingSongData? PlayingSongData { get; set; }
}

View File

@@ -186,9 +186,6 @@ public sealed class WhiteCVars
public static readonly CVarDef<float> MaxJukeboxSongSizeInMb = CVarDef.Create("white.max_jukebox_song_size",
3.5f, CVar.SERVER | CVar.REPLICATED | CVar.ARCHIVE);
public static readonly CVarDef<float> MaxJukeboxSoundRange = CVarDef.Create("white.max_jukebox_sound_range", 20f,
CVar.SERVER | CVar.REPLICATED | CVar.ARCHIVE);
public static readonly CVarDef<float> JukeboxVolume =
CVarDef.Create("white.jukebox_volume", 0f, CVar.CLIENTONLY | CVar.ARCHIVE);

View File

@@ -7,3 +7,7 @@ ent-TapeRecorder = Мысль
ent-TapeEmpty = Аудиокассета
.desc = Старая аудиокассета, возможно на ней что-то есть.
.suffix = { "" }
ent-Walkman = Портативный аудиоплеер
.desc = Удобно крепится на пояс.
.suffix = { "" }

View File

@@ -1838,6 +1838,21 @@
- !type:DonationTierLockCondition
tier: 5
- type: listing
id: DjWalkman
productEntity: Walkman
cost:
MeatyOreCoin: 0
categories:
- DjJukeboxCategory
conditions:
- !type:ListingLimitedStockCondition
stock: 1
- !type:DonationTierLockCondition
tier: 5
- type: listing
id: DjTapeRecorder
productEntity: TapeRecorder

View File

@@ -6,6 +6,7 @@
suffix: Empty
components:
- type: Jukebox
maxAudioRange: 15
- type: Sprite
sprite: White/Objects/Devices/jukebox.rsi
layers:
@@ -28,6 +29,38 @@
jukebox_tapes: !type:Container
jukebox_default_tapes: !type:Container
- type: entity
parent: ClothingBeltBase
id: Walkman
name: Walkman
description: Mini cassette player
suffix: Empty
components:
- type: Jukebox
maxAudioRange: 5
rolloffFactor: 3.5
- type: Sprite
sprite: White/Objects/Devices/walkman.rsi
layers:
- state: walkman
- state: walkman_working_overlay
map: [ "bars" ]
- type: Item
sprite: White/Objects/Devices/walkman.rsi
heldPrefix: walkman
size: 20
- type: UserInterface
interfaces:
- key: enum.JukeboxUIKey.Key
type: JukeboxBUI
- type: ActivatableUI
key: enum.JukeboxUIKey.Key
- type: ContainerContainer
containers:
jukebox_tapes: !type:Container
jukebox_default_tapes: !type:Container
- type: entity
parent: BaseItem
id: TapeRecorder

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

View File

@@ -0,0 +1,37 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC0-1.0",
"copyright": "ГусьМопсик",
"states": [
{
"name": "walkman_working_overlay",
"delays": [
[
0.1,
0.1,
0.1,
0.1
]
]
},
{
"name": "equipped-BELT",
"directions": 4
},
{
"name": "walkman"
},
{
"name": "walkman-inhand-right",
"directions": 4
},
{
"name": "walkman-inhand-left",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B