Merge branch 'master' into kitchen
This commit is contained in:
@@ -151,6 +151,12 @@ namespace Content.Server.GameObjects
|
||||
return success;
|
||||
}
|
||||
|
||||
public void PutInHandOrDrop(ItemComponent item)
|
||||
{
|
||||
if (!PutInHand(item))
|
||||
item.Owner.Transform.GridPosition = Owner.Transform.GridPosition;
|
||||
}
|
||||
|
||||
public bool CanPutInHand(ItemComponent item)
|
||||
{
|
||||
foreach (var hand in ActivePriorityEnumerable())
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
using Content.Server.GameObjects.Components.Damage;
|
||||
using Content.Server.GameObjects.Components.Interactable.Tools;
|
||||
using Content.Server.GameObjects.Components.Power;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Shared.GameObjects.Components.Gravity;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.GameObjects.Components.UserInterface;
|
||||
using Robust.Server.GameObjects.EntitySystems;
|
||||
using Robust.Server.Interfaces.GameObjects;
|
||||
using Robust.Server.Interfaces.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Gravity
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class GravityGeneratorComponent: SharedGravityGeneratorComponent, IAttackBy, IBreakAct, IAttackHand
|
||||
{
|
||||
private BoundUserInterface _userInterface;
|
||||
|
||||
private PowerDeviceComponent _powerDevice;
|
||||
|
||||
private SpriteComponent _sprite;
|
||||
|
||||
private bool _switchedOn;
|
||||
|
||||
private bool _intact;
|
||||
|
||||
private GravityGeneratorStatus _status;
|
||||
|
||||
public bool Powered => _powerDevice.Powered;
|
||||
|
||||
public bool SwitchedOn => _switchedOn;
|
||||
|
||||
public bool Intact => _intact;
|
||||
|
||||
public GravityGeneratorStatus Status => _status;
|
||||
|
||||
public bool NeedsUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_status)
|
||||
{
|
||||
case GravityGeneratorStatus.On:
|
||||
return !(Powered && SwitchedOn && Intact);
|
||||
case GravityGeneratorStatus.Off:
|
||||
return SwitchedOn || !(Powered && Intact);
|
||||
case GravityGeneratorStatus.Unpowered:
|
||||
return SwitchedOn || Powered || !Intact;
|
||||
case GravityGeneratorStatus.Broken:
|
||||
return SwitchedOn || Powered || Intact;
|
||||
default:
|
||||
return true; // This _should_ be unreachable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name => "GravityGenerator";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
|
||||
.GetBoundUserInterface(GravityGeneratorUiKey.Key);
|
||||
_userInterface.OnReceiveMessage += HandleUIMessage;
|
||||
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
|
||||
_sprite = Owner.GetComponent<SpriteComponent>();
|
||||
_switchedOn = true;
|
||||
_intact = true;
|
||||
_status = GravityGeneratorStatus.On;
|
||||
UpdateState();
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _switchedOn, "switched_on", true);
|
||||
serializer.DataField(ref _intact, "intact", true);
|
||||
}
|
||||
|
||||
bool IAttackHand.AttackHand(AttackHandEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent<IActorComponent>(out var actor))
|
||||
return false;
|
||||
if (Status != GravityGeneratorStatus.Off && Status != GravityGeneratorStatus.On)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
OpenUserInterface(actor.playerSession);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.AttackWith.TryGetComponent<WelderComponent>(out var welder)) return false;
|
||||
if (welder.TryUse(5.0f))
|
||||
{
|
||||
// Repair generator
|
||||
var damagable = Owner.GetComponent<DamageableComponent>();
|
||||
var breakable = Owner.GetComponent<BreakableComponent>();
|
||||
damagable.HealAllDamage();
|
||||
breakable.broken = false;
|
||||
_intact = true;
|
||||
|
||||
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
|
||||
var notifyManager = IoCManager.Resolve<IServerNotifyManager>();
|
||||
|
||||
entitySystemManager.GetEntitySystem<AudioSystem>().Play("/Audio/items/welder2.ogg", Owner);
|
||||
notifyManager.PopupMessage(Owner, eventArgs.User, Loc.GetString("You repair the gravity generator with the welder"));
|
||||
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBreak(BreakageEventArgs eventArgs)
|
||||
{
|
||||
_intact = false;
|
||||
_switchedOn = false;
|
||||
}
|
||||
|
||||
public void UpdateState()
|
||||
{
|
||||
if (!Intact)
|
||||
{
|
||||
MakeBroken();
|
||||
} else if (!Powered)
|
||||
{
|
||||
MakeUnpowered();
|
||||
} else if (!SwitchedOn)
|
||||
{
|
||||
MakeOff();
|
||||
} else
|
||||
{
|
||||
MakeOn();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleUIMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message.Message)
|
||||
{
|
||||
case GeneratorStatusRequestMessage _:
|
||||
_userInterface.SetState(new GeneratorState(Status == GravityGeneratorStatus.On));
|
||||
break;
|
||||
case SwitchGeneratorMessage msg:
|
||||
_switchedOn = msg.On;
|
||||
UpdateState();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenUserInterface(IPlayerSession playerSession)
|
||||
{
|
||||
_userInterface.Open(playerSession);
|
||||
}
|
||||
|
||||
private void MakeBroken()
|
||||
{
|
||||
_status = GravityGeneratorStatus.Broken;
|
||||
_sprite.LayerSetState(0, "broken");
|
||||
_sprite.LayerSetVisible(1, false);
|
||||
}
|
||||
|
||||
private void MakeUnpowered()
|
||||
{
|
||||
_status = GravityGeneratorStatus.Unpowered;
|
||||
_sprite.LayerSetState(0, "off");
|
||||
_sprite.LayerSetVisible(1, false);
|
||||
}
|
||||
|
||||
private void MakeOff()
|
||||
{
|
||||
_status = GravityGeneratorStatus.Off;
|
||||
_sprite.LayerSetState(0, "off");
|
||||
_sprite.LayerSetVisible(1, false);
|
||||
}
|
||||
|
||||
private void MakeOn()
|
||||
{
|
||||
_status = GravityGeneratorStatus.On;
|
||||
_sprite.LayerSetState(0, "on");
|
||||
_sprite.LayerSetVisible(1, true);
|
||||
}
|
||||
}
|
||||
|
||||
public enum GravityGeneratorStatus
|
||||
{
|
||||
Broken,
|
||||
Unpowered,
|
||||
Off,
|
||||
On
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,8 @@ namespace Content.Server.GameObjects
|
||||
private int StorageCapacityMax = 10000;
|
||||
public HashSet<IPlayerSession> SubscribedSessions = new HashSet<IPlayerSession>();
|
||||
|
||||
public IReadOnlyCollection<IEntity> StoredEntities => storage.ContainedEntities;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -140,7 +142,6 @@ namespace Content.Server.GameObjects
|
||||
/// <returns></returns>
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
{
|
||||
_ensureInitialCalculated();
|
||||
Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, eventArgs.User.Uid, eventArgs.AttackWith.Uid);
|
||||
|
||||
if(Owner.TryGetComponent<PlaceableSurfaceComponent>(out var placeableSurfaceComponent))
|
||||
@@ -363,8 +364,10 @@ namespace Content.Server.GameObjects
|
||||
/// <summary>
|
||||
/// Inserts an entity into the storage component from the players active hand.
|
||||
/// </summary>
|
||||
private bool PlayerInsertEntity(IEntity player)
|
||||
public bool PlayerInsertEntity(IEntity player)
|
||||
{
|
||||
_ensureInitialCalculated();
|
||||
|
||||
if (!player.TryGetComponent(out IHandsComponent hands) || hands.GetActiveHand == null)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -118,9 +118,17 @@ namespace Content.Server.GameObjects.Components.Mobs
|
||||
if (!ShowExamineInfo)
|
||||
return;
|
||||
|
||||
var dead = false;
|
||||
|
||||
if(Owner.TryGetComponent<SpeciesComponent>(out var species))
|
||||
if (species.CurrentDamageState is DeadState)
|
||||
dead = true;
|
||||
|
||||
// TODO: Use gendered pronouns depending on the entity
|
||||
if(!HasMind)
|
||||
message.AddMarkup($"[color=red]They are totally catatonic. The stresses of life in deep-space must have been too much for them. Any recovery is unlikely.[/color]");
|
||||
message.AddMarkup(!dead
|
||||
? $"[color=red]They are totally catatonic. The stresses of life in deep-space must have been too much for them. Any recovery is unlikely.[/color]"
|
||||
: $"[color=purple]Their soul has departed.[/color]");
|
||||
else if(Mind.Session == null)
|
||||
message.AddMarkup("[color=yellow]They have a blank, absent-minded stare and appears completely unresponsive to anything. They may snap out of it soon.[/color]");
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace Content.Server.GameObjects
|
||||
|
||||
currentstate = threshold;
|
||||
|
||||
EntityEventArgs toRaise = new MobDamageStateChangedMessage(this);
|
||||
var toRaise = new MobDamageStateChangedMessage(this);
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, toRaise);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,15 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float CurrentPushSpeed => 5.0f;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float GrabRange => 0.2f;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Is the entity Sprinting (running)?
|
||||
/// </summary>
|
||||
|
||||
@@ -67,6 +67,14 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float CurrentPushSpeed => 5.0f;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float GrabRange => 0.2f;
|
||||
|
||||
/// <summary>
|
||||
/// Is the entity Sprinting (running)?
|
||||
/// </summary>
|
||||
|
||||
@@ -34,6 +34,15 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float CurrentWalkSpeed { get; set; } = 8;
|
||||
public float CurrentSprintSpeed { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float CurrentPushSpeed => 0.0f;
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
public float GrabRange => 0.0f;
|
||||
|
||||
public bool Sprinting { get; set; }
|
||||
public Vector2 VelocityDir { get; } = Vector2.Zero;
|
||||
public GridCoordinates LastPosition { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.Audio;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -16,17 +17,24 @@ namespace Content.Server.GameObjects.Components.Sound
|
||||
public override string Name => "EmitSoundOnUse";
|
||||
|
||||
public string _soundName;
|
||||
public float _pitchVariation;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _soundName, "sound", "");
|
||||
serializer.DataField(ref _soundName, "sound", string.Empty);
|
||||
serializer.DataField(ref _pitchVariation, "variation", 0.0f);
|
||||
}
|
||||
|
||||
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_soundName))
|
||||
{
|
||||
if (_pitchVariation > 0.0)
|
||||
{
|
||||
Owner.GetComponent<SoundComponent>().Play(_soundName, AudioHelpers.WithVariation(_pitchVariation).WithVolume(-2f));
|
||||
return true;
|
||||
}
|
||||
Owner.GetComponent<SoundComponent>().Play(_soundName, AudioParams.Default.WithVolume(-2f));
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user