internal void OnMachineRemoved(AugmentedTile Tile) { if (Tile.Location != this) { throw new InvalidOperationException("Object instance mismatch in AugmentedLocation.OnMachineRemoved."); } Tiles.Remove(EncodeTileToString(Tile.Position)); if (!Context.IsMultiplayer || Context.IsMainPlayer) { // Now that the managed machine has been removed, refund the player with the augmentors that were placed there // by spawning them on the ground foreach (KeyValuePair <AugmentorType, int> KVP in Tile.Quantities) { int Quantity = KVP.Value; if (Quantity > 0) { Augmentor Refund = Augmentor.CreateInstance(KVP.Key, Quantity); int SpawnDirection = Augmentor.Randomizer.Next(4); Game1.createItemDebris(Refund, new Vector2(Tile.Position.X * Game1.tileSize, Tile.Position.Y * Game1.tileSize), SpawnDirection, Location, -1); } } } }
internal void OnMachineRemoved(AugmentedTile Tile) { if (Tile.Location != this) { throw new InvalidOperationException("Object instance mismatch in AugmentedLocation.OnMachineRemoved."); } Tiles.Remove(EncodeTileToString(Tile.Position)); if (!Context.IsMultiplayer || Context.IsMainPlayer) { // Now that the managed machine has been removed, refund the player with the augmentors that were placed there // by spawning them on the ground foreach (KeyValuePair <AugmentorType, int> KVP in Tile.Quantities) { int Quantity = KVP.Value; if (Quantity > 0) { Augmentor Refund = Augmentor.CreateInstance(KVP.Key, Quantity); int SpawnDirection; // When spawning items at the edge of the map, sometimes it seems to move them off the map. Mostly only happens when removing augmentors from incubators in coops, // so as a temporary workaround, spawn the items in the direction of the player when handling indestructible machines like incubators. if (!MachineInfo.IsDestructible(Tile.Machine)) { SpawnDirection = Game1.MasterPlayer.getGeneralDirectionTowards(Tile.VectorPosition, 0, true); } else { SpawnDirection = Augmentor.Randomizer.Next(4); } Game1.createItemDebris(Refund, new Vector2(Tile.Position.X * Game1.tileSize, Tile.Position.Y * Game1.tileSize), SpawnDirection, Location, -1); } } } }