public static Color?getColorFromProperty(Tile tile, string property) { if (tile.Properties.ContainsKey(property) && TMXColor.FromString(tile.Properties[property]) is TMXColor color) { return(color.toColor()); } return(null); }
private void Player_Warped(object sender, WarpedEventArgs e) { if (e.NewLocation.Map.Properties.ContainsKey("@WaterColor") && TMXColor.FromString(e.NewLocation.Map.Properties["@WaterColor"]) is TMXColor color) { e.NewLocation.waterColor.Value = new Color(color.R, color.G, color.B, color.A); } if (!e.IsLocalPlayer) { return; } e.NewLocation?.Map.enableMoreMapLayers(); if (e.NewLocation is GameLocation g && g.map is Map m) { int forceX = Game1.player.getTileX(); int forceY = Game1.player.getTileY(); int forceF = Game1.player.FacingDirection; if (e.OldLocation is GameLocation og && m.Properties.ContainsKey("ForceEntry_" + og.Name)) { string[] pos = m.Properties["ForceEntry_" + og.Name].ToString().Split(' '); if (pos.Length > 0 && pos[1] != "X") { int.TryParse(pos[0], out forceX); } if (pos.Length > 1 && pos[1] != "Y") { int.TryParse(pos[1], out forceY); } if (pos.Length > 2 && pos[2] != "F") { int.TryParse(pos[2], out forceF); } Game1.player.Position = new Vector2(forceX, forceY); Game1.player.FacingDirection = forceF; } if (m.Properties.ContainsKey("EntryAction")) { TileAction.invokeCustomTileActions("EntryAction", g, Vector2.Zero, "Map"); } PyUtils.checkDrawConditions(m); } }