Actions Rework (#6791)

* Rejig Actions

* fix merge errors

* lambda-b-gon

* fix PAI, add innate actions

* Revert "fix PAI, add innate actions"

This reverts commit 4b501ac083e979e31ebd98d7b98077e0dbdd344b.

* Just fix by making nullable.

if only require: true actually did something somehow.

* Make AddActions() ensure an actions component

and misc comments

* misc cleanup

* Limit range even when not checking for obstructions

* remove old guardian code

* rename function and make EntityUid nullable

* fix magboot bug

* fix action search menu

* make targeting toggle all equivalent actions

* fix combat popups (enabling <-> disabling)
This commit is contained in:
Leon Friedrich
2022-02-25 17:12:29 +13:00
committed by GitHub
parent b99b1f4008
commit 5ac5dd6a64
135 changed files with 3122 additions and 5168 deletions

View File

@@ -1,90 +0,0 @@
using System;
using Content.Shared.Actions;
using Robust.Shared.GameObjects;
namespace Content.Client.Actions.Assignments
{
public struct ActionAssignment : IEquatable<ActionAssignment>
{
private readonly ActionType _actionType;
private readonly ItemActionType _itemActionType;
private readonly EntityUid _item;
public Assignment Assignment { get; private init; }
private ActionAssignment(Assignment assignment, ActionType actionType, ItemActionType itemActionType, EntityUid item)
{
Assignment = assignment;
_actionType = actionType;
_itemActionType = itemActionType;
_item = item;
}
/// <param name="actionType">the action type, if our Assignment is Assignment.Action</param>
/// <returns>true only if our Assignment is Assignment.Action</returns>
public bool TryGetAction(out ActionType actionType)
{
actionType = _actionType;
return Assignment == Assignment.Action;
}
/// <param name="itemActionType">the item action type, if our Assignment is Assignment.ItemActionWithoutItem</param>
/// <returns>true only if our Assignment is Assignment.ItemActionWithoutItem</returns>
public bool TryGetItemActionWithoutItem(out ItemActionType itemActionType)
{
itemActionType = _itemActionType;
return Assignment == Assignment.ItemActionWithoutItem;
}
/// <param name="itemActionType">the item action type, if our Assignment is Assignment.ItemActionWithItem</param>
/// <param name="item">the item UID providing the action, if our Assignment is Assignment.ItemActionWithItem</param>
/// <returns>true only if our Assignment is Assignment.ItemActionWithItem</returns>
public bool TryGetItemActionWithItem(out ItemActionType itemActionType, out EntityUid item)
{
itemActionType = _itemActionType;
item = _item;
return Assignment == Assignment.ItemActionWithItem;
}
public static ActionAssignment For(ActionType actionType)
{
return new(Assignment.Action, actionType, default, default);
}
public static ActionAssignment For(ItemActionType actionType)
{
return new(Assignment.ItemActionWithoutItem, default, actionType, default);
}
public static ActionAssignment For(ItemActionType actionType, EntityUid item)
{
return new(Assignment.ItemActionWithItem, default, actionType, item);
}
public bool Equals(ActionAssignment other)
{
return _actionType == other._actionType && _itemActionType == other._itemActionType && Equals(_item, other._item);
}
public override bool Equals(object? obj)
{
return obj is ActionAssignment other && Equals(other);
}
public override int GetHashCode()
{
return HashCode.Combine(_actionType, _itemActionType, _item);
}
public override string ToString()
{
return $"{nameof(_actionType)}: {_actionType}, {nameof(_itemActionType)}: {_itemActionType}, {nameof(_item)}: {_item}, {nameof(Assignment)}: {Assignment}";
}
}
public enum Assignment : byte
{
Action,
ItemActionWithoutItem,
ItemActionWithItem
}
}