Area of influence depends on followers MobState (#1439)

* simple anti-religion zone shader

* observers refactor
This commit is contained in:
Red
2025-06-18 21:46:58 +03:00
committed by GitHub
parent 54307574c3
commit 3a4bbcb289
11 changed files with 179 additions and 156 deletions

View File

@@ -86,7 +86,12 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
foreach (var god in GetGods(follower.Religion.Value))
{
_magicEnergy.TransferEnergy((uid, energy), god.Owner, follower.EnergyToGodTransfer, out _, out _, safe: true);
_magicEnergy.TransferEnergy((uid, energy),
god.Owner,
follower.EnergyToGodTransfer,
out _,
out _,
safe: true);
}
}
}
@@ -111,7 +116,12 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
Timer.Spawn(333,
() =>
{
_chatSys.TrySendInGameICMessage(speaker, message, type, ChatTransmitRange.Normal, nameOverride: MetaData(ent).EntityName, ignoreActionBlocker: true);
_chatSys.TrySendInGameICMessage(speaker,
message,
type,
ChatTransmitRange.Normal,
nameOverride: MetaData(ent).EntityName,
ignoreActionBlocker: true);
});
}
@@ -126,14 +136,14 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
private void OnObserverInit(Entity<CP14ReligionObserverComponent> ent, ref ComponentInit args)
{
foreach (var (religion, _) in ent.Comp.Observation)
{
var gods = GetGods(religion);
if (ent.Comp.Religion is null)
return;
foreach (var god in gods)
{
UpdatePvsOverrides(god);
}
var gods = GetGods(ent.Comp.Religion.Value);
foreach (var god in gods)
{
UpdatePvsOverrides(god);
}
}
@@ -163,7 +173,9 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
return;
var wrappedMessage =
Loc.GetString("cp14-altar-wrapped-message", ("name", MetaData(args.Source).EntityName), ("msg", args.Message));
Loc.GetString("cp14-altar-wrapped-message",
("name", MetaData(args.Source).EntityName),
("msg", args.Message));
SendMessageToGods(ent.Comp.Religion.Value, wrappedMessage, args.Source);
}
@@ -181,7 +193,14 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
channels.Add(godActor.PlayerSession.Channel);
}
_chat.ChatMessageToMany(ChatChannel.Notifications, msg, msg, source, false, true, channels, colorOverride: Color.Aqua);
_chat.ChatMessageToMany(ChatChannel.Notifications,
msg,
msg,
source,
false,
true,
channels,
colorOverride: Color.Aqua);
}
public FixedPoint2 GetFollowerPercentage(Entity<CP14ReligionEntityComponent> god)
@@ -221,10 +240,10 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
var query = EntityQueryEnumerator<CP14ReligionObserverComponent>();
while (query.MoveNext(out var uid, out var observer))
{
if (!observer.Observation.ContainsKey(ent.Comp.Religion.Value))
if (!observer.Active)
continue;
if (observer.Observation[ent.Comp.Religion.Value] <= ObservationOverrideRadius)
if (observer.Radius <= ObservationOverrideRadius)
continue;
ent.Comp.PvsOverridedObservers.Add(uid);
@@ -240,9 +259,9 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
if (ent.Comp.Session is null)
return;
foreach (var altar in ent.Comp.PvsOverridedObservers)
foreach (var observer in ent.Comp.PvsOverridedObservers)
{
_pvs.RemoveSessionOverride(altar, ent.Comp.Session);
_pvs.RemoveSessionOverride(observer, ent.Comp.Session);
}
ent.Comp.Session = null;
@@ -259,10 +278,10 @@ public sealed partial class CP14ReligionGodSystem : CP14SharedReligionGodSystem
}
}
public sealed class CP14SpokeAttemptEvent(string message, InGameICChatType type, ICommonSession? player) : CancellableEntityEventArgs
public sealed class CP14SpokeAttemptEvent(string message, InGameICChatType type, ICommonSession? player)
: CancellableEntityEventArgs
{
public string Message = message;
public InGameICChatType Type = type;
public ICommonSession? Player = player;
}