Ходить человек гусьмопсик давать деньги (#467)
Апдейт жукбокс системы Добавлен волкман
This commit is contained in:
@@ -26,14 +26,12 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
|
|
||||||
private readonly Dictionary<JukeboxComponent, JukeboxAudio> _playingJukeboxes = new();
|
private readonly Dictionary<JukeboxComponent, JukeboxAudio> _playingJukeboxes = new();
|
||||||
|
|
||||||
private float _maxAudioRange;
|
|
||||||
private float _jukeboxVolume;
|
private float _jukeboxVolume;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
_cfg.OnValueChanged(WhiteCVars.MaxJukeboxSoundRange, range => _maxAudioRange = range, true);
|
|
||||||
_cfg.OnValueChanged(WhiteCVars.JukeboxVolume, JukeboxVolumeChanged, true);
|
_cfg.OnValueChanged(WhiteCVars.JukeboxVolume, JukeboxVolumeChanged, true);
|
||||||
|
|
||||||
SubscribeLocalEvent<JukeboxComponent, ComponentHandleState>(OnStateChanged);
|
SubscribeLocalEvent<JukeboxComponent, ComponentHandleState>(OnStateChanged);
|
||||||
@@ -116,7 +114,7 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
foreach (var (jukeboxComponent, jukeboxXform) in jukeboxes)
|
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))
|
if (_playingJukeboxes.TryGetValue(jukeboxComponent, out var stream))
|
||||||
{
|
{
|
||||||
@@ -143,7 +141,7 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetOcclusion(playerXform, jukeboxXform, jukeboxAudio);
|
SetRolloffAndOcclusion(jukeboxComponent, playerXform, jukeboxXform, jukeboxAudio);
|
||||||
SetPosition(jukeboxXform, jukeboxAudio);
|
SetPosition(jukeboxXform, jukeboxAudio);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -172,7 +170,7 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
jukeboxAudio.PlayingStream.Position = jukeboxXform.MapPosition.Position;
|
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 collisionMask = CollisionGroup.Impassable;
|
||||||
var sourceRelative = playerXform.MapPosition.Position - jukeboxXform.MapPosition.Position;
|
var sourceRelative = playerXform.MapPosition.Position - jukeboxXform.MapPosition.Position;
|
||||||
@@ -186,6 +184,7 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
jukeboxAudio.PlayingStream.Occlusion = occlusion;
|
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)
|
private void HandleSongChanged(JukeboxAudio jukeboxAudio, JukeboxComponent jukeboxComponent, TransformComponent jukeboxXform, TransformComponent playerXform)
|
||||||
@@ -255,14 +254,13 @@ public sealed class JukeboxSystem : EntitySystem
|
|||||||
return null!;
|
return null!;
|
||||||
|
|
||||||
playingStream.Volume = _jukeboxVolume;
|
playingStream.Volume = _jukeboxVolume;
|
||||||
playingStream.RolloffFactor = 3.5f;
|
|
||||||
playingStream.PlaybackPosition = jukeboxComponent.PlayingSongData.PlaybackPosition;
|
playingStream.PlaybackPosition = jukeboxComponent.PlayingSongData.PlaybackPosition;
|
||||||
|
|
||||||
playingStream.Position = jukeboxXform.MapPosition.Position;
|
playingStream.Position = jukeboxXform.MapPosition.Position;
|
||||||
|
|
||||||
var jukeboxAudio = new JukeboxAudio(playingStream!, audio, jukeboxComponent.PlayingSongData);
|
var jukeboxAudio = new JukeboxAudio(playingStream!, audio, jukeboxComponent.PlayingSongData);
|
||||||
|
|
||||||
SetOcclusion(playerXform, jukeboxXform, jukeboxAudio);
|
SetRolloffAndOcclusion(jukeboxComponent, playerXform, jukeboxXform, jukeboxAudio);
|
||||||
playingStream.StartPlaying();
|
playingStream.StartPlaying();
|
||||||
|
|
||||||
return jukeboxAudio;
|
return jukeboxAudio;
|
||||||
|
|||||||
@@ -40,9 +40,15 @@ public sealed partial class JukeboxComponent : Component
|
|||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
public bool Repeating { get; set; } = true;
|
public bool Repeating { get; set; } = true;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[DataField("volume") ,ViewVariables(VVAccess.ReadOnly)]
|
||||||
public float Volume { get; set; }
|
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; }
|
public PlayingSongData? PlayingSongData { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,9 +186,6 @@ public sealed class WhiteCVars
|
|||||||
public static readonly CVarDef<float> MaxJukeboxSongSizeInMb = CVarDef.Create("white.max_jukebox_song_size",
|
public static readonly CVarDef<float> MaxJukeboxSongSizeInMb = CVarDef.Create("white.max_jukebox_song_size",
|
||||||
3.5f, CVar.SERVER | CVar.REPLICATED | CVar.ARCHIVE);
|
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 =
|
public static readonly CVarDef<float> JukeboxVolume =
|
||||||
CVarDef.Create("white.jukebox_volume", 0f, CVar.CLIENTONLY | CVar.ARCHIVE);
|
CVarDef.Create("white.jukebox_volume", 0f, CVar.CLIENTONLY | CVar.ARCHIVE);
|
||||||
|
|
||||||
|
|||||||
@@ -7,3 +7,7 @@ ent-TapeRecorder = Мысль
|
|||||||
ent-TapeEmpty = Аудиокассета
|
ent-TapeEmpty = Аудиокассета
|
||||||
.desc = Старая аудиокассета, возможно на ней что-то есть.
|
.desc = Старая аудиокассета, возможно на ней что-то есть.
|
||||||
.suffix = { "" }
|
.suffix = { "" }
|
||||||
|
|
||||||
|
ent-Walkman = Портативный аудиоплеер
|
||||||
|
.desc = Удобно крепится на пояс.
|
||||||
|
.suffix = { "" }
|
||||||
|
|||||||
@@ -1838,6 +1838,21 @@
|
|||||||
- !type:DonationTierLockCondition
|
- !type:DonationTierLockCondition
|
||||||
tier: 5
|
tier: 5
|
||||||
|
|
||||||
|
- type: listing
|
||||||
|
id: DjWalkman
|
||||||
|
productEntity: Walkman
|
||||||
|
cost:
|
||||||
|
MeatyOreCoin: 0
|
||||||
|
categories:
|
||||||
|
- DjJukeboxCategory
|
||||||
|
conditions:
|
||||||
|
- !type:ListingLimitedStockCondition
|
||||||
|
stock: 1
|
||||||
|
- !type:DonationTierLockCondition
|
||||||
|
tier: 5
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- type: listing
|
- type: listing
|
||||||
id: DjTapeRecorder
|
id: DjTapeRecorder
|
||||||
productEntity: TapeRecorder
|
productEntity: TapeRecorder
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
suffix: Empty
|
suffix: Empty
|
||||||
components:
|
components:
|
||||||
- type: Jukebox
|
- type: Jukebox
|
||||||
|
maxAudioRange: 15
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: White/Objects/Devices/jukebox.rsi
|
sprite: White/Objects/Devices/jukebox.rsi
|
||||||
layers:
|
layers:
|
||||||
@@ -28,6 +29,38 @@
|
|||||||
jukebox_tapes: !type:Container
|
jukebox_tapes: !type:Container
|
||||||
jukebox_default_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
|
- type: entity
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: TapeRecorder
|
id: TapeRecorder
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 384 B |
@@ -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 |
BIN
Resources/Textures/White/Objects/Devices/walkman.rsi/walkman.png
Normal file
BIN
Resources/Textures/White/Objects/Devices/walkman.rsi/walkman.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 589 B |
Binary file not shown.
|
After Width: | Height: | Size: 184 B |
Reference in New Issue
Block a user