Examine prediction (#23565)
* Initial prediction * new group handling * groups for all examines that use multiple rn * compile * why was it doing this?? * handle newlines with sorting properly
This commit is contained in:
@@ -81,27 +81,30 @@ namespace Content.Client.Construction
|
||||
|
||||
private void HandleConstructionGhostExamined(EntityUid uid, ConstructionGhostComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (component.Prototype == null) return;
|
||||
|
||||
args.PushMarkup(Loc.GetString(
|
||||
"construction-ghost-examine-message",
|
||||
("name", component.Prototype.Name)));
|
||||
|
||||
if (!_prototypeManager.TryIndex(component.Prototype.Graph, out ConstructionGraphPrototype? graph))
|
||||
if (component.Prototype == null)
|
||||
return;
|
||||
|
||||
var startNode = graph.Nodes[component.Prototype.StartNode];
|
||||
|
||||
if (!graph.TryPath(component.Prototype.StartNode, component.Prototype.TargetNode, out var path) ||
|
||||
!startNode.TryGetEdge(path[0].Name, out var edge))
|
||||
using (args.PushGroup(nameof(ConstructionGhostComponent)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
args.PushMarkup(Loc.GetString(
|
||||
"construction-ghost-examine-message",
|
||||
("name", component.Prototype.Name)));
|
||||
|
||||
foreach (ConstructionGraphStep step in edge.Steps)
|
||||
{
|
||||
args.Message.PushNewline();
|
||||
step.DoExamine(args);
|
||||
if (!_prototypeManager.TryIndex(component.Prototype.Graph, out ConstructionGraphPrototype? graph))
|
||||
return;
|
||||
|
||||
var startNode = graph.Nodes[component.Prototype.StartNode];
|
||||
|
||||
if (!graph.TryPath(component.Prototype.StartNode, component.Prototype.TargetNode, out var path) ||
|
||||
!startNode.TryGetEdge(path[0].Name, out var edge))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var step in edge.Steps)
|
||||
{
|
||||
step.DoExamine(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -366,13 +366,14 @@ namespace Content.Client.Examine
|
||||
var canSeeClearly = !HasComp<BlurryVisionComponent>(playerEnt);
|
||||
|
||||
OpenTooltip(playerEnt.Value, entity, centeredOnCursor, false, knowTarget: canSeeClearly);
|
||||
if (IsClientSide(entity)
|
||||
|| _client.RunLevel == ClientRunLevel.SinglePlayerGame) // i.e. a replay
|
||||
{
|
||||
message = GetExamineText(entity, playerEnt);
|
||||
UpdateTooltipInfo(playerEnt.Value, entity, message);
|
||||
}
|
||||
else
|
||||
|
||||
// Always update tooltip info from client first.
|
||||
// If we get it wrong, server will correct us later anyway.
|
||||
// This will usually be correct (barring server-only components, which generally only adds, not replaces text)
|
||||
message = GetExamineText(entity, playerEnt);
|
||||
UpdateTooltipInfo(playerEnt.Value, entity, message);
|
||||
|
||||
if (!IsClientSide(entity))
|
||||
{
|
||||
// Ask server for extra examine info.
|
||||
if (entity != _lastExaminedEntity)
|
||||
@@ -383,7 +384,6 @@ namespace Content.Client.Examine
|
||||
}
|
||||
|
||||
RaiseLocalEvent(entity, new ClientExaminedEvent(entity, playerEnt.Value));
|
||||
|
||||
_lastExaminedEntity = entity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user