Make component states dependant on the player getting them (#3280)

* Make component states dependant on the player getting them

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>

* Updated submodule to v0.3.7.

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Acruid <shatter66@gmail.com>
This commit is contained in:
DrSmugleaf
2021-02-18 09:09:07 +01:00
committed by GitHub
parent 77c8fc5b42
commit 1477cd4d0a
61 changed files with 145 additions and 88 deletions

View File

@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Buckle;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
@@ -10,6 +11,7 @@ using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.EntitySystems.EffectBlocker;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
@@ -52,8 +54,9 @@ namespace Content.IntegrationTests.Tests.Buckle
[Test]
public async Task BuckleUnbuckleCooldownRangeTest()
{
var options = new ServerIntegrationOptions {ExtraPrototypes = Prototypes};
var server = StartServer(options);
var cOptions = new ClientIntegrationOptions {ExtraPrototypes = Prototypes};
var sOptions = new ServerIntegrationOptions {ExtraPrototypes = Prototypes};
var (client, server) = await StartConnectedServerClientPair(cOptions, sOptions);
IEntity human = null;
IEntity chair = null;
@@ -91,7 +94,9 @@ namespace Content.IntegrationTests.Tests.Buckle
Assert.True(buckle.TryBuckle(human, chair));
Assert.NotNull(buckle.BuckledTo);
Assert.True(buckle.Buckled);
Assert.True(((BuckleComponentState) buckle.GetComponentState()).Buckled);
var player = IoCManager.Resolve<IPlayerManager>().GetAllPlayers().Single();
Assert.True(((BuckleComponentState) buckle.GetComponentState(player)).Buckled);
Assert.False(ActionBlockerSystem.CanMove(human));
Assert.False(ActionBlockerSystem.CanChangeDirection(human));
Assert.False(EffectBlockerSystem.CanFall(human));

View File

@@ -1,19 +1,20 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.GameObjects;
using NUnit.Framework;
using Robust.Client.GameObjects;
using Robust.Client.GameStates;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Reflection;
using Robust.Shared.Timing;
using System;
using Robust.Client.GameStates;
using Robust.Server.Player;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
namespace Content.IntegrationTests.Tests.Networking
{
@@ -408,7 +409,7 @@ namespace Content.IntegrationTests.Tests.Networking
Foo = pred.Foo;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new PredictionComponentState(Foo);
}

View File

@@ -16,6 +16,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.ActionBlocking
@@ -55,7 +56,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
Owner.EnsureComponentWarn<HandsComponent>();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
// there are 2 approaches i can think of to handle the handcuff overlay on players
// 1 - make the current RSI the handcuff type that's currently active. all handcuffs on the player will appear the same.

View File

@@ -13,6 +13,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -136,7 +137,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
serializer.DataField(this, x => x.BrokenDesc, "brokenDesc", string.Empty);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new HandcuffedComponentState(Broken ? BrokenState : string.Empty);
}

View File

@@ -1,4 +1,6 @@
#nullable enable
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Server.Utility;
@@ -9,13 +11,12 @@ using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.ViewVariables;
using System.Collections.Generic;
using System.Threading.Tasks;
using Robust.Server.Player;
namespace Content.Server.GameObjects.Components.Atmos
{
@@ -44,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Atmos
Owner.TryGetComponent(out _appearance);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new GasAnalyzerComponentState(_pressureDanger);
}

View File

@@ -21,6 +21,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -408,7 +409,7 @@ namespace Content.Server.GameObjects.Components.Buckle
UpdateBuckleStatus();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
int? drawDepth = null;

View File

@@ -2,6 +2,7 @@ using Content.Server.Cargo;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Cargo;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components.Cargo
{
@@ -18,7 +19,7 @@ namespace Content.Server.GameObjects.Components.Cargo
Database = EntitySystem.Get<CargoConsoleSystem>().StationOrderDatabase;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
if (!ConnectedToDatabase)
return new CargoOrderDatabaseState(null);

View File

@@ -1,12 +1,13 @@
using Content.Shared.GameObjects.Components.Cargo;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components.Cargo
{
[RegisterComponent]
public class GalacticMarketComponent : SharedGalacticMarketComponent
{
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new GalacticMarketState(GetProductIdList());
}

View File

@@ -11,6 +11,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -129,7 +130,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
Dirty();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
if (_solution == null)
return new HyposprayComponentState(ReagentUnit.Zero, ReagentUnit.Zero);

View File

@@ -10,6 +10,7 @@ using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -291,7 +292,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
Dirty();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
Owner.TryGetComponent(out SolutionContainerComponent? solution);

View File

@@ -1,4 +1,6 @@
#nullable enable
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Utility;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components;
@@ -10,11 +12,10 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System.Linq;
using System.Threading.Tasks;
namespace Content.Server.GameObjects.Components
{
@@ -83,7 +84,7 @@ namespace Content.Server.GameObjects.Components
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new CrayonComponentState(_color, SelectedState, Charges, Capacity);
}

View File

@@ -4,6 +4,7 @@ using Content.Server.GameObjects.EntitySystems.DoAfter;
using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Damage;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components
{
@@ -17,7 +18,7 @@ namespace Content.Server.GameObjects.Components
// we'll just send them the index. Doesn't matter if it wraps around.
private byte _runningIndex;
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var toAdd = new List<ClientDoAfter>();

View File

@@ -24,6 +24,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Timer = Robust.Shared.Timers.Timer;
@@ -640,7 +641,7 @@ namespace Content.Server.GameObjects.Components.Doors
return false;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new DoorComponentState(State, StateChangeStartTime, CurrentlyCrushing, GameTiming.CurTime);
}

View File

@@ -497,7 +497,7 @@ namespace Content.Server.GameObjects.Components.GUI
return _hands.Any(hand => hand.Name == name);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var hands = new SharedHand[_hands.Count];

View File

@@ -604,7 +604,7 @@ namespace Content.Server.GameObjects.Components.GUI
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var list = new List<KeyValuePair<Slots, EntityUid>>();
foreach (var (slot, container) in _slotContainers)

View File

@@ -175,7 +175,7 @@ namespace Content.Server.GameObjects.Components.Instruments
serializer.DataField(ref _respectMidiLimits, "respectMidiLimits", true);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new InstrumentState(Playing, InstrumentProgram, InstrumentBank, AllowPercussion, AllowProgramChange, RespectMidiLimits, _lastSequencerTick);
}

View File

@@ -17,6 +17,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -244,7 +245,7 @@ namespace Content.Server.GameObjects.Components.Interactable
return (byte?) ContentHelpers.RoundToNearestLevels(currentCharge / Cell.MaxCharge * 255, 255, StatusLevels);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new HandheldLightComponentState(GetLevel());
}

View File

@@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Interactable
@@ -107,7 +108,7 @@ namespace Content.Server.GameObjects.Components.Interactable
return true;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new MultiToolComponentState(_tool.Qualities);
}

View File

@@ -20,6 +20,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -98,7 +99,7 @@ namespace Content.Server.GameObjects.Components.Interactable
serializer.DataField(this, collection => WeldSoundCollection, "weldSoundCollection", string.Empty);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new WelderComponentState(FuelCapacity, Fuel, WelderLit);
}

View File

@@ -8,6 +8,7 @@ using Content.Shared.GameObjects.Components.Storage;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
@@ -66,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Items.Clothing
serializer.DataFieldCached(ref _heatResistance, "HeatResistance", 323);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ClothingComponentState(ClothingEquippedPrefix, EquippedPrefix);
}

View File

@@ -13,6 +13,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -129,7 +130,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession session)
{
return new ItemComponentState(EquippedPrefix);
}

View File

@@ -1,5 +1,6 @@
using Content.Shared.GameObjects.Components.Storage;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components.Items.Storage
{
@@ -25,7 +26,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new StorableComponentState(_size);
}

View File

@@ -15,6 +15,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
@@ -112,7 +113,7 @@ namespace Content.Server.GameObjects.Components
Toggle(eventArgs.User);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new MagbootsComponentState(On);
}

View File

@@ -10,6 +10,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Timing;
@@ -115,7 +116,7 @@ namespace Content.Server.GameObjects.Components.Mobs
.PlayFromEntity("/Audio/Effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.05f));
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new StunnableComponentState(StunnedTimer, KnockdownTimer, SlowdownTimer, WalkModifierOverride,
RunModifierOverride);

View File

@@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components.Movement
{
@@ -79,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Movement
IsOnClimbableThisFrame = false;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ClimbModeComponentState(_isClimbing);
}

View File

@@ -2,6 +2,7 @@
using Content.Shared.GameObjects.Components.Movement;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -102,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Movement
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new SlipperyComponentState(_paralyzeTime, _intersectPercentage, _requiredSlipSpeed, _launchForwardsMultiplier, _slippery);
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -213,7 +214,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
UpdateCurrentThreshold();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new HungerComponentState(_currentHungerThreshold);
}

View File

@@ -10,6 +10,7 @@ using Content.Shared.GameObjects.Components.Nutrition;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -209,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
UpdateCurrentThreshold();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ThirstComponentState(_currentThirstThreshold);
}

View File

@@ -1,22 +1,22 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.Markers;
using Content.Server.Players;
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.Mobs;
using Content.Server.Players;
using Content.Shared.GameObjects.Components.Observer;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.ViewVariables;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.Utility;
using Robust.Shared.Localization;
using System;
using Robust.Server.Player;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
#nullable enable
namespace Content.Server.GameObjects.Components.Observer
@@ -47,7 +47,7 @@ namespace Content.Server.GameObjects.Components.Observer
_timeOfDeath = _gameTimer.RealTime;
}
public override ComponentState GetComponentState() => new GhostComponentState(CanReturnToBody);
public override ComponentState GetComponentState(ICommonSession player) => new GhostComponentState(CanReturnToBody);
public override void HandleMessage(ComponentMessage message, IComponent? component)
{

View File

@@ -4,6 +4,7 @@ using Content.Shared.GameObjects.Components;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -82,7 +83,7 @@ namespace Content.Server.GameObjects.Components
serializer.DataField(ref _positionOffset, "positionOffset", Vector2.Zero);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new PlaceableSurfaceComponentState(_isPlaceable,_placeCentered,_positionOffset);
}

View File

@@ -5,6 +5,7 @@ using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Projectiles;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -114,7 +115,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
if (collideCount > 0 && DeleteOnCollide && _internalDeleteOnCollide) Owner.Delete();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ProjectileComponentState(NetID!.Value, _shooter, IgnoreShooter);
}

View File

@@ -1,6 +1,7 @@
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -17,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Research
public bool Static => _static;
private bool _static = false;
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new LatheDatabaseState(GetRecipeIdList());
}

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -20,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Research
public int StorageLimit => _storageLimit;
private int _storageLimit;
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new MaterialStorageState(Storage);
}

View File

@@ -2,6 +2,7 @@ using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
namespace Content.Server.GameObjects.Components.Research
@@ -14,7 +15,7 @@ namespace Content.Server.GameObjects.Components.Research
public override string Name => "ProtolatheDatabase";
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ProtolatheDatabaseState(GetRecipeIdList());
}

View File

@@ -1,13 +1,14 @@
using Content.Shared.GameObjects.Components.Research;
using Content.Shared.Research;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
namespace Content.Server.GameObjects.Components.Research
{
[RegisterComponent]
public class TechnologyDatabaseComponent : SharedTechnologyDatabaseComponent
{
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new TechnologyDatabaseState(_technologies);
}

View File

@@ -3,6 +3,7 @@ using Content.Shared.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
@@ -102,7 +103,7 @@ namespace Content.Server.GameObjects.Components.StationEvents
Dirty();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new RadiationPulseState(_radsPerSecond, _range, Draw, Decay, _endTime);
}

View File

@@ -11,6 +11,7 @@ using Content.Shared.Utility;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -163,7 +164,7 @@ namespace Content.Server.GameObjects.Components.Strap
_occupiedSize = 0;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new StrapComponentState(Position);
}

View File

@@ -13,6 +13,7 @@ using Content.Shared.GameObjects.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -140,7 +141,7 @@ namespace Content.Server.GameObjects.Components.Suspicion
message.AddMarkup(tooltip);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return Role == null
? new SuspicionRoleComponentState(null, null, Array.Empty<(string, EntityUid)>())

View File

@@ -4,6 +4,7 @@ using Content.Shared.Utility;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Timing;
namespace Content.Server.GameObjects.Components.Weapon
@@ -23,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Weapon
Dirty();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new FlashComponentState(_duration, _lastFlash);
}

View File

@@ -14,6 +14,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -128,7 +129,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
UpdateAppearance();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
(int, int)? count = (ShotsLeft, Capacity);
var chamberedExists = _chamberContainer.ContainedEntity != null;

View File

@@ -11,6 +11,7 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -82,7 +83,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
UpdateAppearance();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
(int, int)? count = (ShotsLeft, Capacity);
var chamberedExists = _chamberContainer.ContainedEntity != null;

View File

@@ -13,6 +13,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -66,7 +67,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
serializer.DataField(ref _soundSpin, "soundSpin", "/Audio/Weapons/Guns/Misc/revolver_spin.ogg");
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var slotsSpent = new bool?[Capacity];
for (var i = 0; i < Capacity; i++)

View File

@@ -16,6 +16,7 @@ using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -89,7 +90,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
serializer.DataField(ref _soundPowerCellEject, "soundPowerCellEject", null);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
(int, int)? count = (ShotsLeft, Capacity);

View File

@@ -18,6 +18,7 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -164,7 +165,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
return types;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
(int, int)? count = null;
var magazine = _magazineContainer.ContainedEntity;

View File

@@ -18,7 +18,6 @@ using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Random;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -120,7 +119,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new RangedWeaponComponentState(FireRateSelector);
}

View File

@@ -7,6 +7,7 @@ using Content.Shared.GameObjects.Components.Body.Surgery;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -134,7 +135,7 @@ namespace Content.Shared.GameObjects.Components.Body.Part
serializer.DataField(ref _mechanismIds, "mechanisms", new List<string>());
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var mechanismIds = new EntityUid[_mechanisms.Count];

View File

@@ -13,11 +13,11 @@ using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using Component = Robust.Shared.GameObjects.Component;
namespace Content.Shared.GameObjects.Components.Body
{
@@ -653,7 +653,7 @@ namespace Content.Shared.GameObjects.Components.Body
Connections = cleanedConnections;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var parts = new (string slot, EntityUid partId)[_parts.Count];

View File

@@ -1,4 +1,6 @@
#nullable enable
using System;
using System.Collections.Generic;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
@@ -6,12 +8,11 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
namespace Content.Shared.GameObjects.Components.Chemistry
{
@@ -261,7 +262,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
return new SolutionContainerVisualState(Color, filledVolumeFraction);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new SolutionContainerComponentState(Solution);
}

View File

@@ -5,10 +5,11 @@ using System.Linq;
using Content.Shared.Damage;
using Content.Shared.Damage.DamageContainer;
using Content.Shared.Damage.ResistanceSet;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -165,7 +166,7 @@ namespace Content.Shared.GameObjects.Components.Damage
ForceHealthChangedEvent();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new DamageableComponentState(_damageList, _flags);
}

View File

@@ -1,5 +1,6 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -51,7 +52,7 @@ namespace Content.Shared.GameObjects.Components.Items
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ItemCooldownComponentState
{

View File

@@ -7,6 +7,7 @@ using Content.Shared.Actions;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -76,7 +77,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new ActionComponentState(_actions, _itemActions);
}

View File

@@ -4,6 +4,7 @@ using Content.Shared.Alert;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -35,7 +36,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
_alerts = state.Alerts;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new AlertsComponentState(_alerts);
}

View File

@@ -1,5 +1,6 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -47,7 +48,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new CombatModeComponentState(IsInCombatMode, ActiveZone);
}

View File

@@ -2,6 +2,7 @@
using Content.Shared.Preferences;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization.Macros;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -49,7 +50,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new HumanoidAppearanceComponentState(Appearance, Sex, Gender);
}

View File

@@ -7,6 +7,7 @@ using Content.Shared.Alert;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Robust.Shared.GameObjects;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -28,6 +29,7 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
/// States that this <see cref="SharedMobStateComponent"/> mapped to
/// the amount of damage at which they are triggered.
/// A threshold is reached when the total damage of an entity is equal
/// A threshold is reached when the total damage of an entity is equal
/// to or higher than the int key, but lower than the next threshold.
/// Ordered from lowest to highest.
/// </summary>
@@ -75,7 +77,7 @@ namespace Content.Shared.GameObjects.Components.Mobs.State
base.OnRemove();
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new MobStateComponentState(CurrentThreshold);
}

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -228,7 +229,7 @@ namespace Content.Shared.GameObjects.Components.Movement
}
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new MoverComponentState(_heldMoveButtons);
}

View File

@@ -10,6 +10,7 @@ using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Pulling
@@ -253,7 +254,7 @@ namespace Content.Shared.GameObjects.Components.Pulling
return controller.TryMoveTo(Puller.Transform.Coordinates, to);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new PullableComponentState(Puller?.Uid);
}

View File

@@ -1,6 +1,7 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -85,7 +86,7 @@ namespace Content.Shared.GameObjects.Components
StackType = stackType;
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
return new StackComponentState(Count, MaxCount);
}

View File

@@ -4,6 +4,7 @@ using System.Linq;
using Content.Shared.Prototypes.Tag;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -41,7 +42,7 @@ namespace Content.Shared.GameObjects.Components.Tag
() => _tags);
}
public override ComponentState GetComponentState()
public override ComponentState GetComponentState(ICommonSession player)
{
var tags = new string[_tags.Count];
var i = 0;

View File

@@ -48,18 +48,18 @@ namespace Content.Tests.Server.GameObjects.Components.Mobs
Assert.That(alertManager.TryGet(AlertType.HighPressure, out var highpressure));
alertsComponent.ShowAlert(AlertType.LowPressure);
var alertState = alertsComponent.GetComponentState() as AlertsComponentState;
var alertState = alertsComponent.GetComponentState(null) as AlertsComponentState;
Assert.NotNull(alertState);
Assert.That(alertState.Alerts.Count, Is.EqualTo(1));
Assert.That(alertState.Alerts.ContainsKey(lowpressure.AlertKey));
alertsComponent.ShowAlert(AlertType.HighPressure);
alertState = alertsComponent.GetComponentState() as AlertsComponentState;
alertState = alertsComponent.GetComponentState(null) as AlertsComponentState;
Assert.That(alertState.Alerts.Count, Is.EqualTo(1));
Assert.That(alertState.Alerts.ContainsKey(highpressure.AlertKey));
alertsComponent.ClearAlertCategory(AlertCategory.Pressure);
alertState = alertsComponent.GetComponentState() as AlertsComponentState;
alertState = alertsComponent.GetComponentState(null) as AlertsComponentState;
Assert.That(alertState.Alerts.Count, Is.EqualTo(0));
}
}