Admin ghosts can now interact with stuff (#4178)
* Ghosts now have a bool for interacting with stuff * Wrong ghost * Simping for Swept * Merge cleanup * IT'S ODNE Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Shared.Ghost;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Player;
|
using Robust.Client.Player;
|
||||||
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ namespace Content.Client.Ghost
|
|||||||
private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args)
|
private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args)
|
||||||
{
|
{
|
||||||
component.Gui?.Dispose();
|
component.Gui?.Dispose();
|
||||||
|
component.Gui = null;
|
||||||
|
|
||||||
// PlayerDetachedMsg might not fire due to deletion order so...
|
// PlayerDetachedMsg might not fire due to deletion order so...
|
||||||
if (component.IsAttached)
|
if (component.IsAttached)
|
||||||
@@ -72,15 +74,12 @@ namespace Content.Client.Ghost
|
|||||||
|
|
||||||
private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, PlayerAttachedEvent playerAttachedEvent)
|
private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, PlayerAttachedEvent playerAttachedEvent)
|
||||||
{
|
{
|
||||||
|
// I hate UI I hate UI I Hate UI
|
||||||
if (component.Gui == null)
|
if (component.Gui == null)
|
||||||
{
|
{
|
||||||
component.Gui = new GhostGui(component, EntityManager.EntityNetManager!);
|
component.Gui = new GhostGui(component, EntityManager.EntityNetManager!);
|
||||||
component.Gui.Update();
|
component.Gui.Update();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
component.Gui.Orphan();
|
|
||||||
}
|
|
||||||
|
|
||||||
_gameHud.HandsContainer.AddChild(component.Gui);
|
_gameHud.HandsContainer.AddChild(component.Gui);
|
||||||
GhostVisibility = true;
|
GhostVisibility = true;
|
||||||
|
|||||||
@@ -339,10 +339,11 @@ namespace Content.Client.HUD
|
|||||||
LC.SetMarginBottom(centerBottomContainer, -10f);
|
LC.SetMarginBottom(centerBottomContainer, -10f);
|
||||||
RootControl.AddChild(centerBottomContainer);
|
RootControl.AddChild(centerBottomContainer);
|
||||||
|
|
||||||
HandsContainer = new Control
|
HandsContainer = new BoxContainer()
|
||||||
{
|
{
|
||||||
VerticalAlignment = Control.VAlignment.Bottom,
|
VerticalAlignment = Control.VAlignment.Bottom,
|
||||||
HorizontalAlignment = Control.HAlignment.Center
|
HorizontalAlignment = Control.HAlignment.Center,
|
||||||
|
Orientation = LayoutOrientation.Vertical,
|
||||||
};
|
};
|
||||||
BottomRightInventoryQuickButtonContainer = new BoxContainer
|
BottomRightInventoryQuickButtonContainer = new BoxContainer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ namespace Content.Client.Hands
|
|||||||
{
|
{
|
||||||
component.Gui = new HandsGui(component, this);
|
component.Gui = new HandsGui(component, this);
|
||||||
_gameHud.HandsContainer.AddChild(component.Gui);
|
_gameHud.HandsContainer.AddChild(component.Gui);
|
||||||
|
component.Gui.SetPositionFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void HandlePlayerDetached(EntityUid uid, HandsComponent component, PlayerDetachedEvent args)
|
private static void HandlePlayerDetached(EntityUid uid, HandsComponent component, PlayerDetachedEvent args)
|
||||||
|
|||||||
@@ -76,6 +76,17 @@ namespace Content.Client.Input
|
|||||||
common.AddFunction(ContentKeyFunctions.Loadout8);
|
common.AddFunction(ContentKeyFunctions.Loadout8);
|
||||||
common.AddFunction(ContentKeyFunctions.Loadout9);
|
common.AddFunction(ContentKeyFunctions.Loadout9);
|
||||||
|
|
||||||
|
var aghost = contexts.New("aghost", "common");
|
||||||
|
aghost.AddFunction(EngineKeyFunctions.MoveUp);
|
||||||
|
aghost.AddFunction(EngineKeyFunctions.MoveDown);
|
||||||
|
aghost.AddFunction(EngineKeyFunctions.MoveLeft);
|
||||||
|
aghost.AddFunction(EngineKeyFunctions.MoveRight);
|
||||||
|
aghost.AddFunction(EngineKeyFunctions.Walk);
|
||||||
|
aghost.AddFunction(ContentKeyFunctions.OpenContextMenu);
|
||||||
|
aghost.AddFunction(ContentKeyFunctions.SwapHands);
|
||||||
|
aghost.AddFunction(ContentKeyFunctions.Drop);
|
||||||
|
aghost.AddFunction(ContentKeyFunctions.ThrowItemInHand);
|
||||||
|
|
||||||
var ghost = contexts.New("ghost", "common");
|
var ghost = contexts.New("ghost", "common");
|
||||||
ghost.AddFunction(EngineKeyFunctions.MoveUp);
|
ghost.AddFunction(EngineKeyFunctions.MoveUp);
|
||||||
ghost.AddFunction(EngineKeyFunctions.MoveDown);
|
ghost.AddFunction(EngineKeyFunctions.MoveDown);
|
||||||
|
|||||||
@@ -94,8 +94,6 @@ namespace Content.Shared.Body.Components
|
|||||||
SlotIds[slotId].SetConnectionsInternal(connections);
|
SlotIds[slotId].SetConnectionsInternal(connections);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CalculateSpeed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnRemove()
|
protected override void OnRemove()
|
||||||
@@ -474,51 +472,8 @@ namespace Content.Shared.Body.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalculateSpeed()
|
|
||||||
{
|
|
||||||
if (!Owner.TryGetComponent(out MovementSpeedModifierComponent? playerMover))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var legs = GetPartsWithProperty<LegComponent>().ToArray();
|
|
||||||
float speedSum = 0;
|
|
||||||
|
|
||||||
foreach (var leg in legs)
|
|
||||||
{
|
|
||||||
var footDistance = DistanceToNearestFoot(leg.part);
|
|
||||||
|
|
||||||
if (Math.Abs(footDistance - float.MinValue) <= 0.001f)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
speedSum += leg.property.Speed * (1 + (float) Math.Log(footDistance, 1024.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (speedSum <= 0.001f)
|
|
||||||
{
|
|
||||||
playerMover.BaseWalkSpeed = 0.8f;
|
|
||||||
playerMover.BaseSprintSpeed = 2.0f;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Extra legs stack diminishingly.
|
|
||||||
playerMover.BaseWalkSpeed =
|
|
||||||
speedSum / (legs.Length - (float) Math.Log(legs.Length, 4.0));
|
|
||||||
|
|
||||||
playerMover.BaseSprintSpeed = playerMover.BaseWalkSpeed * 1.75f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnBodyChanged()
|
private void OnBodyChanged()
|
||||||
{
|
{
|
||||||
// Calculate move speed based on this body.
|
|
||||||
if (Owner.HasComponent<MovementSpeedModifierComponent>())
|
|
||||||
{
|
|
||||||
CalculateSpeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,17 +15,43 @@ namespace Content.Shared.Ghost
|
|||||||
{
|
{
|
||||||
public override string Name => "Ghost";
|
public override string Name => "Ghost";
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool CanGhostInteract
|
||||||
|
{
|
||||||
|
get => _canGhostInteract;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_canGhostInteract == value) return;
|
||||||
|
_canGhostInteract = value;
|
||||||
|
Dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DataField("canInteract")]
|
||||||
|
private bool _canGhostInteract;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
|
/// Changed by <see cref="SharedGhostSystem.SetCanReturnToBody"/>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
// TODO MIRROR change this to use friend classes when thats merged
|
// TODO MIRROR change this to use friend classes when thats merged
|
||||||
[DataField("canReturnToBody")]
|
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool CanReturnToBody { get; set; }
|
public bool CanReturnToBody
|
||||||
|
{
|
||||||
|
get => _canReturnToBody;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_canReturnToBody == value) return;
|
||||||
|
_canReturnToBody = value;
|
||||||
|
Dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DataField("canReturnToBody")]
|
||||||
|
private bool _canReturnToBody;
|
||||||
|
|
||||||
public override ComponentState GetComponentState(ICommonSession player)
|
public override ComponentState GetComponentState(ICommonSession player)
|
||||||
{
|
{
|
||||||
return new GhostComponentState(CanReturnToBody);
|
return new GhostComponentState(CanReturnToBody, CanGhostInteract);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||||
@@ -38,13 +64,14 @@ namespace Content.Shared.Ghost
|
|||||||
}
|
}
|
||||||
|
|
||||||
CanReturnToBody = state.CanReturnToBody;
|
CanReturnToBody = state.CanReturnToBody;
|
||||||
|
CanGhostInteract = state.CanGhostInteract;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanInteract() => false;
|
public bool CanInteract() => CanGhostInteract;
|
||||||
public bool CanUse() => false;
|
public bool CanUse() => CanGhostInteract;
|
||||||
public bool CanThrow() => false;
|
public bool CanThrow() => false;
|
||||||
public bool CanDrop() => false;
|
public bool CanDrop() => CanGhostInteract;
|
||||||
public bool CanPickup() => false;
|
public bool CanPickup() => CanGhostInteract;
|
||||||
public bool CanEmote() => false;
|
public bool CanEmote() => false;
|
||||||
public bool CanAttack() => false;
|
public bool CanAttack() => false;
|
||||||
}
|
}
|
||||||
@@ -53,19 +80,14 @@ namespace Content.Shared.Ghost
|
|||||||
public class GhostComponentState : ComponentState
|
public class GhostComponentState : ComponentState
|
||||||
{
|
{
|
||||||
public bool CanReturnToBody { get; }
|
public bool CanReturnToBody { get; }
|
||||||
|
public bool CanGhostInteract { get; }
|
||||||
public HashSet<string>? LocationWarps { get; }
|
|
||||||
|
|
||||||
public Dictionary<EntityUid, string>? PlayerWarps { get; }
|
|
||||||
|
|
||||||
public GhostComponentState(
|
public GhostComponentState(
|
||||||
bool canReturnToBody,
|
bool canReturnToBody,
|
||||||
HashSet<string>? locationWarps = null,
|
bool canGhostInteract)
|
||||||
Dictionary<EntityUid, string>? playerWarps = null)
|
|
||||||
{
|
{
|
||||||
CanReturnToBody = canReturnToBody;
|
CanReturnToBody = canReturnToBody;
|
||||||
LocationWarps = locationWarps;
|
CanGhostInteract = canGhostInteract;
|
||||||
PlayerWarps = playerWarps;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
Resources/Prototypes/Body/Templates/aghost.yml
Normal file
14
Resources/Prototypes/Body/Templates/aghost.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
- type: bodyTemplate
|
||||||
|
id: AGhostTemplate
|
||||||
|
name: "humanoid"
|
||||||
|
centerSlot: "torso"
|
||||||
|
slots:
|
||||||
|
left arm: Arm
|
||||||
|
left hand: Hand
|
||||||
|
right arm: Arm
|
||||||
|
right hand: Hand
|
||||||
|
connections:
|
||||||
|
left arm:
|
||||||
|
- left hand
|
||||||
|
right arm:
|
||||||
|
- right hand
|
||||||
@@ -5,6 +5,11 @@
|
|||||||
name: admin observer
|
name: admin observer
|
||||||
abstract: true
|
abstract: true
|
||||||
components:
|
components:
|
||||||
|
- type: Input
|
||||||
|
context: "aghost"
|
||||||
|
- type: Ghost
|
||||||
|
canInteract: true
|
||||||
|
- type: Hands
|
||||||
- type: PlayerInputMover
|
- type: PlayerInputMover
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: Kinematic
|
bodyType: Kinematic
|
||||||
@@ -17,3 +22,6 @@
|
|||||||
mask:
|
mask:
|
||||||
- GhostImpassable
|
- GhostImpassable
|
||||||
status: InAir
|
status: InAir
|
||||||
|
- type: Body
|
||||||
|
template: AGhostTemplate
|
||||||
|
preset: HumanPreset
|
||||||
|
|||||||
@@ -10,10 +10,11 @@
|
|||||||
- type: InteractionOutline
|
- type: InteractionOutline
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: KinematicController
|
bodyType: KinematicController
|
||||||
|
fixedRotation: true
|
||||||
fixtures:
|
fixtures:
|
||||||
- shape:
|
- shape:
|
||||||
!type:PhysShapeAabb
|
!type:PhysShapeCircle
|
||||||
bounds: "-0.35,-0.35,0.35,0.35"
|
radius: 0.35
|
||||||
mass: 5
|
mass: 5
|
||||||
mask:
|
mask:
|
||||||
- GhostImpassable
|
- GhostImpassable
|
||||||
|
|||||||
Reference in New Issue
Block a user