Re-add action prototypes (#7508)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2022-04-14 16:17:34 +12:00
committed by GitHub
parent c30b38a476
commit ba75934512
34 changed files with 291 additions and 189 deletions

View File

@@ -5,7 +5,7 @@ using Content.Shared.Sound;
using Content.Shared.Targeting;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.CombatMode
{
@@ -27,22 +27,17 @@ namespace Content.Shared.CombatMode
[DataField("disarmSuccessSound")]
public readonly SoundSpecifier DisarmSuccessSound = new SoundPathSpecifier("/Audio/Effects/thudswoosh.ogg");
// These are chonky default definitions for combat actions. But its a pain to add a yaml version of this for
// every entity that wants combat mode, especially given that they're currently all identical... so ummm.. yeah.
[DataField("disarmAction")]
public readonly EntityTargetAction DisarmAction = new();
[DataField("disarmActionId", customTypeSerializer:typeof(PrototypeIdSerializer<EntityTargetActionPrototype>))]
public readonly string DisarmActionId = "Disarm";
[DataField("disarmAction")] // must be a data-field to properly save cooldown when saving game state.
public EntityTargetAction? DisarmAction;
[DataField("combatToggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer<InstantActionPrototype>))]
public readonly string CombatToggleActionId = "CombatModeToggle";
[DataField("combatToggleAction")]
public readonly InstantAction CombatToggleAction = new()
{
Icon = new SpriteSpecifier.Texture(new ResourcePath("Interface/Actions/harmOff.png")),
IconOn = new SpriteSpecifier.Texture(new ResourcePath("Interface/Actions/harm.png")),
UserPopup = "action-popup-combat",
PopupToggleSuffix = "-disabling",
Name = "action-name-combat",
Description = "action-description-combat",
Event = new ToggleCombatActionEvent(),
};
public InstantAction? CombatToggleAction;
[ViewVariables(VVAccess.ReadWrite)]
public virtual bool IsInCombatMode
@@ -52,7 +47,8 @@ namespace Content.Shared.CombatMode
{
if (_isInCombatMode == value) return;
_isInCombatMode = value;
EntitySystem.Get<SharedActionsSystem>().SetToggled(CombatToggleAction, _isInCombatMode);
if (CombatToggleAction != null)
EntitySystem.Get<SharedActionsSystem>().SetToggled(CombatToggleAction, _isInCombatMode);
Dirty();
// Regenerate physics contacts -> Can probably just selectively check