Fix some mispredict reconciliation issues. (#6319)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -11,19 +11,6 @@ namespace Content.Shared.Atmos
|
||||
VisualState
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class PipeVisualState
|
||||
{
|
||||
// TODO ATMOS: Make this not a class and just be the field below...
|
||||
[ViewVariables]
|
||||
public readonly PipeDirection ConnectedDirections;
|
||||
|
||||
public PipeVisualState(PipeDirection connectedDirections)
|
||||
{
|
||||
ConnectedDirections = connectedDirections;
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
[Serializable, NetSerializable]
|
||||
public enum PipeDirection
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Content.Shared.Botany
|
||||
[Serializable, NetSerializable]
|
||||
public enum PlantHolderVisuals
|
||||
{
|
||||
Plant,
|
||||
PlantRsi,
|
||||
PlantState,
|
||||
HealthLight,
|
||||
WaterLight,
|
||||
NutritionLight,
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Content.Shared.Chemistry
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class SolutionContainerVisualState
|
||||
public class SolutionContainerVisualState : ICloneable
|
||||
{
|
||||
public readonly Color Color;
|
||||
|
||||
@@ -33,6 +33,11 @@ namespace Content.Shared.Chemistry
|
||||
Color = color;
|
||||
FilledVolumeFraction = (byte) (byte.MaxValue * filledVolumeFraction);
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new SolutionContainerVisualState(Color, FilledVolumeFraction);
|
||||
}
|
||||
}
|
||||
|
||||
public enum SolutionContainerLayers : byte
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Damage
|
||||
@@ -11,4 +12,20 @@ namespace Content.Shared.Damage
|
||||
DamageUpdateGroups,
|
||||
ForceUpdate
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class DamageVisualizerGroupData : ICloneable
|
||||
{
|
||||
public List<string> GroupList;
|
||||
|
||||
public DamageVisualizerGroupData(List<string> groupList)
|
||||
{
|
||||
GroupList = groupList;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new DamageVisualizerGroupData(new List<string>(GroupList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,10 @@ namespace Content.Shared.Damage
|
||||
component.Dirty();
|
||||
|
||||
if (EntityManager.TryGetComponent<AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
|
||||
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, damageDelta.GetDamagePerGroup().Keys.ToList());
|
||||
{
|
||||
var data = new DamageVisualizerGroupData(damageDelta.GetDamagePerGroup().Keys.ToList());
|
||||
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, data);
|
||||
}
|
||||
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
|
||||
}
|
||||
|
||||
@@ -198,7 +201,7 @@ namespace Content.Shared.Damage
|
||||
component.DamageModifierSetId = state.ModifierSetId;
|
||||
|
||||
// Has the damage actually changed?
|
||||
DamageSpecifier newDamage = new() { DamageDict = state.DamageDict };
|
||||
DamageSpecifier newDamage = new() { DamageDict = new(state.DamageDict) };
|
||||
var delta = component.Damage - newDamage;
|
||||
delta.TrimZeros();
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ namespace Content.Shared.Hands.Components
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class HandsVisualState
|
||||
public class HandsVisualState : ICloneable
|
||||
{
|
||||
public List<HandVisualState> Hands { get; } = new();
|
||||
|
||||
@@ -726,10 +726,15 @@ namespace Content.Shared.Hands.Components
|
||||
{
|
||||
Hands = hands;
|
||||
}
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return new HandsVisualState(new List<HandVisualState>(Hands));
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class HandVisualState
|
||||
public struct HandVisualState
|
||||
{
|
||||
public string RsiPath { get; }
|
||||
public string? EquippedPrefix { get; }
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace Content.Shared.StatusEffect
|
||||
foreach (var state in status.ActiveEffects.ToArray())
|
||||
{
|
||||
// if we're past the end point of the effect
|
||||
if (_gameTiming.CurTime > state.Value.Cooldown.Item2)
|
||||
if (curTime > state.Value.Cooldown.Item2)
|
||||
{
|
||||
TryRemoveStatusEffect(status.Owner, state.Key, status);
|
||||
}
|
||||
@@ -53,24 +53,33 @@ namespace Content.Shared.StatusEffect
|
||||
|
||||
private void OnHandleState(EntityUid uid, StatusEffectsComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is StatusEffectsComponentState state)
|
||||
if (args.Current is not StatusEffectsComponentState state)
|
||||
return;
|
||||
|
||||
component.AllowedEffects = new(state.AllowedEffects);
|
||||
|
||||
// Remove non-existent effects.
|
||||
foreach (var effect in component.ActiveEffects.Keys)
|
||||
{
|
||||
component.AllowedEffects = state.AllowedEffects;
|
||||
|
||||
foreach (var effect in state.ActiveEffects)
|
||||
if (!state.ActiveEffects.ContainsKey(effect))
|
||||
{
|
||||
// don't bother with anything if we already have it
|
||||
if (component.ActiveEffects.ContainsKey(effect.Key))
|
||||
{
|
||||
component.ActiveEffects[effect.Key] = effect.Value;
|
||||
continue;
|
||||
}
|
||||
|
||||
var time = effect.Value.Cooldown.Item2 - effect.Value.Cooldown.Item1;
|
||||
//TODO: Not sure how to handle refresh here.
|
||||
TryAddStatusEffect(uid, effect.Key, time, true);
|
||||
TryRemoveStatusEffect(uid, effect, component);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var effect in state.ActiveEffects)
|
||||
{
|
||||
// don't bother with anything if we already have it
|
||||
if (component.ActiveEffects.ContainsKey(effect.Key))
|
||||
{
|
||||
component.ActiveEffects[effect.Key] = effect.Value;
|
||||
continue;
|
||||
}
|
||||
|
||||
var time = effect.Value.Cooldown.Item2 - effect.Value.Cooldown.Item1;
|
||||
//TODO: Not sure how to handle refresh here.
|
||||
TryAddStatusEffect(uid, effect.Key, time, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -140,7 +149,7 @@ namespace Content.Shared.StatusEffect
|
||||
/// <remarks>
|
||||
/// This obviously does not add any actual 'effects' on its own. Use the generic overload,
|
||||
/// which takes in a component type, if you want to automatically add and remove a component.
|
||||
///
|
||||
///
|
||||
/// If the effect already exists, it will simply replace the cooldown with the new one given.
|
||||
/// If you want special 'effect merging' behavior, do it your own damn self!
|
||||
/// </remarks>
|
||||
@@ -187,7 +196,7 @@ namespace Content.Shared.StatusEffect
|
||||
_alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown1);
|
||||
}
|
||||
|
||||
status.Dirty();
|
||||
Dirty(status);
|
||||
// event?
|
||||
return true;
|
||||
}
|
||||
@@ -261,7 +270,7 @@ namespace Content.Shared.StatusEffect
|
||||
|
||||
status.ActiveEffects.Remove(key);
|
||||
|
||||
status.Dirty();
|
||||
Dirty(status);
|
||||
// event?
|
||||
return true;
|
||||
}
|
||||
@@ -285,6 +294,7 @@ namespace Content.Shared.StatusEffect
|
||||
failed = true;
|
||||
}
|
||||
|
||||
Dirty(status);
|
||||
return failed;
|
||||
}
|
||||
|
||||
@@ -352,6 +362,7 @@ namespace Content.Shared.StatusEffect
|
||||
_alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown);
|
||||
}
|
||||
|
||||
Dirty(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -387,6 +398,7 @@ namespace Content.Shared.StatusEffect
|
||||
_alertsSystem.ShowAlert(uid, proto.Alert.Value, null, cooldown);
|
||||
}
|
||||
|
||||
Dirty(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -406,6 +418,8 @@ namespace Content.Shared.StatusEffect
|
||||
return false;
|
||||
|
||||
status.ActiveEffects[key].Cooldown = (_gameTiming.CurTime, _gameTiming.CurTime + time);
|
||||
|
||||
Dirty(status);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Content.Shared.Storage.Components
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ShowLayerData
|
||||
public class ShowLayerData : ICloneable
|
||||
{
|
||||
public IReadOnlyList<string> QueuedEntities { get; internal set; }
|
||||
|
||||
@@ -33,14 +33,14 @@ namespace Content.Shared.Storage.Components
|
||||
QueuedEntities = new List<string>();
|
||||
}
|
||||
|
||||
public ShowLayerData(IReadOnlyList<string> other)
|
||||
public ShowLayerData(IEnumerable<string> other)
|
||||
{
|
||||
QueuedEntities = other;
|
||||
QueuedEntities = new List<string>(other);
|
||||
}
|
||||
|
||||
public ShowLayerData(ShowLayerData other)
|
||||
public object Clone()
|
||||
{
|
||||
QueuedEntities = other.QueuedEntities;
|
||||
return new ShowLayerData(QueuedEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user