* basic religion vision * block god interactions * skill tree mob specify * silvania setup?? * clustering shader optimization * gods department & job * random gods jobs * Luxian god * Update Nature.png * Update sphere_of_light.yml * god chat * Update ChatSystem.cs * OBSERVATION * public observation and basic follower api * shader tweaks * improve shaders * spawning and praying on altars * altars ppvs override * move pvs overridiation from altars to observers * shader coloration * spectral z mover * god magic radius restricted * guide how to believe in god * sends messages to god when smoeone wanna become follower * follower doAfter * goodbye luxian, welcome lumera * goodbye silvania, welcome merkas * som polish and renamings * gods fast travel * Update altar.ftl * some lumera sfx * renouncing patrons! * renounce followers * followewr percentage calculation * remove from player-facing * fix * Update sphere_of_light.yml * Update base.yml
97 lines
2.9 KiB
C#
97 lines
2.9 KiB
C#
using System.Numerics;
|
|
using Content.Shared._CP14.Religion.Components;
|
|
using Content.Shared._CP14.Religion.Prototypes;
|
|
using Content.Shared.Interaction;
|
|
using Content.Shared.Verbs;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared._CP14.Religion.Systems;
|
|
|
|
public abstract partial class CP14SharedReligionGodSystem
|
|
{
|
|
private void InitializeObservation()
|
|
{
|
|
SubscribeLocalEvent<CP14ReligionEntityComponent, InRangeOverrideEvent>(OnGodInRange);
|
|
SubscribeLocalEvent<CP14ReligionEntityComponent, MenuVisibilityEvent>(OnGodMenu);
|
|
}
|
|
|
|
private void OnGodInRange(Entity<CP14ReligionEntityComponent> ent, ref InRangeOverrideEvent args)
|
|
{
|
|
args.Handled = true;
|
|
|
|
args.InRange = InVision(args.Target, ent);
|
|
}
|
|
|
|
private void OnGodMenu(Entity<CP14ReligionEntityComponent> ent, ref MenuVisibilityEvent args)
|
|
{
|
|
args.Visibility &= ~MenuVisibility.NoFov;
|
|
}
|
|
|
|
public void EditObservation(EntityUid target, ProtoId<CP14ReligionPrototype> religion, float range)
|
|
{
|
|
EnsureComp<CP14ReligionObserverComponent>(target, out var observer);
|
|
|
|
if (observer.Observation.ContainsKey(religion))
|
|
{
|
|
var newRange = Math.Clamp(observer.Observation[religion] + range, 0, float.MaxValue);
|
|
|
|
if (newRange <= 0)
|
|
{
|
|
observer.Observation.Remove(religion);
|
|
}
|
|
else
|
|
{
|
|
observer.Observation[religion] = newRange;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Otherwise, add a new observation for the religion.
|
|
observer.Observation.Add(religion, range);
|
|
}
|
|
Dirty(target, observer);
|
|
}
|
|
|
|
public bool InVision(EntityUid target, Entity<CP14ReligionEntityComponent> user)
|
|
{
|
|
var position = Transform(target).Coordinates;
|
|
|
|
return InVision(position, user);
|
|
}
|
|
|
|
public bool InVision(EntityCoordinates coords, Entity<CP14ReligionEntityComponent> user)
|
|
{
|
|
if (!HasComp<CP14ReligionVisionComponent>(user))
|
|
return true;
|
|
|
|
var userXform = Transform(user);
|
|
var query = EntityQueryEnumerator<CP14ReligionObserverComponent, TransformComponent>();
|
|
while (query.MoveNext(out var uid, out var observer, out var xform))
|
|
{
|
|
if (!observer.Active)
|
|
continue;
|
|
|
|
if (xform.MapID != userXform.MapID)
|
|
continue;
|
|
|
|
if (user.Comp.Religion is null)
|
|
continue;
|
|
|
|
if (!observer.Observation.ContainsKey(user.Comp.Religion.Value))
|
|
continue;
|
|
|
|
|
|
var obsPos = _transform.GetWorldPosition(uid);
|
|
var targetPos = coords.Position;
|
|
if (Vector2.Distance(obsPos, targetPos) <= observer.Observation[user.Comp.Religion.Value])
|
|
{
|
|
// If the observer is within range of the target, they can see it.
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|