Removed old Loc.GetString() use instances (#4155)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Galactic Chimp
2021-06-21 02:13:54 +02:00
committed by GitHub
parent 4a46fbe6dd
commit 392b820796
523 changed files with 3082 additions and 1551 deletions

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
using System.Linq;
namespace Content.Client.Actions.Assignments
{
@@ -70,8 +70,6 @@ namespace Content.Client.Actions.Assignments
}
}
foreach (var (item, itemStates) in itemActionStates)
{
foreach (var itemActionState in itemStates)
@@ -94,10 +92,13 @@ namespace Content.Client.Actions.Assignments
// which once had an associated item but have been revoked (based on our newly provided action states)
// so we can dissociate them from the item. If the provided action states do not
// have a state for this action type + item, we can assume that the action has been revoked for that item.
var assignmentsWithoutItem = new List<KeyValuePair<ActionAssignment,List<(byte Hotbar, byte Slot)>>>();
var assignmentsWithoutItem = new List<KeyValuePair<ActionAssignment, List<(byte Hotbar, byte Slot)>>>();
foreach (var assignmentEntry in _assignments)
{
if (!assignmentEntry.Key.TryGetItemActionWithItem(out var actionType, out var item)) continue;
if (!assignmentEntry.Key.TryGetItemActionWithItem(out var actionType, out var item))
{
continue;
}
// we have this assignment currently tied to an item,
// check if it no longer has an associated item in our dict of states
@@ -110,8 +111,10 @@ namespace Content.Client.Actions.Assignments
continue;
}
}
assignmentsWithoutItem.Add(assignmentEntry);
}
// reassign without the item for each assignment we found that no longer has an associated item
foreach (var (assignment, slots) in assignmentsWithoutItem)
{
@@ -158,7 +161,7 @@ namespace Content.Client.Actions.Assignments
}
else
{
var newList = new List<(byte Hotbar, byte Slot)> {(hotbar, slot)};
var newList = new List<(byte Hotbar, byte Slot)> { (hotbar, slot) };
_assignments[actionType] = newList;
}
}
@@ -179,7 +182,12 @@ namespace Content.Client.Actions.Assignments
// remove this particular assignment from our data structures
// (keeping in mind something can be assigned multiple slots)
var currentAction = _slots[hotbar, slot];
if (!currentAction.HasValue) return;
if (!currentAction.HasValue)
{
return;
}
if (preventAutoPopulate)
{
var assignment = currentAction.Value;
@@ -199,6 +207,7 @@ namespace Content.Client.Actions.Assignments
actionTypes.Add(itemActionType);
}
}
var assignmentList = _assignments[currentAction.Value];
assignmentList = assignmentList.Where(a => a.Hotbar != hotbar || a.Slot != slot).ToList();
if (!assignmentList.Any())
@@ -209,6 +218,7 @@ namespace Content.Client.Actions.Assignments
{
_assignments[currentAction.Value] = assignmentList;
}
_slots[hotbar, slot] = null;
}
@@ -223,7 +233,11 @@ namespace Content.Client.Actions.Assignments
/// if this assignment has been prevented from auto population.</param>
public void AutoPopulate(ActionAssignment toAssign, byte currentHotbar, bool force = true)
{
if (ShouldPreventAutoPopulate(toAssign, force)) return;
if (ShouldPreventAutoPopulate(toAssign, force))
{
return;
}
// if the assignment to make is an item action with an associated item,
// then first look for currently assigned item actions without an item, to replace with this
// assignment
@@ -240,7 +254,7 @@ namespace Content.Client.Actions.Assignments
{
var cost = possibility.Slot + _numSlots * (currentHotbar >= possibility.Hotbar
? currentHotbar - possibility.Hotbar
: (_numHotbars - currentHotbar) + possibility.Hotbar);
: _numHotbars - currentHotbar + possibility.Hotbar);
if (cost < minCost)
{
hotbar = possibility.Hotbar;
@@ -273,8 +287,10 @@ namespace Content.Client.Actions.Assignments
AssignSlot(hotbar, slot, toAssign);
return;
}
continue;
}
// slot's empty, assign
AssignSlot(hotbar, slot, toAssign);
return;
@@ -285,7 +301,10 @@ namespace Content.Client.Actions.Assignments
private bool ShouldPreventAutoPopulate(ActionAssignment assignment, bool force)
{
if (force) return false;
if (force)
{
return false;
}
if (assignment.TryGetAction(out var actionType))
{