public static void ClientObserving(IStaticWorldObject worldObject, bool isObserving) { if (isObserving) { structureLandClaimIndicator = ControlsCache <StructureLandClaimIndicator> .Instance.Pop(); structureLandClaimIndicator.Setup( isClaimed: LandClaimSystem.SharedIsLandClaimedByAnyone(worldObject.Bounds)); var offset = worldObject.ProtoStaticWorldObject.SharedGetObjectCenterWorldOffset(worldObject); componentStructureLandClaimIndicator = Api.Client.UI.AttachControl( worldObject, structureLandClaimIndicator, positionOffset: offset + (0, 0.3), isFocusable: false); } else { componentStructureLandClaimIndicator.Destroy(); componentStructureLandClaimIndicator = null; ControlsCache <StructureLandClaimIndicator> .Instance.Push(structureLandClaimIndicator); structureLandClaimIndicator = null; } }
public static void ClientInitialize(IStaticWorldObject worldObject) { // ensure there is no existing entry for it ClientDeinitialize(worldObject); var playerPosition = ClientCurrentCharacterHelper.Character?.TilePosition ?? Vector2Ushort.Zero; StructureLandClaimIndicator control = null; if (IsNearby(worldObject, playerPosition)) { var isLandClaimedByAnyone = LandClaimSystem.SharedIsObjectInsideAnyArea(worldObject); if (!isLandClaimedByAnyone) { var component = SetupFor(worldObject, isClaimed: false); control = (StructureLandClaimIndicator)component.Control; } } initializedOverlays[worldObject] = control; }
private static void DestroyControl(StructureLandClaimIndicator control) { control.AttachedToComponent?.Destroy(); control.AttachedToComponent = null; ControlsCache <StructureLandClaimIndicator> .Instance.Push(control); }