Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examining now has larger range. Ghosts have no range limit. Fixed some messy code and some bad netcode.
- Loading branch information
Showing
8 changed files
with
92 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Content.Shared/GameObjects/Components/Mobs/ExaminerComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Serialization; | ||
using Robust.Shared.ViewVariables; | ||
|
||
namespace Content.Shared.GameObjects.Components.Mobs | ||
{ | ||
/// <summary> | ||
/// Component required for a player to be able to examine things. | ||
/// </summary> | ||
public sealed class ExaminerComponent : Component | ||
{ | ||
public override string Name => "Examiner"; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
private bool _doRangeCheck = true; | ||
|
||
/// <summary> | ||
/// Whether to do a distance check on examine. | ||
/// If false, the user can theoretically examine from infinitely far away. | ||
/// </summary> | ||
public bool DoRangeCheck => _doRangeCheck; | ||
|
||
public override void ExposeData(ObjectSerializer serializer) | ||
{ | ||
base.ExposeData(serializer); | ||
|
||
serializer.DataField(ref _doRangeCheck, "DoRangeCheck", true); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Content.Shared/GameObjects/EntitySystems/ExamineSystemShared.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Content.Shared.GameObjects.Components.Mobs; | ||
using JetBrains.Annotations; | ||
using Robust.Shared.GameObjects.Systems; | ||
using Robust.Shared.Interfaces.GameObjects; | ||
|
||
namespace Content.Shared.GameObjects.EntitySystems | ||
{ | ||
public abstract class ExamineSystemShared : EntitySystem | ||
{ | ||
public const float ExamineRange = 8f; | ||
public const float ExamineRangeSquared = ExamineRange * ExamineRange; | ||
|
||
[Pure] | ||
protected static bool CanExamine(IEntity examiner, IEntity examined) | ||
{ | ||
if (!examiner.TryGetComponent(out ExaminerComponent examinerComponent)) | ||
{ | ||
return false; | ||
} | ||
|
||
if (!examinerComponent.DoRangeCheck) | ||
{ | ||
return true; | ||
} | ||
|
||
if (examiner.Transform.MapID != examined.Transform.MapID) | ||
{ | ||
return false; | ||
} | ||
|
||
var delta = examined.Transform.WorldPosition - examiner.Transform.WorldPosition; | ||
return delta.LengthSquared <= ExamineRangeSquared; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters