Modernize GhostComponent & Ghost API (#36858)
* Move CanReturnToBody to system * Move CanGhostInteract to system * Cleanup redundant datafields and viewvariables * Document datafields * Document component * Add SetTimeOfDeath Entity<T> overload, obsolete old version * Document public methods * Cleanup obsoleted method calls
This commit is contained in:
@@ -37,25 +37,68 @@ namespace Content.Shared.Ghost
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the ghost's time of death.
|
||||
/// </summary>
|
||||
public void SetTimeOfDeath(Entity<GhostComponent?> entity, TimeSpan value)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp))
|
||||
return;
|
||||
|
||||
if (entity.Comp.TimeOfDeath == value)
|
||||
return;
|
||||
|
||||
entity.Comp.TimeOfDeath = value;
|
||||
Dirty(entity);
|
||||
}
|
||||
|
||||
[Obsolete("Use the Entity<GhostComponent?> overload")]
|
||||
public void SetTimeOfDeath(EntityUid uid, TimeSpan value, GhostComponent? component)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.TimeOfDeath = value;
|
||||
SetTimeOfDeath((uid, component), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether or not the ghost player is allowed to return to their original body.
|
||||
/// </summary>
|
||||
public void SetCanReturnToBody(Entity<GhostComponent?> entity, bool value)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp))
|
||||
return;
|
||||
|
||||
if (entity.Comp.CanReturnToBody == value)
|
||||
return;
|
||||
|
||||
entity.Comp.CanReturnToBody = value;
|
||||
Dirty(entity);
|
||||
}
|
||||
|
||||
[Obsolete("Use the Entity<GhostComponent?> overload")]
|
||||
public void SetCanReturnToBody(EntityUid uid, bool value, GhostComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return;
|
||||
|
||||
component.CanReturnToBody = value;
|
||||
SetCanReturnToBody((uid, component), value);
|
||||
}
|
||||
|
||||
[Obsolete("Use the Entity<GhostComponent?> overload")]
|
||||
public void SetCanReturnToBody(GhostComponent component, bool value)
|
||||
{
|
||||
component.CanReturnToBody = value;
|
||||
SetCanReturnToBody((component.Owner, component), value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the ghost is allowed to interact with other entities.
|
||||
/// </summary>
|
||||
public void SetCanGhostInteract(Entity<GhostComponent?> entity, bool value)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp))
|
||||
return;
|
||||
|
||||
if (entity.Comp.CanGhostInteract == value)
|
||||
return;
|
||||
|
||||
entity.Comp.CanGhostInteract = value;
|
||||
Dirty(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user