private void Canvas_Drop(object sender, DragEventArgs e) { UndertaleObject sourceItem = e.Data.GetData(e.Data.GetFormats()[e.Data.GetFormats().Length - 1]) as UndertaleObject; e.Effects = e.AllowedEffects.HasFlag(DragDropEffects.Link) && sourceItem != null && (sourceItem is UndertaleGameObject || sourceItem is UndertalePath) ? DragDropEffects.Link : DragDropEffects.None; if (e.Effects == DragDropEffects.Link) { if (sourceItem is UndertaleGameObject) { UndertaleGameObject droppedObject = sourceItem as UndertaleGameObject; var mousePos = e.GetPosition(RoomGraphics); UndertaleRoom room = this.DataContext as UndertaleRoom; var obj = new UndertaleRoom.GameObject() { X = (int)mousePos.X, Y = (int)mousePos.Y, ObjectDefinition = droppedObject, InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++ }; room.GameObjects.Add(obj); SelectObject(obj); } if (sourceItem is UndertalePath) { PreviewPath = sourceItem as UndertalePath; } } e.Handled = true; }
private void RoomObjectsTree_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { UndertaleRoom room = this.DataContext as UndertaleRoom; UndertaleObject selectedObj = ObjectEditor.Content as UndertaleObject; if (selectedObj is UndertaleRoom.Background) { UndertaleRoom.Background bg = selectedObj as UndertaleRoom.Background; bg.Enabled = false; bg.BackgroundDefinition = null; ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.View) { UndertaleRoom.View view = selectedObj as UndertaleRoom.View; view.Enabled = false; ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.Tile) { UndertaleRoom.Tile tile = selectedObj as UndertaleRoom.Tile; room.Tiles.Remove(tile); ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.GameObject) { UndertaleRoom.GameObject gameObj = selectedObj as UndertaleRoom.GameObject; room.GameObjects.Remove(gameObj); ObjectEditor.Content = null; } } }
private void AddObjectInstance(UndertaleRoom room) { var newobject = new UndertaleRoom.GameObject { InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++ }; room.GameObjects.Add(newobject); SelectObject(newobject); }
/// <summary> /// Checks if the enemy is in the blocking list for that room /// </summary> /// <param name="blockingList">List of blocked spawns</param> /// <param name="obj">Room object</param> /// <returns>If enemy is blocked</returns> static bool IsBlockedObject(List <Pair <string, ObjDesc> > blockingList, UndertaleRoom.GameObject obj) { if (blockingList.Exists( s => s.Second.Name == obj.ObjectDefinition.Name.Content && s.Second.XPos == obj.X && s.Second.YPos == obj.Y )) { return(true); } return(false); }
private void Canvas_Drop(object sender, DragEventArgs e) { UndertaleObject sourceItem = e.Data.GetData(e.Data.GetFormats()[e.Data.GetFormats().Length - 1]) as UndertaleObject; e.Effects = e.AllowedEffects.HasFlag(DragDropEffects.Link) && sourceItem != null && (sourceItem is UndertaleGameObject || sourceItem is UndertalePath) ? DragDropEffects.Link : DragDropEffects.None; if (e.Effects == DragDropEffects.Link) { if (sourceItem is UndertaleBackground) { } else if (sourceItem is UndertaleGameObject) { UndertaleGameObject droppedObject = sourceItem as UndertaleGameObject; var mousePos = e.GetPosition(RoomGraphics); UndertaleRoom room = this.DataContext as UndertaleRoom; UndertaleRoom.Layer layer = ObjectEditor.Content as UndertaleRoom.Layer; if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible && layer == null) { MessageBox.Show("Must have a layer selected", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (layer != null && layer.InstancesData == null) { MessageBox.Show("Must be on an instances layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error); return; } var obj = new UndertaleRoom.GameObject() { X = (int)mousePos.X, Y = (int)mousePos.Y, ObjectDefinition = droppedObject, InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++ }; room.GameObjects.Add(obj); if (layer != null) { layer.InstancesData.Instances.Add(obj); } SelectObject(obj); } if (sourceItem is UndertalePath) { PreviewPath = sourceItem as UndertalePath; } } e.Handled = true; (this.DataContext as UndertaleRoom)?.SetupRoom(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { UndertaleRoom.GameObject obj = value as UndertaleRoom.GameObject; if (obj == null) { return(0); } if (obj.ObjectDefinition == null || obj.ObjectDefinition.Sprite == null) { return(obj.Y); } return(obj.Y + (obj.ObjectDefinition.Sprite.OriginY * obj.ScaleY)); }
public void Command_Paste(object sender, ExecutedRoutedEventArgs e) { /*IDataObject data = Clipboard.GetDataObject(); * UndertaleObject obj = data.GetData(data.GetFormats()[0]) as UndertaleObject; * if (obj != null) * { * Debug.WriteLine("Paste"); * Debug.WriteLine(obj); * }*/ if (copied != null) { UndertaleRoom room = this.DataContext as UndertaleRoom; if (copied is UndertaleRoom.GameObject) { var other = copied as UndertaleRoom.GameObject; var obj = new UndertaleRoom.GameObject(); obj.X = other.X; obj.Y = other.Y; obj.ObjectDefinition = other.ObjectDefinition; obj.InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++; obj.CreationCode = other.CreationCode; obj.ScaleX = other.ScaleX; obj.ScaleY = other.ScaleY; obj.Color = other.Color; obj.Rotation = other.Rotation; obj.PreCreateCode = other.PreCreateCode; room.GameObjects.Add(obj); SelectObject(obj); } if (copied is UndertaleRoom.Tile) { var other = copied as UndertaleRoom.Tile; var obj = new UndertaleRoom.Tile(); obj.X = other.X; obj.Y = other.Y; obj.BackgroundDefinition = other.BackgroundDefinition; obj.SourceX = other.SourceX; obj.SourceY = other.SourceY; obj.Width = other.Width; obj.Height = other.Height; obj.TileDepth = other.TileDepth; obj.InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++; obj.ScaleX = other.ScaleX; obj.ScaleY = other.ScaleY; obj.Color = other.Color; room.Tiles.Add(obj); SelectObject(obj); } } }
public static void ClockPatches(UndertaleData data) { UndertaleGameObject go = new UndertaleGameObject(); go.Name = data.Strings.MakeString("obj_clock"); go.Sprite = null; go.Persistent = true; go.CollisionShape = 0; go.Depth = -1; go.Awake = true; go.Visible = true; CreateEvent(RabbitRunCode.coinstants, data, go, EventType.Create, 0u); CreateEvent(RabbitRunCode.yote, data, go, EventType.Other, (uint)EventSubtypeOther.RoomEnd); CreateEvent(RabbitRunCode.rabstart, data, go, EventType.Other, (uint)EventSubtypeOther.RoomStart); CreateEvent(RabbitRunCode.constantDrawer, data, go, EventType.Draw, (uint)EventSubtypeDraw.DrawGUIEnd); CreateEvent(RabbitRunCode.constantStepper, data, go, EventType.Step, (uint)EventSubtypeStep.Step); CreateEvent(RabbitRunCode.doneThisShit, data, go, EventType.Other, (uint)EventSubtypeOther.User0); data.GameObjects.Add(go); data.Code.ByName("gml_Script_pausegame").AppendGML("instance_activate_object(obj_clock);", data); UndertaleCode c = data.Code.ByName("gml_Script_goto_mainmenu"); c.AppendGML(RabbitRunCode.gohomebyebye, data); UndertaleCode endingCutscene = data.Code.ByName("gml_RoomCC_rm_n4_760_Create"); ReplaceInGML("t_scene_info = [", @"t_scene_info = [[cutscene_checkiflist, obj_constant.flagList, 191, 1, 1],[cutscene_activate_userevent, obj_clock,0],", data.Code.ByName("gml_RoomCC_rm_n4_760_Create"), data); ReplaceInGML("t_scene_info = [", @"t_scene_info = [[cutscene_activate_userevent, obj_clock,0],", data.Code.ByName("gml_RoomCC_rm_n5_33_Create"), data); var house = data.Rooms.ByName("rm_init"); UndertaleRoom.GameObject rogo = new UndertaleRoom.GameObject { ObjectDefinition = go, InstanceID = 108990u, GMS2_2_2 = true }; house.GameObjects.Add(rogo); house.Layers.Single((layer) => layer.LayerName.Content == "Instances").InstancesData.Instances.Add(rogo); }
public void Command_Paste(object sender, ExecutedRoutedEventArgs e) { /*IDataObject data = Clipboard.GetDataObject(); * UndertaleObject obj = data.GetData(data.GetFormats()[0]) as UndertaleObject; * if (obj != null) * { * Debug.WriteLine("Paste"); * Debug.WriteLine(obj); * }*/ if (copied != null) { UndertaleRoom room = this.DataContext as UndertaleRoom; UndertaleRoom.Layer layer = ObjectEditor.Content as UndertaleRoom.Layer; if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible && layer == null) { MessageBox.Show("Must paste onto a layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (copied is UndertaleRoom.GameObject) { if (layer != null && layer.InstancesData == null) { MessageBox.Show("Must be on an instances layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error); return; } var other = copied as UndertaleRoom.GameObject; var obj = new UndertaleRoom.GameObject(); obj.X = other.X; obj.Y = other.Y; obj.ObjectDefinition = other.ObjectDefinition; obj.InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastObj++; obj.CreationCode = other.CreationCode; obj.ScaleX = other.ScaleX; obj.ScaleY = other.ScaleY; obj.Color = other.Color; obj.Rotation = other.Rotation; obj.PreCreateCode = other.PreCreateCode; room.GameObjects.Add(obj); if (layer != null) { layer.InstancesData.Instances.Add(obj); } SelectObject(obj); } if (copied is UndertaleRoom.Tile) { if (layer != null && layer.AssetsData == null) { MessageBox.Show("Must be on an assets layer", "UndertaleModTool", MessageBoxButton.OK, MessageBoxImage.Error); return; } var other = copied as UndertaleRoom.Tile; var obj = new UndertaleRoom.Tile(); obj.X = -(int)other.Height; //other.X; obj.Y = -(int)other.Height; //other.Y; obj._SpriteMode = other._SpriteMode; obj.ObjectDefinition = other.ObjectDefinition; obj.SourceX = other.SourceX; obj.SourceY = other.SourceY; obj.Width = other.Width; obj.Height = other.Height; obj.TileDepth = other.TileDepth; obj.InstanceID = (Application.Current.MainWindow as MainWindow).Data.GeneralInfo.LastTile++; obj.ScaleX = other.ScaleX; obj.ScaleY = other.ScaleY; obj.Color = other.Color; if (layer != null) { layer.AssetsData.LegacyTiles.Add(obj); } else { room.Tiles.Add(obj); } SelectObject(obj); } } (this.DataContext as UndertaleRoom)?.SetupRoom(); }
private void RoomObjectsTree_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { UndertaleRoom room = this.DataContext as UndertaleRoom; UndertaleObject selectedObj = ObjectEditor.Content as UndertaleObject; if (selectedObj is UndertaleRoom.Background) { UndertaleRoom.Background bg = selectedObj as UndertaleRoom.Background; bg.Enabled = false; bg.BackgroundDefinition = null; ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.View) { UndertaleRoom.View view = selectedObj as UndertaleRoom.View; view.Enabled = false; ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.Tile) { UndertaleRoom.Tile tile = selectedObj as UndertaleRoom.Tile; if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible) { foreach (var layer in room.Layers) { if (layer.AssetsData != null) { layer.AssetsData.LegacyTiles.Remove(tile); } } } room.Tiles.Remove(tile); ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.GameObject) { UndertaleRoom.GameObject gameObj = selectedObj as UndertaleRoom.GameObject; if ((Application.Current.MainWindow as MainWindow).IsGMS2 == Visibility.Visible) { foreach (var layer in room.Layers) { if (layer.InstancesData != null) { layer.InstancesData.Instances.Remove(gameObj); } } } room.GameObjects.Remove(gameObj); ObjectEditor.Content = null; } else if (selectedObj is UndertaleRoom.Layer) { UndertaleRoom.Layer layer = selectedObj as UndertaleRoom.Layer; if (layer.InstancesData != null) { foreach (var go in layer.InstancesData.Instances) { room.GameObjects.Remove(go); } } room.Layers.Remove(layer); ObjectEditor.Content = null; } } }