public static void ServerRefreshLandClaimObject(IStaticWorldObject worldObject) { if (worldObject.IsDestroyed) { return; } if (!(worldObject.ProtoStaticWorldObject is IProtoObjectLandClaim)) { // not a land claim structure return; } var area = LandClaimSystem.ServerGetLandClaimArea(worldObject); if (area == null) { // incorrect land claim - no area attached return; } var areaBounds = LandClaimSystem.SharedGetLandClaimAreaBounds(area); var owners = LandClaimArea.GetPrivateState(area).LandOwners; foreach (var owner in owners) { var character = Server.Characters.GetPlayerCharacter(owner); if (character == null || !character.IsOnline) { continue; } if (!areaBounds.Contains(character.TilePosition)) { continue; } // the land claim contains an online owner character // reset the decay timer for this land claim StructureDecaySystem.ServerResetDecayTimer( worldObject.GetPrivateState <StructurePrivateState>()); using (var tempVisitedAreas = Api.Shared.WrapObjectInTempList(area)) { ServerResetDecayTimerRecursively(tempVisitedAreas.AsList(), areaBounds, character); } return; } }
void IInteractableProtoStaticWorldObject.ServerOnMenuClosed(ICharacter who, IStaticWorldObject worldObject) { var area = LandClaimSystem.ServerGetLandClaimArea(worldObject); if (area == null) { // area could be null in the Editor for the land claim without owners return; } var areasGroup = LandClaimArea.GetPublicState(area).LandClaimAreasGroup; if (CreativeModeSystem.SharedIsInCreativeMode(who) && !LandClaimSystem.ServerIsOwnedArea(area, who)) { Server.World.ExitPrivateScope(who, area); } Server.World.ExitPrivateScope(who, areasGroup); }
void IInteractableProtoWorldObject.ServerOnClientInteract(ICharacter who, IWorldObject worldObject) { var area = LandClaimSystem.ServerGetLandClaimArea((IStaticWorldObject)worldObject); if (area == null) { // area could be null in the Editor for the land claim without owners return; } var areasGroup = LandClaimArea.GetPublicState(area).LandClaimAreasGroup; if (!LandClaimSystem.ServerIsOwnedArea(area, who) && (PlayerCharacterSpectator.SharedIsSpectator(who) || CreativeModeSystem.SharedIsInCreativeMode(who))) { Server.World.EnterPrivateScope(who, area); } Server.World.EnterPrivateScope(who, areasGroup); }