Until someone finds out how to solve this problem using the build in warp property, i came up with my own solution. It isn't as nice but i thought i am gonna share it with you if someone has the same problem.
ModEntry.cs
using System;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewModdingAPI.Utilities;
using StardewValley;
using xTile;
namespace StardewValleyMod {
public class ModEntry : Mod {
private IModHelper helper;
private WarpManager warpManager;
public override void Entry(IModHelper helper) {
this.helper = helper;
warpManager = new WarpManager();
warpManager.add(new Warp(new Vector2(60, 15), "Farm", new Vector2(5, 5), "TestRoom"));
GameEvents.FourthUpdateTick += warpManager.update;
}
}
}
WarpManager.cs
using System;
using System.Collections.Generic;
using StardewModdingAPI;
using StardewValley;
namespace StardewValleyMod {
class WarpManager {
private List<Warp> warps;
public WarpManager() {
warps = new List<Warp>();
}
public void add(Warp warp) {
warps.Add(warp);
}
public void update(object sender, EventArgs args){
update();
}
public void update() {
if(Context.IsWorldReady) {
int x = Game1.player.getStandingX() / Game1.tileSize;
int y = Game1.player.getStandingY() / Game1.tileSize;
foreach(Warp warp in warps) {
warp.tryToWarp(x, y, Game1.currentLocation.Name);
}
}
}
}
}
Warp.cs
using System;
using Microsoft.Xna.Framework;
using StardewValley;
namespace StardewValleyMod {
class Warp {
private Vector2 from;
private Vector2 to;
String fromMap;
String toMap;
private int rotation;
private bool triggerFlag;
public Warp(Vector2 from, String fromMap, Vector2 to, String toMap, int rotation) : this(from, fromMap, to, toMap) {
this.rotation = rotation;
}
public Warp(Vector2 from, String fromMap, Vector2 to, String toMap) {
this.from = from;
this.to = to;
this.fromMap = fromMap;
this.toMap = toMap;
rotation = 2;
}
public bool tryToWarp(int x, int y, String mapName) {
if(!triggerFlag) {
if(x == from.X && y == from.Y && mapName.Equals(fromMap)) {
Game1.warpFarmer(toMap, (int) to.X, (int) to.Y, (int) rotation);
triggerFlag = true;
return true;
}
} else if(!mapName.Equals(fromMap)) {
triggerFlag = false;
}
return false;
}
}
}