ECS damageable (#4529)
* ECS and damage Data * Comments and newlines * Added Comments * Make TryChangeDamageEvent immutable * Remove SetAllDamage event Use public SetAllDamage function instead * Undo destructible mistakes That was some shit code. * Rename DamageData to DamageSpecifier And misc small edits misc * Cache trigger prototypes. * Renaming destructible classes & functions * Revert "Cache trigger prototypes." This reverts commit 86bae15ba6616884dba75f552dfdfbe2d1fb6586. * Replace prototypes with prototype IDs. * Split damage.yml into individual files * move get/handle component state to system * Update HealthChange doc * Make godmode call Dirty() on damageable component * Add Initialize() to fix damage test * Make non-static * uncache resistance set prototype and trim DamageableComponentState * Remove unnecessary Dirty() calls during initialization * RemoveTryChangeDamageEvent * revert Dirty() * Fix MobState relying on DamageableComponent.Dirty() * Fix DisposalUnit Tests. These were previously failing, but because the async was not await-ed, this never raised the exception. After I fixed MobState component, this exception stopped happening and instead the assertions started being tested & failing * Disposal test 2: electric boogaloo * Fix typos/mistakes also add comments and fix spacing. * Use Uids instead of IEntity * fix merge * Comments, a merge issue, and making some damage ignore resistances * Extend DamageSpecifier and use it for DamageableComponent * fix master merge * Fix Disposal unit test. Again. Snapgrids were removed in master * Execute Exectute
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Damage;
|
||||
using System.Linq;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
@@ -10,6 +9,7 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
|
||||
namespace Content.Client.MedicalScanner.UI
|
||||
{
|
||||
@@ -55,59 +55,36 @@ namespace Content.Client.MedicalScanner.UI
|
||||
{
|
||||
text.Append($"{Loc.GetString("medical-scanner-window-entity-health-text", ("entityName", entity.Name))}\n");
|
||||
|
||||
// Show the total damage
|
||||
var totalDamage = state.DamagePerTypeID.Values.Sum();
|
||||
var totalDamage = state.DamagePerType.Values.Sum();
|
||||
text.Append($"{Loc.GetString("medical-scanner-window-entity-damage-total-text", ("amount", totalDamage))}\n");
|
||||
|
||||
// Keep track of how many damage types we have shown
|
||||
HashSet<string> shownTypeIDs = new();
|
||||
HashSet<string> shownTypes = new();
|
||||
|
||||
// First show just the total damage and type breakdown for each damge group that is fully supported by that entitygroup.
|
||||
foreach (var (damageGroupID, damageAmount) in state.DamagePerSupportedGroupID)
|
||||
// Show the total damage and type breakdown for each damage group.
|
||||
foreach (var (damageGroupID, damageAmount) in state.DamagePerGroup)
|
||||
{
|
||||
|
||||
// Show total damage for the group
|
||||
text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", damageGroupID), ("amount", damageAmount))}");
|
||||
|
||||
// Then show the damage for each type in that group.
|
||||
// currently state has a dictionary mapping groupsIDs to damage, and typeIDs to damage, but does not know how types and groups are related.
|
||||
// So use PrototypeManager.
|
||||
// Show the damage for each type in that group.
|
||||
var group = IoCManager.Resolve<IPrototypeManager>().Index<DamageGroupPrototype>(damageGroupID);
|
||||
foreach (var type in group.DamageTypes)
|
||||
{
|
||||
if (state.DamagePerTypeID.TryGetValue(type.ID, out var typeAmount))
|
||||
if (state.DamagePerType.TryGetValue(type, out var typeAmount))
|
||||
{
|
||||
// If damage types are allowed to belong to more than one damage group, they may appear twice here. Mark them as duplicate.
|
||||
if (!shownTypeIDs.Contains(type.ID))
|
||||
if (!shownTypes.Contains(type))
|
||||
{
|
||||
shownTypeIDs.Add(type.ID);
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", type.ID), ("amount", typeAmount))}");
|
||||
shownTypes.Add(type);
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", type), ("amount", typeAmount))}");
|
||||
}
|
||||
else {
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-duplicate-text", ("damageType", type.ID), ("amount", typeAmount))}");
|
||||
text.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-duplicate-text", ("damageType", type), ("amount", typeAmount))}");
|
||||
}
|
||||
}
|
||||
}
|
||||
text.Append('\n');
|
||||
}
|
||||
|
||||
// Then, lets also list any damageType that was not fully Supported by the entity's damageContainer
|
||||
var textAppendix = new StringBuilder();
|
||||
int totalMiscDamage = 0;
|
||||
// Iterate over ids that have not been printed.
|
||||
foreach (var damageTypeID in state.DamagePerTypeID.Keys.Where(typeID => !shownTypeIDs.Contains(typeID)))
|
||||
{
|
||||
//This damage type was not yet added to the text.
|
||||
textAppendix.Append($"\n- {Loc.GetString("medical-scanner-window-damage-type-text", ("damageType", damageTypeID), ("amount", state.DamagePerTypeID[damageTypeID]))}");
|
||||
totalMiscDamage += state.DamagePerTypeID[damageTypeID];
|
||||
}
|
||||
|
||||
// Is there any information to show? Did any damage types not belong to a group?
|
||||
if (textAppendix.Length > 0) {
|
||||
text.Append($"\n{Loc.GetString("medical-scanner-window-damage-group-text", ("damageGroup", "Miscellaneous"), ("amount", totalMiscDamage))}");
|
||||
text.Append(textAppendix);
|
||||
}
|
||||
|
||||
_diagnostics.Text = text.ToString();
|
||||
ScanButton.Disabled = state.IsScanned;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user