示例#1
0
        // Hit to unclaim
        public override InteractResult OnActLeft(InteractionContext context)
        {
            Vector2i?position = ClaimingUtils.GetClaimingPosition(context);
            Player   player   = context.Player;


            if (!position.HasValue)
            {
                return(InteractResult.NoOp);
            }
            var plot = PropertyManager.GetPlot(position.Value);
            var deed = plot?.Deed;

            if (deed == null)
            {
                return(ErrorAlreadyPublic);
            }

            // shift + click
            if (context.Modifier == InteractionModifier.Shift)
            {
                var nearbyDeeds = PropertyManager.ConnectedDeeds(player.User, position.Value)?.Distinct();
                if (nearbyDeeds != null && nearbyDeeds.Count() > 0)
                {
                    ClaimingUtils.ChangeWithDialog(player, nearbyDeeds, position.Value);
                }
                else
                {
                    return(ErrorNoNearby);
                }
                return(InteractResult.NoOp);
            }

            // ctrl + click
            else if (context.Modifier == InteractionModifier.Ctrl)
            {
                DeleteWithDialog(player, deed);
                return(InteractResult.NoOp); //
            }

            // regular click
            else
            {
                var deedsAfterUnclaim = deed.GetContiguousPartsWithAlterations(null, new List <Vector2i> {
                    position.Value
                });
                if (deedsAfterUnclaim.Count > 1)
                {
                    this.ConfirmUnclaim(player, Localizer.Do($"Unclaiming this plot will split {deed.Name} into {deedsAfterUnclaim.Count()} because property must be contiguous on a deed. Do you want to continue?"), position.Value);
                    return(InteractResult.NoOp);
                }
                var result = (InteractResult)PropertyManager.TryUnclaim(new GameActionPack(), player.User, player.User.Inventory, position.Value, autoPerform: true);
                return(result);
            }
        }
示例#2
0
        // Interact to examine
        public override InteractResult OnActInteract(InteractionContext context)
        {
            Vector2i?position = ClaimingUtils.GetClaimingPosition(context);

            if (!position.HasValue)
            {
                return(InteractResult.NoOp);
            }

            Deed deed = PropertyManager.GetDeed(position.Value);

            if (deed != null)
            {
                deed.OpenAuthorizationMenuOn(context.Player);
                return(InteractResult.Success);
            }

            return(base.OnActLeft(context));
        }