* Initial framework for pulling. * Make it possible to pull items via (temporary) keybind Ctrl+Click, make items follow the player correctly. * Make other objects pullable, implement functionality for moving an object being pulled, make only one object able to be pulled at a time. * Make sure that MoveTo won't allow collisions with the player * Update everything to work with the new physics engine * Update Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs Co-authored-by: ComicIronic <comicironic@gmail.com> * Physics update and convert to direct type casts * Add notnull checks * Add pull keybinds to the tutorial window * Move PullController to shared * Fix pulled items getting left behind * Fix moving pulled objects into walls * Remove flooring of coordinates when moving pulled objects * Add missing null check in PutInHand * Change pulling keybind to control and throwing to alt * Change PhysicsComponent references to IPhysicsComponent * Add trying to pull a pulled entity disabling the pull * Add pulled status effect * Fix merge conflicts * Merge fixes * Make players pullable * Fix being able to pull yourself * Change pull moving to use a velocity * Update pulled and pulling icons to not be buckle A tragedy * Make pulled and pulling icons more consistent * Remove empty not pulled and not pulling images * Pulled icon update * Pulled icon update * Add clicking pulling status effect to stop the pull * Fix spacewalking when pulling * Merge conflict fixes * Add a pull verb * Fix nullable error * Add pulling through the entity drop down menu Co-authored-by: Jackson Lewis <inquisitivepenguin@protonmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com>
125 lines
4.0 KiB
C#
125 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Content.Server.GameObjects.Components.Buckle;
|
|
using Content.Server.GameObjects.Components.GUI;
|
|
using Content.Server.GameObjects.Components.Movement;
|
|
using Content.Shared.GameObjects.Components.Mobs;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Interfaces.Network;
|
|
using Robust.Shared.Players;
|
|
|
|
namespace Content.Server.GameObjects.Components.Mobs
|
|
{
|
|
[RegisterComponent]
|
|
[ComponentReference(typeof(SharedStatusEffectsComponent))]
|
|
public sealed class ServerStatusEffectsComponent : SharedStatusEffectsComponent
|
|
{
|
|
private readonly Dictionary<StatusEffect, StatusEffectStatus> _statusEffects = new Dictionary<StatusEffect, StatusEffectStatus>();
|
|
|
|
public override ComponentState GetComponentState()
|
|
{
|
|
return new StatusEffectComponentState(_statusEffects);
|
|
}
|
|
|
|
public void ChangeStatusEffectIcon(StatusEffect effect, string icon)
|
|
{
|
|
if (_statusEffects.TryGetValue(effect, out var value) && value.Icon == icon)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_statusEffects[effect] = new StatusEffectStatus()
|
|
{Icon = icon, Cooldown = value.Cooldown};
|
|
Dirty();
|
|
}
|
|
|
|
public void ChangeStatusEffectCooldown(StatusEffect effect, ValueTuple<TimeSpan, TimeSpan> cooldown)
|
|
{
|
|
if (_statusEffects.TryGetValue(effect, out var value)
|
|
&& value.Cooldown == cooldown)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_statusEffects[effect] = new StatusEffectStatus()
|
|
{
|
|
Icon = value.Icon, Cooldown = cooldown
|
|
};
|
|
Dirty();
|
|
}
|
|
|
|
public override void ChangeStatusEffect(StatusEffect effect, string icon, ValueTuple<TimeSpan, TimeSpan>? cooldown)
|
|
{
|
|
_statusEffects[effect] = new StatusEffectStatus()
|
|
{Icon = icon, Cooldown = cooldown};
|
|
|
|
Dirty();
|
|
}
|
|
|
|
public void RemoveStatusEffect(StatusEffect effect)
|
|
{
|
|
if (!_statusEffects.Remove(effect))
|
|
{
|
|
return;
|
|
}
|
|
|
|
Dirty();
|
|
}
|
|
|
|
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession session = null)
|
|
{
|
|
base.HandleNetworkMessage(message, netChannel, session);
|
|
|
|
if (session == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(session));
|
|
}
|
|
|
|
switch (message)
|
|
{
|
|
case ClickStatusMessage msg:
|
|
{
|
|
var player = session.AttachedEntity;
|
|
|
|
if (player != Owner)
|
|
{
|
|
break;
|
|
}
|
|
|
|
// TODO: Implement clicking other status effects in the HUD
|
|
switch (msg.Effect)
|
|
{
|
|
case StatusEffect.Buckled:
|
|
if (!player.TryGetComponent(out BuckleComponent buckle))
|
|
{
|
|
break;
|
|
}
|
|
|
|
buckle.TryUnbuckle(player);
|
|
break;
|
|
case StatusEffect.Piloting:
|
|
if (!player.TryGetComponent(out ShuttleControllerComponent controller))
|
|
{
|
|
break;
|
|
}
|
|
|
|
controller.RemoveController();
|
|
break;
|
|
case StatusEffect.Pulling:
|
|
if (!player.TryGetComponent(out HandsComponent hands))
|
|
{
|
|
break;
|
|
}
|
|
|
|
hands.StopPull();
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|