Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play Sound Instruction for World Logic #9736

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2387963
hell
Mythril382 Jan 20, 2024
eed30eb
hell
Mythril382 Jan 20, 2024
1edfd9b
issue
Mythril382 Jan 20, 2024
2b0653b
aaaa
Mythril382 Jan 20, 2024
57e317f
foror
Mythril382 Jan 20, 2024
11f9052
Merge branch 'Anuken:master' into do-you-hear-the-voices-too
Mythril382 Mar 11, 2024
03e9c86
Merge branch 'Anuken:master' into do-you-hear-the-voices-too
Mythril382 Apr 12, 2024
05d499f
bingor
Mythril382 Apr 12, 2024
63783a1
why don't you do this by default
Mythril382 Apr 12, 2024
38b5ce0
i have no idea how to do this automatically
Mythril382 Apr 12, 2024
7510628
forgor
Mythril382 Apr 12, 2024
e9a4699
the ctrl+c ctrl+v is real
Mythril382 Apr 12, 2024
780f13b
el ui
Mythril382 Apr 12, 2024
67fc5ba
h
Mythril382 Apr 12, 2024
c77b866
much error
Mythril382 Apr 12, 2024
74cf56d
h
Mythril382 Apr 12, 2024
23aa93f
rear
Mythril382 Apr 12, 2024
753e992
slight desktop issue
Mythril382 Apr 12, 2024
64986a5
tooltip
Mythril382 Apr 12, 2024
bc2be5d
Delete core/src/mindustry/logic/LogicSound.java
Mythril382 May 26, 2024
7f80a18
sound id
Mythril382 May 26, 2024
ce56c1d
it is 3:40 am right now
Mythril382 May 26, 2024
d24f031
it's 4:14, i should sleep
Mythril382 May 26, 2024
580d35c
the arc pr
Mythril382 May 27, 2024
dbb62bd
nullcheck
Mythril382 May 27, 2024
ff35e6a
mythril that's a seq, NOT an objectmap
Mythril382 May 27, 2024
0067af0
changes
Mythril382 May 27, 2024
5e3ee08
remove that
Mythril382 May 27, 2024
41e2183
Merge branch 'master' into do-you-hear-the-voices-too
Mythril382 May 27, 2024
30480a6
wack
Mythril382 Jun 2, 2024
0397d3b
Merge branch 'master' into do-you-hear-the-voices-too
Mythril382 Jun 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/assets/bundles/bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2366,6 +2366,7 @@ lst.getflag = Check if a global flag is set.
lst.setprop = Sets a property of a unit or building.
lst.effect = Create a particle effect.
lst.sync = Sync a variable across the network.\nLimited to 20 times a second per variable.
lst.playsound = Plays a sound either at input position\nif positional or anywhere if global.
lst.makemarker = Create a new logic marker in the world.\nAn ID to identify this marker must be provided.\nMarkers currently limited to 20,000 per world.
lst.setmarker = Set a property for a marker.\nThe ID used must be the same as in the Make Marker instruction.\n[accent]null []values are ignored.
lst.localeprint = Add map locale property value to the text buffer.\nTo set map locale bundles in map editor, check [accent]Map Info > Locale Bundles[].\nIf client is a mobile device, tries to print a property ending in ".mobile" first.
Expand Down
1 change: 1 addition & 0 deletions core/assets/contributors
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,4 @@ OpalSoPL
BalaM314
Redstonneur1256
ApsZoldat
Mythril382
28 changes: 28 additions & 0 deletions core/src/mindustry/logic/LExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,34 @@ public void run(LExecutor exec){
}
}

public static class PlaySoundI implements LInstruction{
public boolean positional;
public LogicSound sound;
public int volume, pitch, pan, x, y;

public PlaySoundI(){
}

public PlaySoundI(boolean positional, LogicSound sound, int volume, int pitch, int pan, int x, int y){
this.positional = positional;
this.sound = sound;
this.volume = volume;
this.pitch = pitch;
this.pan = pan;
this.x = x;
this.y = y;
}

@Override
public void run(LExecutor exec){
if(positional){
sound.sound.at(World.unconv(exec.numf(x)), World.unconv(exec.numf(y)), exec.numf(pitch), exec.numf(volume));
}else{
sound.sound.play(exec.numf(volume) * (Core.settings.getInt("sfxvol") / 100f), exec.numf(pitch), exec.numf(pan));
}
}
}

public static class SetMarkerI implements LInstruction{
public LMarkerControl type = LMarkerControl.pos;
public int id, p1, p2, p3;
Expand Down
67 changes: 67 additions & 0 deletions core/src/mindustry/logic/LStatements.java
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,73 @@ public LCategory category(){
return LCategory.world;
}
}

@RegisterStatement("playsound")
public static class PlaySoundStatement extends LStatement{
public boolean positional;
public LogicSound sound = LogicSound.pew;
public String volume = "1", pitch = "1", pan = "0", x = "@thisx", y = "@thisy";

@Override
public void build(Table table){
rebuild(table);
}

void rebuild(Table table){
table.clearChildren();

table.button(positional ? "positional" : "global", Styles.logict, () -> {
positional = !positional;
rebuild(table);
}).size(160f, 40f).pad(4f).color(table.color);

row(table);

table.add("play");

table.button(b -> {
b.label(() -> sound.name());
b.clicked(() -> showSelect(b, LogicSound.all, sound, s -> {
sound = s;
rebuild(table);
}, 3, cell -> cell.size(150, 50)));
}, Styles.logict, () -> {}).size(190, 40).color(table.color).left().padLeft(2);

row(table);

fieldst(table, "volume", volume, str -> volume = str);
fieldst(table, "pitch", pitch, str -> pitch = str);

table.row();

if(positional){
table.add("at ");

fields(table, x, str -> x = str);

table.add(", ");

fields(table, y, str -> y = str);
}else{
fieldst(table, "pan", pan, str -> pan = str);
}
}

@Override
public boolean privileged(){
return true;
}

@Override
public LInstruction build(LAssembler builder){
return new PlaySoundI(positional, sound, builder.var(volume), builder.var(pitch), builder.var(pan), builder.var(x), builder.var(y));
}

@Override
public LCategory category(){
return LCategory.world;
}
}

@RegisterStatement("setmarker")
public static class SetMarkerStatement extends LStatement{
Expand Down
113 changes: 113 additions & 0 deletions core/src/mindustry/logic/LogicSound.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package mindustry.logic;

import arc.audio.*;
import mindustry.gen.*;

public enum LogicSound{
Mythril382 marked this conversation as resolved.
Show resolved Hide resolved
artillery(Sounds.artillery),
bang(Sounds.bang),
bigshot(Sounds.bigshot),
blaster(Sounds.blaster),
bolt(Sounds.bolt),
boom(Sounds.boom),
breakBlock(Sounds.breaks),
buttonClick(Sounds.buttonClick),
cannon(Sounds.cannon),
cannonLarge(Sounds.largeCannon),
click(Sounds.click),
coreExplode(Sounds.corexplode),
door(Sounds.door),
drillImpact(Sounds.drillImpact),
explosion(Sounds.explosion),
explosionBig(Sounds.explosionbig),
explosionDull(Sounds.dullExplosion),
explosionLarge(Sounds.largeExplosion),
explosionTitan(Sounds.titanExplosion),
flame(Sounds.flame),
flame2(Sounds.flame2),
laser(Sounds.laser),
laserBig(Sounds.laserbig),
laserCharge(Sounds.lasercharge),
laserCharge2(Sounds.lasercharge2),
laserShoot(Sounds.lasershoot),
malignShoot(Sounds.malignShoot),
mineDeploy(Sounds.mineDeploy),
missile(Sounds.missile),
missileLarge(Sounds.missileLarge),
missileLaunch(Sounds.missileLaunch),
missileSmall(Sounds.missileSmall),
mud(Sounds.mud),
noAmmo(Sounds.noammo),
pew(Sounds.pew),
place(Sounds.place),
plantBreak(Sounds.plantBreak),
plasmaBoom(Sounds.plasmaboom),
plasmaDrop(Sounds.plasmadrop),
pulseBlast(Sounds.pulseBlast),
railgun(Sounds.railgun),
release(Sounds.release),
respawn(Sounds.respawn),
rockBreak(Sounds.rockBreak),
sap(Sounds.sap),
shockBlast(Sounds.shockBlast),
shoot(Sounds.shoot),
shootAlt(Sounds.shootAlt),
shootAltLong(Sounds.shootAltLong),
shootBig(Sounds.shootBig),
shootSmite(Sounds.shootSmite),
shootSnap(Sounds.shootSnap),
shotgun(Sounds.shotgun),
spark(Sounds.spark),
splash(Sounds.splash),
wave(Sounds.wave),
wind3(Sounds.wind3),

beamLoop(Sounds.beam),
bioLoop(Sounds.bioLoop),
buildLoop(Sounds.build),
combustionLoop(Sounds.combustion),
conveyorLoop(Sounds.conveyor),
cutterLoop(Sounds.cutter),
drillLoop(Sounds.drill),
drillChargeLoop(Sounds.drillCharge),
extractLoop(Sounds.extractLoop),
fireLoop(Sounds.fire),
fluxLoop(Sounds.flux),
glowLoop(Sounds.glow),
grindingLoop(Sounds.grinding),
humLoop(Sounds.hum),
humElectricLoop(Sounds.electricHum),
laserBeamLoop(Sounds.laserbeam),
machineLoop(Sounds.machine),
mineBeamLoop(Sounds.minebeam),
missileTrailLoop(Sounds.missileTrail),
pulseLoop(Sounds.pulse),
rainLoop(Sounds.rain),
respawnLoop(Sounds.respawning),
shieldLoop(Sounds.shield),
smelterLoop(Sounds.smelter),
spellLoop(Sounds.spellLoop),
sprayLoop(Sounds.spray),
steamLoop(Sounds.steam),
techLoop(Sounds.techloop),
thrusterLoop(Sounds.thruster),
torchLoop(Sounds.torch),
tractorBeamLoop(Sounds.tractorbeam),
windLoop(Sounds.wind),
wind2Loop(Sounds.wind2),
windHowlLoop(Sounds.windhowl),

backUi(Sounds.back),
chatMessageUi(Sounds.chatMessage),
messageUi(Sounds.message),
pressUi(Sounds.press),
unlockUi(Sounds.unlock);

public final Sound sound;

public static final LogicSound[] all = values();

LogicSound(Sound sound){
this.sound = sound;
}
}