Permissions and zones

Owners

Every piece has an owner (FPulseBuildOwner): the player id (unique net id, or the player name without online subsystem) and an optional team tag. The build component writes the player id from its player state and the team from Pulse::Team of PulseFoundation (the Pulse Team component on the player state, or Pulse Team Interface); builders without a player state (AI) use FallbackPlayerId. Pieces without owner belong to the world.

The piece keeps the team it was placed with. Permissions compare it with the player’s team of now, so a player who changes teams keeps the pieces they own but no longer shares the pieces of the old team.

Besides the team, an owner can have a group: the players of a party or the friends, given by a bridge (Pulse::Build::OnCheckOwnerGroup, for example PulseBuildOnlineBridge with the party of the owner). The group counts like the team for the permission Owner and Team (bAllowGroup), for claims and for decay in claims (Pulse::Build::IsOwnerOrGroup).

Permissions

Every action on a piece (EPulseBuildAction: Place, Remove, Change, Repair, Work, Use) goes through UPulseBuildComponent::CheckPermission, on the client for the preview and again on the server:

  1. The settings’ DefaultPermissions (instanced FPulseBuildPermission, all must allow). The default Owner and Team permission lets only the owner (with bAllowTeam the team, with bAllowGroup the group) do the actions in Actions (default Remove, Change, Repair). Custom (Blueprint) calls a UPulseBuildPermissionHandler (its Check Permission answers with Make Pulse Success or Make Pulse Failure).
  2. The zones and claims of the world (below).

Can Do Build Action (K2_CheckPermission(Action, PieceId)) gives Blueprints the same answer as an FPulseResult (the reason of the permission or zone that refused, with its text), for example to grey out a menu entry. Every permission answers with an FPulseResult; one that refuses without a reason refuses as Pulse.Result.Failure.Build.NotAllowed.

Zones

APulseBuildZone is a box volume (place it in the level or spawn it with SetupZone), replicated and always relevant:

Type Effect
Allow Building is allowed here; AllowedPieces (tag query) limits which pieces, PieceLimit how many
Forbid No building (spawn areas, quest places)
Claim Belongs to ClaimOwner: other players may do nothing here

The zone with the highest Priority decides (an allow zone inside a forbid zone). With bRequireBuildZone in the settings players can only build inside allow zones and their own claims.

The zone replicates one net state (GetNetState(): type, claim owner, piece limit, extent). The authored fields Type, ClaimOwner and PieceLimit count when the zone is created; at runtime change zones with SetupZone and SetPieceLimit (a direct write after spawning reaches neither the checks nor the clients; a deferred spawn may set them before FinishSpawning). The authored fields mirror the net state, so Blueprints that read them keep working.

A zone placed in the level whose value goes back to its default at runtime (limit 0, a claim released, Forbid) is not sent to clients that join later: they keep the authored value, and their preview may disagree with the server. Change level zones before play, or spawn zones at runtime for values that change.

The zone rule

The zone check is a pure function: Pulse::Build::Zones::CheckAction(Query, OutReason) looks only at an FPulseBuildZoneQuery (action, player, piece and its bounds, the zones around it, the counts, the claims, the group answers and the two settings). UPulseBuildZoneSubsystem::MakeQuery(Context) fills the query from the world, and CheckAction(Context) of the subsystem is just both together, as an FPulseResult with the text of the rule as its message:

  • Counts are taken only where the rule reads them (NeedsPieceCount, NeedsPlayerPieceCount), the claims of the world only for claim pieces (NeedsClaims), and then only those near enough to be too close.
  • The group of each claim owner around the piece is asked once (Pulse::Build::OnCheckOwnerGroup) before the rule runs.
  • A query that lacks an input the rule needs (a count of -1, claims not filled) is refused with a warning, never allowed: tools that build their own query must fill every input the Needs... functions ask for.

Claims

A piece with the Claim trait claims a cylinder for its owner (Radius, HalfHeight): a totem, a flag, a workbench. Others cannot build, remove or change anything inside. PieceLimit limits the pieces in the claim, bPreventsDecay keeps the owner’s pieces from decaying, and claims of different players keep apart (Gap). Removing the claim piece ends the claim.

To build only inside claims, add the placement rule In Own Claim to the pieces or to the Default Rules. To let claims stand only on ground of the builder’s faction (a territory of PulseFactionTerritory), use the rule Own Faction Territory of PulseBuildFactionTerritoryBridge on the claim pieces.

Changing the ground

The action Terrain stands for changing the ground: digging, filling, flattening. It has no piece, only an area. Pulse::Build::CheckTerrain(World, Player, Area, Check) (Blueprint: Can Change Terrain of the zone subsystem, with a place and a radius) answers on any machine whether a player may change the ground there:

  1. the default permissions for the action Terrain (a Custom (Blueprint) permission can answer it; Owner and Team has no piece to look at and allows);
  2. the zones: a claim of others that the area touches refuses (“This area belongs to someone else.”), and so does a forbid zone unless an allow zone with a higher priority decides first (“You cannot change the ground here.”);
  3. with Only In Own Claim (FPulseBuildTerrainCheck, on by default) a claim of the player (owner, with bAllowTeam the team, with bAllowGroup the group) at the center of the area, with Whole Area Inside also at four points on its side; else Pulse.Result.Failure.Build.TerrainOutsideClaim (“You can only change the ground inside your own claim.”).

The player is any of its actors: Pulse::Build::MakePlayerOwner takes the owner of its build component, else its player id and team. Pulse Build changes no ground itself: a terrain system asks the query, for example the rule In Own Claim of PulseWorldBuildBridge for digging and filling in Pulse World.

Limits

Limit Where
Pieces per player PlayerPieceLimit in the settings (blueprints count as a whole, with the same rule: Pulse::Build::Zones::IsOverPlayerLimit)
Pieces per zone or claim PieceLimit of the zone or the claim trait
Pieces of a kind The Limit rule (per player or for everyone)

Debugging

  • Pulse.Build.Zones.Debug 1 draws zones near the player.
  • PulseBuildZones prints the zones at the player.
  • PulseBuildSpawnZone <allow|forbid|claim> [half size] spawns a zone around the player.
  • PulseBuildTeam <tag> sets the team of the player (Pulse::Team, on the server).

This site uses Just the Docs, a documentation theme for Jekyll.