Cleanup the remainder of dragon (#8881)
* Cleanup the remainder of dragon - Fixed some of the niscellaneous changes made to yml - Made devour use a whitelist - Fixed spelling * name fix * a
This commit is contained in:
@@ -5,6 +5,7 @@ using Content.Shared.Actions;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Sound;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
@@ -78,6 +79,20 @@ namespace Content.Server.Dragon
|
||||
|
||||
public CancellationTokenSource? CancelToken;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("devourWhitelist")]
|
||||
public EntityWhitelist? DevourWhitelist = new()
|
||||
{
|
||||
Components = new string[]
|
||||
{
|
||||
"Door",
|
||||
"MobState",
|
||||
},
|
||||
Tags = new List<string>()
|
||||
{
|
||||
"Wall",
|
||||
}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Where the entities go when dragon devours them, empties when the dragon is butchered.
|
||||
/// </summary>
|
||||
|
||||
@@ -112,9 +112,11 @@ namespace Content.Server.Dragon
|
||||
/// <summary>
|
||||
/// The devour action
|
||||
/// </summary>
|
||||
private void OnDevourAction(EntityUid dragonuid, DragonComponent component, DragonDevourActionEvent args)
|
||||
private void OnDevourAction(EntityUid uid, DragonComponent component, DragonDevourActionEvent args)
|
||||
{
|
||||
if (component.CancelToken != null || args.Handled) return;
|
||||
if (component.CancelToken != null ||
|
||||
args.Handled ||
|
||||
component.DevourWhitelist?.IsValid(args.Target, EntityManager) != true) return;
|
||||
|
||||
args.Handled = true;
|
||||
var target = args.Target;
|
||||
@@ -128,9 +130,9 @@ namespace Content.Server.Dragon
|
||||
case SharedDeadMobState:
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(dragonuid, component.DevourTime, component.CancelToken.Token, target)
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(uid, component.DevourTime, component.CancelToken.Token, target)
|
||||
{
|
||||
UserFinishedEvent = new DragonStructureDevourComplete(dragonuid, target),
|
||||
UserFinishedEvent = new DragonDevourComplete(uid, target),
|
||||
UserCancelledEvent = new DragonDevourCancelledEvent(),
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
@@ -138,33 +140,28 @@ namespace Content.Server.Dragon
|
||||
});
|
||||
break;
|
||||
default:
|
||||
_popupSystem.PopupEntity(Loc.GetString("devour-action-popup-message-fail-target-alive"), dragonuid, Filter.Entities(dragonuid));
|
||||
_popupSystem.PopupEntity(Loc.GetString("devour-action-popup-message-fail-target-alive"), uid, Filter.Entities(uid));
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Absolutely ass solution but requires less yaml fuckery
|
||||
// If it's a door (firelock, airlock, windoor), Wall or Window, dragon can eat it.
|
||||
if (_tagSystem.HasTag(target, "Wall") || (_tagSystem.HasTag(target, "Window") || EntityManager.HasComponent<DoorComponent>(target)))
|
||||
_popupSystem.PopupEntity(Loc.GetString("devour-action-popup-message-structure"), uid, Filter.Entities(uid));
|
||||
|
||||
if (component.SoundStructureDevour != null)
|
||||
SoundSystem.Play(component.SoundStructureDevour.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid, component.SoundStructureDevour.Params);
|
||||
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(uid, component.DevourTime, component.CancelToken.Token, target)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("devour-action-popup-message-structure"), dragonuid, Filter.Entities(dragonuid));
|
||||
|
||||
if (component.SoundStructureDevour != null)
|
||||
SoundSystem.Play(component.SoundStructureDevour.GetSound(), Filter.Pvs(dragonuid, entityManager: EntityManager), dragonuid, component.SoundStructureDevour.Params);
|
||||
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
_doAfterSystem.DoAfter(new DoAfterEventArgs(dragonuid, component.DevourTime, component.CancelToken.Token, target)
|
||||
{
|
||||
UserFinishedEvent = new DragonStructureDevourComplete(dragonuid, target),
|
||||
UserCancelledEvent = new DragonDevourCancelledEvent(),
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnStun = true,
|
||||
});
|
||||
}
|
||||
UserFinishedEvent = new DragonStructureDevourComplete(uid, target),
|
||||
UserCancelledEvent = new DragonDevourCancelledEvent(),
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnStun = true,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnDragonSpawnAction(EntityUid dragonuid, DragonComponent component, DragonSpawnActionEvent args)
|
||||
|
||||
Reference in New Issue
Block a user