public static IslandInstanceData SetFrom(this IslandInstanceData Data, string name, float worldX, float worldY, float rotation, int id, float width, float height) { Data.name = name; Data.worldX = worldX; Data.worldY = worldY; Data.rotation = rotation; Data.id = id; Data.spawnerOverrides = new Dictionary <string, string>(); Data.minTreasureQuality = Data.maxTreasureQuality = -1; Data.spawnPointRegionOverride = -1; Data.finalNPCLevelMultiplier = 1.0f; Data.instanceTreasureQualityMultiplier = 1.0f; Data.instanceTreasureQualityAddition = 0.0f; Data.finalNPCLevelOffset = 0; Data.IslandInstanceCustomDatas1 = ""; Data.IslandInstanceCustomDatas2 = ""; Data.IslandInstanceClientCustomDatas1 = ""; Data.IslandInstanceClientCustomDatas2 = ""; Data.islandWidth = width; Data.islandHeight = height; Data.islandPoints = 1; Data.singleSpawnPointX = 0; Data.singleSpawnPointY = 0; Data.singleSpawnPointZ = 0; return(Data); }
public static Island GetReferencedIsland(this IslandInstanceData Data, IDictionary <string, Island> islands) { if (!islands.ContainsKey(Data.name)) { return(null); } return(islands[Data.name]); }
public static bool ContainsPoint(this IslandInstanceData Data, Point p, MainForm mainForm) { Rectangle Rect = Data.GetRect(mainForm.currentProject, mainForm.islands); PointF rotatedP = StaticHelpers.RotatePointAround(p, new PointF(Rect.Left + Rect.Width / 2.0f, Rect.Top + Rect.Height / 2.0f), -Data.rotation); p.X = (int)rotatedP.X; p.Y = (int)rotatedP.Y; return(Rect.Contains(p)); }
public static Rectangle GetRect(this IslandInstanceData Data, Project currentProject, IDictionary <string, Island> islands) { if (currentProject == null) { return(new Rectangle()); } Island referencedIsland = Data.GetReferencedIsland(islands); float relativeX = referencedIsland.x * currentProject.coordsScaling; float relativeY = referencedIsland.y * currentProject.coordsScaling; return(new Rectangle((int)Math.Round(Data.worldX * currentProject.coordsScaling - relativeX / 2f), (int)Math.Round(Data.worldY * currentProject.coordsScaling - relativeY / 2f), (int)Math.Round(relativeX), (int)Math.Round(relativeY))); }
//Removes overrides with the same value as template public static void SyncOverridesWithTemplates(this IslandInstanceData Data, MainForm mainForm) { Island referencedIsland = Data.GetReferencedIsland(mainForm.islands); if (referencedIsland.spawnerOverrides == null) { return; } List <string> keysToRemove = new List <string>(); foreach (KeyValuePair <string, string> templateSpawnerOverride in referencedIsland.spawnerOverrides) { if (Data.spawnerOverrides.ContainsKey(templateSpawnerOverride.Key) && Data.spawnerOverrides[templateSpawnerOverride.Key] == templateSpawnerOverride.Value) { keysToRemove.Add(templateSpawnerOverride.Key); } } foreach (string keyToRemove in keysToRemove) { Data.spawnerOverrides.Remove(keyToRemove); } }
public EditIslandInstance(MainForm mainForm, IslandInstanceData targetInstance) { this.mainForm = mainForm; this.targetInstance = targetInstance; InitializeComponent(); targetInstance.SyncOverridesWithTemplates(mainForm); foreach (SpawnerInfoData spawnerInfo in mainForm.spawners.spawnersInfo) { SpawnerTemplate.Items.Add((string)spawnerInfo.Name); } spawnPointRegionOverrideTxtBox.Text = targetInstance.spawnPointRegionOverride.ToString(); finalNPCLevelMultiplierTxtBox.Text = (targetInstance.finalNPCLevelMultiplier == 1.0f) ? "1.0" :targetInstance.finalNPCLevelMultiplier.ToString(); finalNPCLevelOffsetTxtBox.Text = targetInstance.finalNPCLevelOffset.ToString(); instanceTreasureQualityMultiplierTxtBox.Text = (targetInstance.instanceTreasureQualityMultiplier == 1.0f) ? "1.0" : targetInstance.instanceTreasureQualityMultiplier.ToString(); instanceTreasureQualityAdditionTxtBox.Text = (targetInstance.instanceTreasureQualityAddition == 0.0f) ? "0.0" : targetInstance.instanceTreasureQualityAddition.ToString(); IslandInstanceCustomDatas1TxtBox.Text = targetInstance.IslandInstanceCustomDatas1; IslandInstanceCustomDatas2TxtBox.Text = targetInstance.IslandInstanceCustomDatas2; IslandInstanceClientCustomDatas1TxtBox.Text = targetInstance.IslandInstanceClientCustomDatas1; IslandInstanceClientCustomDatas2TxtBox.Text = targetInstance.IslandInstanceClientCustomDatas2; if (targetInstance.spawnerOverrides != null) { foreach (KeyValuePair <string, string> overrides in targetInstance.spawnerOverrides) { int index = spawnerOverridesGrid.Rows.Add(); spawnerOverridesGrid.Rows[index].Cells[SpawnerName.Name].Value = overrides.Key; if (SpawnerTemplate.Items.Contains(overrides.Value)) { spawnerOverridesGrid.Rows[index].Cells[SpawnerTemplate.Name].Value = overrides.Value; } } } }