Explosions and Grenades, Triggers, OnDestroy, OnExAct, Fueltanks and destructible tables (#247)
* initial explosiveComponent * remove garbagee * assets * tile mass deletion baby * grenades * tweaks * Update Content.Server/GameObjects/Components/Explosion/ExplosiveComponent.cs Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com> * Ex_act based on damage, fixes and tweaks * One finishing touch Done the most cringe way * ex_act explosions, tables are destructible now also adds fuel tanks * adds ex_act to mobs
This commit is contained in:
committed by
Pieter-Jan Briers
parent
f1aeaaa640
commit
10801af2f7
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using Content.Shared.GameObjects.Components.Triggers;
|
||||
using Robust.Client.Animations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.GameObjects.Components.Animations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Doors
|
||||
{
|
||||
public class TimerTriggerVisualizer2D : AppearanceVisualizer
|
||||
{
|
||||
private const string AnimationKey = "priming_animation";
|
||||
|
||||
private Animation PrimingAnimation;
|
||||
|
||||
public override void LoadData(YamlMappingNode node)
|
||||
{
|
||||
base.LoadData(node);
|
||||
|
||||
var countdownSound = node.GetNode("countdown_sound").AsString();
|
||||
|
||||
|
||||
PrimingAnimation = new Animation { Length = TimeSpan.MaxValue };
|
||||
{
|
||||
var flick = new AnimationTrackSpriteFlick();
|
||||
PrimingAnimation.AnimationTracks.Add(flick);
|
||||
flick.LayerKey = TriggerVisualLayers.Base;
|
||||
flick.KeyFrames.Add(new AnimationTrackSpriteFlick.KeyFrame("primed", 0f));
|
||||
|
||||
var sound = new AnimationTrackPlaySound();
|
||||
PrimingAnimation.AnimationTracks.Add(sound);
|
||||
sound.KeyFrames.Add(new AnimationTrackPlaySound.KeyFrame(countdownSound, 0));
|
||||
}
|
||||
}
|
||||
|
||||
public override void InitializeEntity(IEntity entity)
|
||||
{
|
||||
if (!entity.HasComponent<AnimationPlayerComponent>())
|
||||
{
|
||||
entity.AddComponent<AnimationPlayerComponent>();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||
var animPlayer = component.Owner.GetComponent<AnimationPlayerComponent>();
|
||||
if (!component.TryGetData(TriggerVisuals.VisualState, out TriggerVisualState state))
|
||||
{
|
||||
state = TriggerVisualState.Unprimed;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TriggerVisualState.Primed:
|
||||
if (!animPlayer.HasRunningAnimation(AnimationKey))
|
||||
{
|
||||
animPlayer.Play(PrimingAnimation, AnimationKey);
|
||||
}
|
||||
break;
|
||||
case TriggerVisualState.Unprimed:
|
||||
sprite.LayerSetState(0, "icon");
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
public enum TriggerVisualLayers
|
||||
{
|
||||
Base
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user