UI/KillNotification/KillNotification.razor
@using Sandbox.UI
@inherits Panel
<style>
KillNotification {
position: absolute;
width: 100%;
height: 30%;
top: 0;
left: 0;
z-index: 50;
flex-direction: column-reverse;
align-items: center;
.entries {
flex-direction: column;
align-content: center;
align-items: center;
}
}
KillNotificationEntry {
transition: all 0.15s ease;
margin-bottom: 100px;
flex-direction: column;
font-family: "Wallpoet";
align-content: center;
justify-content: center;
align-items: center;
background-color: rgba(78, 75, 66, 0.1);
border-left: 5px solid rgba(0, 0, 0, 0.2);
border-right: 5px solid rgba(0, 0, 0, 0.2);
min-width: 400px;
padding: 8px;
.message {
font-size: 40px;
color: rgba(0, 255, 255, 0.75);
text-shadow: 0px 0px 20px rgba(0, 255, 255, 1);
margin-bottom: 20px;
}
.name {
color: rgba(218, 233, 239, 0.75);
text-shadow: 0px 0px 20px rgba(218, 233, 239, 1);
font-size: 28px;
}
&:intro {
transform: scale(0);
}
&:outro {
transform: scale(0);
opacity: 0;
}
&.faded {
opacity: 0;
}
}
</style>
<root>
<div @ref="_entries" class="entries"></div>
</root>
@code
{
private Panel _entries;
protected override void OnAfterTreeRender( bool firstTime )
{
base.OnAfterTreeRender( firstTime );
if ( !firstTime ) return;
KillFeedEvent.OnKill += OnKill;
}
public override void OnDeleted()
{
KillFeedEvent.OnKill -= OnKill;
}
private void OnKill( string killer, string victim, string method )
{
if ( killer != Connection.Local.DisplayName ) return;
// Remove any existing entries so only one shows at a time
_entries?.DeleteChildren( true );
_entries?.AddChild( new KillNotificationEntry( victim ) );
}
}