random death messages (#65)

* random death messages

* .

Co-authored-by: Ricardo Lopes <Raicuparta@users.noreply.github.com>
This commit is contained in:
AmazingAlek 2020-03-07 16:44:08 +01:00 committed by Ricardo Lopes
parent f239acd724
commit 31dd0b6a1f
4 changed files with 110 additions and 6 deletions

View File

@ -7,18 +7,18 @@ namespace QSB.Events
{
public override MessageType MessageType => MessageType.Death;
public short DeathId { get; set; }
public DeathType DeathType { get; set; }
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
DeathId = reader.ReadInt16();
DeathType = (DeathType)reader.ReadInt16();
}
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(DeathId);
writer.Write((short)DeathType);
}
}
}

103
QSB/Events/Necronomicon.cs Normal file
View File

@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace QSB.Events
{
public static class Necronomicon
{
private static readonly Dictionary<DeathType, string[]> DeathDictionary = new Dictionary<DeathType, string[]>
{
{ DeathType.Default, new[]
{
"{0} died"
} },
{ DeathType.Impact, new[]
{
"{0} forgot what retro thrusters were",
"{0} bonked into the ground too hard",
"{0} went splat"
} },
{ DeathType.Asphyxiation, new[]
{
"{0} forgot to breathe",
"{0} forgot how to breathe",
"{0} forgot to check their oxygen meter",
"{0} lacked oxygen",
"{0} attempted to photosynthesise"
} },
{ DeathType.Energy, new[]
{
"{0} was cooked",
"{0} failed the Hotshot achievement",
"{0} forgot to install AC unit"
} },
{ DeathType.Supernova, new[]
{
"{0} ran out of time",
"{0} vaporized",
"{0} lost track of time",
"{0} got front row seats to the supernova",
"{0} heard the End of Times music",
"{0} watched the sun go kaboom",
"{0} became cosmic marshmallow"
} },
{ DeathType.Digestion, new[]
{
"{0} was eaten",
"{0} found a fish",
"{0} encountered an evil creature",
"{0} followed the light, then was followed by it",
"{0} messed with the wrong species of fish"
} },
{ DeathType.BigBang, new[]
{
"{0} sacrificed themself for the universe",
"{0} knows the true meaning of sacrifice",
"{0} won at the cost of their life"
} },
{ DeathType.Crushed, new[]
{
"{0} went through the tunnel too slow",
"{0} didn't make it out in time",
"{0} was squished",
"{0} thought the Sunless City was safe",
"{0} was buried"
} },
{ DeathType.Meditation, new[]
{
"{0} took a deep breath and died",
"{0} fell asleep",
"{0} got killed by Gabbro's advice"
} },
{ DeathType.TimeLoop, new[]
{
"{0} ran out of time",
"{0} was caught by a statue",
"{0}'s memories were pilfered",
"{0}'s memories fell into a black hole",
"{0}'s universe was eaten by Grobletombus"
} },
{ DeathType.Lava, new[]
{
"{0} tried to swim in lava",
"{0} didn't know what the glowy orange liquid was",
"{0} slipped in lava",
"{0} became one with the glowing gooey rock"
} },
{ DeathType.BlackHole, new[]
{
"{0} should visit the Ash Twin Project again",
"{0} waited inside the Ash Twin Project",
"{0} chased their memories"
} }
};
public static string GetPhrase(DeathType deathType)
{
return DeathDictionary[deathType].OrderBy(x => Guid.NewGuid()).First();
}
}
}

View File

@ -106,6 +106,7 @@
<Compile Include="Animation\AnimFloatParam.cs" />
<Compile Include="Animation\AnimTriggerMessage.cs" />
<Compile Include="Animation\AnimTrigger.cs" />
<Compile Include="Events\Necronomicon.cs" />
<Compile Include="Events\JoinMessage.cs" />
<Compile Include="Events\LeaveMessage.cs" />
<Compile Include="Events\PlayerLeave.cs" />

View File

@ -129,8 +129,8 @@ namespace QSB.TimeSync
private void OnClientReceiveMessage(DeathMessage message)
{
var playerName = PlayerJoin.PlayerNames.TryGetValue(message.SenderId, out var n) ? n : message.PlayerName;
var deathType = ((DeathType)message.DeathId).ToString();
DebugLog.All($"{playerName} was killed by {deathType}!");
var deathMessage = Necronomicon.GetPhrase(message.DeathType);
DebugLog.All(string.Format(deathMessage, playerName));
}
internal static class Patches
@ -158,7 +158,7 @@ namespace QSB.TimeSync
{
PlayerName = PlayerJoin.MyName,
SenderId = PlayerTransformSync.LocalInstance.netId.Value,
DeathId = (short)deathType
DeathType = deathType
};
_instance._deathHandler.SendToServer(message);
}