More borg tweaks (#19143)
* borg tweaks but i'm gonna go code fun stuff first * werkin' on it * a ton of tweaks * fuck everyone and then myself
This commit is contained in:
@@ -15,28 +15,7 @@ namespace Content.Shared.Access.Systems
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AccessComponent, MapInitEvent>(OnAccessInit);
|
||||
SubscribeLocalEvent<AccessComponent, ComponentGetState>(OnAccessGetState);
|
||||
SubscribeLocalEvent<AccessComponent, ComponentHandleState>(OnAccessHandleState);
|
||||
}
|
||||
|
||||
private void OnAccessHandleState(EntityUid uid, AccessComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not AccessComponentState state) return;
|
||||
|
||||
// Don't do = because prediction and refs
|
||||
component.Tags.Clear();
|
||||
component.Groups.Clear();
|
||||
component.Tags.UnionWith(state.Tags);
|
||||
component.Groups.UnionWith(state.Groups);
|
||||
}
|
||||
|
||||
private void OnAccessGetState(EntityUid uid, AccessComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new AccessComponentState()
|
||||
{
|
||||
Tags = component.Tags,
|
||||
Groups = component.Groups,
|
||||
};
|
||||
SubscribeLocalEvent<AccessComponent, GetAccessTagsEvent>(OnGetAccessTags);
|
||||
}
|
||||
|
||||
private void OnAccessInit(EntityUid uid, AccessComponent component, MapInitEvent args)
|
||||
@@ -52,6 +31,22 @@ namespace Content.Shared.Access.Systems
|
||||
}
|
||||
}
|
||||
|
||||
private void OnGetAccessTags(EntityUid uid, AccessComponent component, ref GetAccessTagsEvent args)
|
||||
{
|
||||
if (!component.Enabled)
|
||||
return;
|
||||
|
||||
args.Tags.UnionWith(component.Tags);
|
||||
}
|
||||
|
||||
public void SetAccessEnabled(EntityUid uid, bool val, AccessComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
component.Enabled = val;
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Replaces the set of access tags we have with the provided set.
|
||||
/// </summary>
|
||||
@@ -122,12 +117,5 @@ namespace Content.Shared.Access.Systems
|
||||
TryAddGroups(uid, prototype.ExtendedAccessGroups, access);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class AccessComponentState : ComponentState
|
||||
{
|
||||
public HashSet<string> Tags = new();
|
||||
public HashSet<string> Groups = new();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user