public FishingActionState( ICharacter character, double durationSeconds, IItem itemFishingRod, Vector2D fishingTargetPosition) : base(character, null, durationSeconds) { this.ItemFishingRod = itemFishingRod; this.FishingTargetPosition = fishingTargetPosition; if (Api.IsServer) { this.SharedFishingSession = Api.Server.World.CreateLogicObject <FishingSession>(); FishingSession.ServerSetup(this.SharedFishingSession, character); } }
public void ClientOnItemUse() { var skeletonRenderer = PlayerCharacter.GetClientState(this.Character).SkeletonRenderer; var currentAnimationName = skeletonRenderer.GetCurrentAnimationName(AnimationTrackIndexes.Extra); if (currentAnimationName is not null && currentAnimationName.IndexOf("Fishing", StringComparison.Ordinal) >= 0) { // the animation is not yet finished return; } // player clicked a mouse so the rod should be removed if (this.SharedFishingSession is not null && FishingSession.GetPublicState(this.SharedFishingSession) .IsFishBiting) { // fish baiting, request pulling FishingSystem.ClientPullFish(); // it's no longer possible to abort this action this.clientIsAbortSent = true; return; // Alas we don't know what the fish was caught yet // so the game cannot stop action immediately and display a pulling animation. // (Please note that players with high ping are not penalized for having // a shorter time to react on fish baiting - the baiting period is extended for them by ping duration) } // Not yet bating on the client side, but probably bating on the server side. // Let's just send an abort command to server and wait for a server-side cancellation command. // This way we can be certain there will be no discrepancy with the server state. if (this.clientIsAbortSent) { return; } System.ClientSendAbortAction(this.Request); this.clientIsAbortSent = true; }