Skip to content

Weapon highlights + Weapon flesh pull #238

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

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/MadnessInteractiveReloaded/Assets/Sounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static class Sounds
/// Bad thing happened noise
/// </summary>
public static readonly Sound UiBad = new(Assets.Load<FixedAudioData>("sounds/ui/bad.wav").Value, spatialParams: null, track: AudioTracks.UserInterface);
public static readonly Sound FleshPull = new(Assets.Load<FixedAudioData>("sounds/fleshpull.wav").Value, spatialParams: null, track: AudioTracks.SoundEffects);

public static readonly Sound DeathMusic = new(Assets.Load<StreamAudioData>("sounds/music/death.ogg").Value, false, spatialParams: null, track: AudioTracks.Music);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,18 @@ public bool EquipWeapon(Scene scene, WeaponComponent weapon)
scene.DetachComponent<ThrowableProjectileComponent>(weapon.Entity);

weapon.IsAttachedToWall = false;
if (weapon.StuckInsideParams != null) // blood splat and sound if we are pulling a weapon from a body
{
if(scene.TryGetComponentFrom<BodyPartComponent>(weapon.StuckInsideParams.Value.Entity, out var bodypart))
{
TransformComponent transform = scene.GetComponentFrom<TransformComponent>(weapon.Entity);
Color bloodColor = bodypart.Character.Get(scene).Look.BloodColour;
Vector2 midPoint = Vector2.Lerp(transform.Position, scene.GetComponentFrom<TransformComponent>(weapon.StuckInsideParams.Value.Entity).Position, 0.5f);
Prefabs.CreateBloodSpurt(scene, midPoint, Utilities.RandomFloat(0, 360), bloodColor, 0.7f);
Prefabs.CreateBloodSplat(scene, midPoint, Utilities.RandomFloat(0, 360), bloodColor, Utilities.RandomFloat(150, 250));
scene.Game.AudioRenderer.PlayOnce(Sounds.FleshPull);
}
}
weapon.StuckInsideParams = null;
weapon.Wielder = new ComponentRef<CharacterComponent>(Entity);
weapon.Timer = float.MaxValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public override void Update()
// nearestWeapon.Stats.Name, 0.4f);
}
}
else
{
player.LastWeaponHoveredOver = null;
}

if (Input.IsKeyHeld(Key.LeftControl) && MathF.Abs(Input.MouseScrollDelta) > float.Epsilon)
{
Expand Down
1 change: 1 addition & 0 deletions src/MadnessInteractiveReloaded/Shared/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class GeneralSettings
{
public string Language = "en-GB";
public float Screenshake = 1;
public bool WeaponHighlights = true;
}

public class VideoSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public override void Render()
break;
default:
break;
}
}
}

//DrawLine(Textures.UserInterface.HatCategoryIcon.Value, weaponStr, ref c);
Expand Down Expand Up @@ -191,6 +191,28 @@ public override void Render()
}

}

// weapon highlights
// check if the highlights setting is on, if there is a weapon entity we are hovering over and if the weapon entity has a weapon component attached to it
if (UserData.Instances.Settings.General.WeaponHighlights && player.LastWeaponHoveredOver != null && Scene.TryGetComponentFrom(player.LastWeaponHoveredOver.Value, out WeaponComponent? nearestWeapon) && nearestWeapon != null)
{
Draw.ScreenSpace = false;
//TODO: when melee durability is added, edit this line to account for it
float normAmt = nearestWeapon.Data.WeaponType == WeaponType.Firearm ? (float)nearestWeapon.RemainingRounds / (float)nearestWeapon.Data.RoundsPerMagazine : 1f;
Draw.Colour = nearestWeapon.InfiniteAmmo ? Color.FromHsv(Time, 0.2f, 1) : Utilities.Lerp(Colors.Red, Colors.White, normAmt);
Draw.Colour.A = 0.75f;
Draw.Order = RenderOrders.Effects;
Draw.Material = Materials.BlackToWhiteOutline;
var tr = Scene.GetComponentFrom<TransformComponent>(player.LastWeaponHoveredOver.Value);
if (nearestWeapon.Texture != null)
{
Texture tex = nearestWeapon.Texture;
Draw.Texture = tex;
Draw.TransformMatrix = tr.LocalToWorldMatrix;

Draw.Quad(new Rect(Vector2.Zero, new Vector2(tex.Width, tex.Height)), 0f);
}
}
}

private static void DrawCounter(Vector2 p, int c, int max, HorizontalTextAlign alignment = HorizontalTextAlign.Left)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ static SettingsSceneSystem()
Ui.Layout.FitContainer(1,1,false);
if (Ui.FloatSlider(ref settings.General.Screenshake, Direction.Horizontal, (0,2), 0.1f, "{0:P0}"))
settings.Apply();
}),
("settings-weapon-highlights", () => {
Ui.Layout.FitContainer(1, 1, false).AspectRatio(1, AspectRatioBehaviour.Shrink);
if (Controls.Toggle.Start(ref settings.General.WeaponHighlights))
settings.Apply();
})
]},

Expand Down
1 change: 1 addition & 0 deletions src/MadnessInteractiveReloaded/base/locale/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"settings-sfx-volume": "Sound effects",
"settings-ui-volume": "User interface",
"settings-screenshake": "Screenshake",
"settings-weapon-highlights": "Highlight hovered weapon",

"improbability-no-ability": "This disk grants no special abilities.",
"disk-unlocked": "IMPROBABILITY DISK UNLOCKED",
Expand Down
Binary file not shown.