Added colliding sound
parent
7d15ea3684
commit
895896710e
|
@ -50,6 +50,8 @@ namespace stardew_access
|
||||||
|
|
||||||
ScreenReader.initializeScreenReader(); // Initialize the screen reader
|
ScreenReader.initializeScreenReader(); // Initialize the screen reader
|
||||||
|
|
||||||
|
this.initializeSounds();
|
||||||
|
|
||||||
harmony = new Harmony(ModManifest.UniqueID); // Init harmony
|
harmony = new Harmony(ModManifest.UniqueID); // Init harmony
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -239,30 +241,49 @@ namespace stardew_access
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Custom Drop Item Sound
|
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
||||||
|
helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeSounds()
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CueDefinition sa_drop_item = new CueDefinition();
|
#region Drop Item Sound
|
||||||
sa_drop_item.name = "sa_drop_item";
|
CueDefinition dropItemCueDef = new CueDefinition();
|
||||||
sa_drop_item.instanceLimit = 1;
|
dropItemCueDef.name = "sa_drop_item";
|
||||||
sa_drop_item.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest;
|
dropItemCueDef.instanceLimit = 1;
|
||||||
SoundEffect audio;
|
dropItemCueDef.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest;
|
||||||
string filePathCombined = Path.Combine(this.Helper.DirectoryPath, "drop_item.wav");
|
SoundEffect dropItemAudio;
|
||||||
using (FileStream stream = new(filePathCombined, FileMode.Open))
|
string dropItemFilePath = Path.Combine(this.Helper.DirectoryPath, "sounds/drop_item.wav");
|
||||||
|
using (FileStream stream = new(dropItemFilePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
audio = SoundEffect.FromStream(stream);
|
dropItemAudio = SoundEffect.FromStream(stream);
|
||||||
}
|
}
|
||||||
sa_drop_item.SetSound(audio, Game1.audioEngine.GetCategoryIndex("Sound"), false);
|
dropItemCueDef.SetSound(dropItemAudio, Game1.audioEngine.GetCategoryIndex("Sound"), false);
|
||||||
Game1.soundBank.AddCue(sa_drop_item);
|
#endregion
|
||||||
|
|
||||||
|
#region Colliding sound
|
||||||
|
CueDefinition collidingCueDef = new CueDefinition();
|
||||||
|
collidingCueDef.name = "sa_colliding";
|
||||||
|
collidingCueDef.instanceLimit = 1;
|
||||||
|
collidingCueDef.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest;
|
||||||
|
SoundEffect collidingAudio;
|
||||||
|
string collidingFilePath = Path.Combine(Path.Combine(this.Helper.DirectoryPath), "sounds/NPC.wav");
|
||||||
|
using (FileStream stream = new(collidingFilePath, FileMode.Open))
|
||||||
|
{
|
||||||
|
collidingAudio = SoundEffect.FromStream(stream);
|
||||||
|
}
|
||||||
|
collidingCueDef.SetSound(collidingAudio, Game1.audioEngine.GetCategoryIndex("Sound"), false);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
Game1.soundBank.AddCue(dropItemCueDef);
|
||||||
|
Game1.soundBank.AddCue(collidingCueDef);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MainClass.monitor.Log($"Unable to initialize custom sounds:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
monitor.Log($"Unable to initialize custom sounds:\n{e.Message}\n{e.StackTrace}", LogLevel.Error);
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
helper.Events.Input.ButtonPressed += this.OnButtonPressed;
|
|
||||||
helper.Events.GameLoop.UpdateTicked += this.onUpdateTicked;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
|
private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
private static string currentLetterText = " ";
|
private static string currentLetterText = " ";
|
||||||
private static string currentLevelUpTitle = " ";
|
private static string currentLevelUpTitle = " ";
|
||||||
|
public static Vector2? prevTile = null;
|
||||||
|
|
||||||
internal static bool PlaySoundPatch(string cueName)
|
internal static bool PlaySoundPatch(string cueName)
|
||||||
{
|
{
|
||||||
|
@ -24,34 +25,17 @@ namespace stardew_access.Patches
|
||||||
|
|
||||||
if(cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep")
|
if(cueName == "grassyStep" || cueName == "sandyStep" || cueName == "snowyStep" || cueName == "stoneStep" || cueName == "thudStep" || cueName == "woodyStep")
|
||||||
{
|
{
|
||||||
if(!Game1.currentLocation.isTilePassable(Game1.player.nextPosition(Game1.player.getDirection()), Game1.viewport))
|
Vector2 nextTile = CurrentPlayer.getNextTile();
|
||||||
|
Rectangle rect = new Rectangle((int)nextTile.X * 64 + 1,(int) nextTile.Y * 64 + 1, 62, 62);
|
||||||
|
if (Game1.currentLocation.isCollidingPosition(rect, Game1.viewport, true, 0, glider: false, Game1.player, pathfinding: false))
|
||||||
{
|
{
|
||||||
|
if (prevTile != nextTile)
|
||||||
|
{
|
||||||
|
prevTile = nextTile;
|
||||||
|
Game1.playSound("sa_colliding");
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Check for objects
|
|
||||||
Vector2 gt = CurrentPlayer.getNextTile();
|
|
||||||
|
|
||||||
if (Game1.currentLocation.isObjectAtTile((int)gt.X, (int)gt.Y))
|
|
||||||
{
|
|
||||||
if (!Game1.currentLocation.getObjectAtTile((int)gt.X, (int)gt.Y).isPassable())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Check for terrain features
|
|
||||||
Dictionary<Vector2, Netcode.NetRef<TerrainFeature>> terrainFeature = Game1.currentLocation.terrainFeatures.FieldDict;
|
|
||||||
if (terrainFeature.ContainsKey(gt))
|
|
||||||
{
|
|
||||||
if (!terrainFeature[gt].Get().isPassable())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Check for resource clumps
|
|
||||||
if(ReadTile.getResourceClumpAtTile((int)gt.X, (int) gt.Y)!=null)
|
|
||||||
return false;
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"Name": "Stardew Access",
|
"Name": "Stardew Access",
|
||||||
"Author": "Mohammad Shoaib",
|
"Author": "Mohammad Shoaib",
|
||||||
"Version": "1.0.16-beta",
|
"Version": "1.0.17-beta",
|
||||||
"Description": "An accessibility mod with screen reader support!",
|
"Description": "An accessibility mod with screen reader support!",
|
||||||
"UniqueID": "shoaib.stardewaccess",
|
"UniqueID": "shoaib.stardewaccess",
|
||||||
"EntryDll": "stardew-access.dll",
|
"EntryDll": "stardew-access.dll",
|
||||||
|
|
Loading…
Reference in New Issue